‼️ Note: v1 will soon be deprecated!
How to create a Withdrawal?
The
createWithdraw method is used for creating a withdrawat payment on the ChainBerry infrastructure.php$withdrawParams = [ 'amount' => '50.00', 'currency' => 'USDT', 'callbackUrl' => 'https://your-callback-url.com/webhook', 'tradingAccountLogin' => 'user-12345', 'address' => '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6', // Required 'partnerPaymentID' => '0766167c-68dd-491d-a454-9fc5bb6eea3e', 'paymentGatewayName' => 'ETH', // Optional 'withdrawCurrency' => 'USDT' // Optional ]; try { $withdraw = BerrySdk::createWithdraw($withdrawParams); echo "Withdrawal created: " . $withdraw['paymentId']; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Parameters
Parameter | Required | Type | Default | Example | Description |
amount | true | string | undefined | 0.001 | Amount of cryptocurrency to deposit in the ##.## format |
currency | true | string | undefined | ETH | Currency that the Customer will receive from CB |
paymentGatewayName | false | string | undefined | ETH | Network on which the funds will be sent. If not set, it defaults to currency field |
withdrawCurrency | false | string | undefined | ETH | Currency that the Customer will receive from CB. Defaults to currency |
address | true | string | undefined | External address provided by the user to which the funds will be withdrawn | |
callbackUrl | true | string | undefined | Callback for receiveing transaction updates | |
tradingAccountLogin | true | true | undefined | Reference id for the user provided by the partner | |
partnerPaymentID | false | string | undefined | Payment ID provided by the Partner |
Returns
Parameter | Type | Example | Description |
paymentId | string | Id of the payment for easy tracking | |
status | string | ||
finalAmount | string | 15.60 | |
netAmount | string | 15.50 | |
transactionCurrency | string | ETH | Cryptocurrency that is sent from CB |
finalCurrency | string | ETH | Cryptocurrency that the Customer received |
processingFee | string | 0.10 | Estimated transaction fee |
convertRatio | |||
errorList | |||
tempTransactionId | |||
address | string | External Customer wallet for receiving funds |
Errors
TBD
How to track Withdrawal payments?
You can track transaction changes in one or two ways:
- Receive updates automatically to the
callbackUrlprovided in thecreateWithdraw
- Manually fetch the transaction with
getWithdrawmethod
Tracking transaction changes through a callback
For every deposit transaction, you need to provide a
callbackUrl. Whenever a status changes, the route will be called with the following body:Parameter | Type | Example | Description |
paymentId | string | ChainBerry id of the transaction | |
status | string | ||
depositAddress | string | Customer address on chain | |
transactionAmount | number | netAmount + processingFee | |
netAmount | number | Amount the user sent | |
processingFee | number | Blockchain transaction fees | |
transactionCurrency | string | Currency the Customer has deposited | |
finalAmount | number | Amount the user received | |
finalCurrency | string | Currency the user received | |
conversionRate | number | Conversion rate between transactionCurrency and finalCurrency | |
cryptoTransactionInfo.txid | string | Transaction hash on the blockchain | |
cryptoTransactionInfo.confirmations | number | Number of confirmations on the chain | |
cryptoTransactionInfo.amount | number | Total amount. Same as transactionAmount | |
cryptoTransactionInfo.confirmedTime | string | Time of the confirmation on chain | |
cryptoTransactionInfo.status | string | ||
cryptoTransactionInfo.processingFee | number | Same as processingFee | |
cryptoTransactionInfo.conversionRate | number | Same as conversionRate | |
signature | string | ChainBerry payload signature |
Manually tracking transaction changes
phptry { $withdraw = BerrySdk::getWithdraw($paymentId); echo "Withdrawal status: " . $withdraw['status']; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Parameters:
Parameter | Required | Type | Default | Description |
paymentId | true | string | undefined | Payment Id returned by the createWithdraw method |
Returns:
Same as the callback.
Errors:
No payment found for provided id. |
What are the statuses of Withdrawal payments?
CREATED | Payment created in the system, but the funds haven’t been sent to the blockchain. |
KYT IN PROGRESS | Transaction is being verified by the KYT provider. |
PROCESSING | Transaction is being processed by the blockchain and waiting confirmation. |
PENDING APPROVAL | Transaction was flagged as risky and is pending manual review by an Operative. |
CONFIRMED | Transaction has been confirmed by the blockchain and the funds are sent to the Customer. |
REJECTED | Transaction was rejected by an Operative and the funds stay in the system. |
FAILED | Transaction has failed for some reason. |