This section explains how to set up auto-conversion deposits using BerrySDK and the BerryPay flow. Users initiate the deposit through your app using the SDK, then complete the transaction via the embedded BerryPay interface. Once confirmed, the crypto is automatically converted into stablecoins and sent directly to the user's wallet.
There are currently two methods for conversions:
createAutoConversion- used for generating an conversion deposit payment for the end user with automatic wallet generation in the background.
getAutoConversion- used for tracking the status of the conversion deposit payment
What will you find here?
How to create a Conversion Deposit?ParametersResponseErrorsHow to track Conversion payments?Tracking transaction changes through a callbackAdditional InformationSupported currenciesSupported CurrenciesSupported StablecoinsSupported NetworksDestination Currencies
Check out older Conversions docs:
ConversionsHow to create a Conversion Deposit?
The
createAutoConversion method is used for creating an auto-conversion deposit payment on the ChainBerry infrastructure. If the user is new, or doesn’t have a dedicated wallet for the chosen currency, the wallet will be created automatically in the background.php$autoConversionParams = [ 'fromAmount' => '25', 'fromCurrency' => 'TON', 'toCurrency' => 'USDC', 'toNetwork' => 'BNB', 'partnerUserID' => '9d57ccb2-b9a8-40d4-b985-1c17be009e90', 'partnerPaymentID' => '0766167c-68dd-491d-a454-9fc5bb6eea3e', 'callbackUrl' => 'https://your-callback-url.com/webhook' ]; try { $autoConversion = BerrySdk::createAutoConversion($autoConversionParams); echo "Auto-Conversion created: " . $autoConversion['paymentId']; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Parameters
Parameter | Required | Type | Default | Example | Description |
fromAmount | true | string | undefined | 0.01 | Amount of cryptocurrency to deposit in the ##.## format |
fromCurrency | false | string | undefined | BNB | Currency that the Customer will send. Defaults to currency |
fromNetwork | false | string | undefined | BNB | Network on which the funds will be sent. |
toCurrency | true | string | undefined | USDT | Currency that the Customer will receive. Currently defaults to Tron network. |
toNetwork | false | string | undefined | BNB | Network on which the funds will be received. |
partnerUserID | false | true | undefined | Reference id for the user provided by the partner | |
partnerPaymentID | false | string | undefined | Payment ID provided by the Partner | |
callbackUrl | true | string | undefined | Callback for receiveing transaction updates |
Response
Parameter | Type | Example | Description |
paymentID | string | Id of the payment for easy tracking | |
status | string | CONFIRMED | Check out Conversion Payment Statuses > |
fromAmount | string | 15.60 | Amount the Customer should send |
fromAmountUsd | string | 15.50 | fromAmount in usd |
fromCurrency | string | ETH | Cryptocurrency that the Customer sent |
fromNetwork | string | ETH | Network through which the Customer will sent the funds |
address | string | Customer wallet for sending funds | |
toAmount | string | 0.10 | Amount the Customer will receive in the desired currency |
toAmountUsd | string | 15.50 | toAmount in usd |
toCurrency | string | USDT | Cryptocurrency that the Customer received |
toNetwork | string | TRX | Network on which the Customer will receive the converted funds |
conversionRate | string | 15.50 | fromCurrency / toCurrency rate |
partnerUserID | string | Reference ID for the user provided by the partner | |
partnerPaymentID | string | Payment ID provided by the Partner | |
checkoutUrl | string | Url to BerryPay for completing the transaction | |
commissionAmount | string | 0.05 | Commission Amount to be paid to ChainBerry |
commissionCurrency | string | BNB | Currency in which the commission is paid |
commissionNetwork | string | BNB | Network on which the commission is paid |
Errors
Status | Error | Message |
401 | UNAUTHORIZED | API Token is incorrect or missing. |
401 | UNAUTHORIZED | Payload Signature is incorrect or missing. |
400 | BAD_REQUEST | Amount is invalid. It should be a ##.## formatted string. |
400 | BAD_REQUEST | Amount is required. |
400 | BAD_REQUEST | From currency is invalid. It should be one of the supported currencies. |
400 | BAD_REQUEST | From currency is required. |
400 | BAD_REQUEST | From network is invalid. It should be one of the supported networks |
400 | BAD_REQUEST | To currency is invalid. It should be one of the supported currencies. |
400 | BAD_REQUEST | To currency is required. |
400 | BAD_REQUEST | To network is invalid. It should be one of the supported networks |
400 | BAD_REQUEST | Callback URL is invalid. |
400 | BAD_REQUEST | Callback URL is required. |
400 | BAD_REQUEST | Partner User ID is invalid. It should be a string. |
400 | BAD_REQUEST | Partner Payment ID is invalid. It should be a string. |
javascript{ status: 401, error: "UNAUTHORIZED", message: "API Token is incorrect or missing." } { status: 400, error: "BAD_REQUEST", message: { amount: "Amount is invalid. It should be a ##.## formatted string.", network: "Network is invalid. It should be one of the following ETH, BNB, TRX and align with the Currency field.", callbackUrl: "Callback URL is required.", } }
How to track Conversion payments?
You can track payment changes by receiving updates automatically to the
callbackUrl provided in the createAutoConversionTracking transaction changes through a callback
For every auto-conversion deposit payment, 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 | Check out Conversion Payment Statuses > | |
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 |
Additional Information
Supported currencies
Supported Currencies
Bitcoin (BTC), Ethereum (ETH), Binance (BNB), Polygon (POL), Solana (SOL), Tron (TRX), Litecoin (LTC), Ton Coin (TON)
Supported Stablecoins
- USDT (ETH, BSC, POL, SOL, TRX)
- USDC (ETH, BSC, POL, SOL)
Supported Networks
Ethereum (ETH), Binance Smart Chain (BNB), Polygon (POL), Solana (SOL), Tron (TRX)
Destination Currencies
ChainBerry currently supports only conversions to stablecoins:
- USDT (ETH, BSC, POL, SOL, TRX)
- USDC (ETH, BSC, POL, SOL)