Simulating a Payment with Cryptocurrency
When you create a card payment for a cryptocurrency transaction, the payment goes through two phases: creation and completion. You can simulate both phases in the sandbox. In the creation phase, you specify the currency and amount that the merchant wants to receive in the client wallet. In the completion phase, you specify the cryptocurrency that the customer pays with. Note that in production, Rapyd handles the completion phase.
Relevant where the payment method category is ewallet and the payment method type has crypto as part of its name, for example at_crypto_ewallet.
Prerequisites
Keys to the sandbox environment for your user.
A properly configured testing tool.
How
Create a payment with the following settings:
currency- The name of a fiat currency that the payment method supports. These currencies are listed in the response to List Payment Methods by Country.amount- The amount of fiat currency with the same value as the cryptocurrency the customer wants to pay with.
For example:
Request
curl -X post 'https://sandboxapi.rapyd.net/v1/payments/' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -H 'idempotency: your-idempotency-parameter-here' \ -H 'salt: your-random-string-here' \ -H 'signature: your-calculated-signature-here' \ -H 'timestamp: your-unix-timestamp-here' \ --data-raw '{ "amount": 14.47, "currency": "USD", "payment_method": { "type": "at_crypto_ewallet" }, "customer": "cus_4e25112ac20e144ad073a614dc46934b", "complete_payment_url": "https://complete.rapyd.net", "error_payment_url": "https://error.rapyd.net" }'
The platform returns the following response and the PAYMENT_SUCCEEDED webhook, which has the same content:
Response
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "aaf91d35-9878-46cd-a948-5bb98c9a0e2e" }, "data": { "id": "payment_890472b66f16b046e962706e1ea343b2", "amount": 0, "original_amount": 14.47, "is_partial": false, "currency_code": "USD", "country_code": "AT", "status": "ACT", "description": "", "merchant_reference_id": "", "customer_token": "cus_4e25112ac20e144ad073a614dc46934b", "payment_method": "other_1cc7fae4a180b8aac23b06048ab401f9", "payment_method_data": { "id": "other_1cc7fae4a180b8aac23b06048ab401f9", "type": "at_crypto_ewallet", "category": "ewallet", "metadata": {}, "image": "", "webhook_url": "", "supporting_documentation": "", "next_action": "not_applicable", "bic_swift": "", "account_last4": "" }, "auth_code": null, "expiration": 1767880027, "captured": true, "refunded": false, "refunded_amount": 0, "receipt_email": "", "redirect_url": "", "complete_payment_url": "https://complete.rapyd.net", "error_payment_url": "https://error.rapyd.net", "receipt_number": "", "flow_type": "", "address": null, "statement_descriptor": "Doc Team", "transaction_id": "", "created_at": 1767620827, "metadata": {}, "failure_code": "", "failure_message": "", "paid": false, "paid_at": 0, "dispute": null, "refunds": null, "order": null, "outcome": null, "visual_codes": {}, "textual_codes": { "code": "paygw_572e869088d8d8ea3727fb6c74e7e7f3" }, "instructions": [ { "name": "instructions", "steps": [ { "step1": "Redirect to PalWallet payment page.", "step2": "Scan the QR code or pay via your crypto wallet." } ] } ], "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861", "ewallets": [ { "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861", "amount": 14.47, "percent": 100, "refunded_amount": 0 } ], "payment_method_options": {}, "payment_method_type": "at_crypto_ewallet", "payment_method_type_category": "ewallet", "fx_rate": 1, "merchant_requested_currency": null, "merchant_requested_amount": null, "fixed_side": "", "payment_fees": null, "invoice": "", "escrow": null, "group_payment": "", "cancel_reason": null, "initiation_type": "customer_present", "mid": "", "next_action": "pending_confirmation", "error_code": "", "remitter_information": {}, "save_payment_method": false, "merchant_advice_code": null, "merchant_advice_message": null, "transaction_link_id": null } }
Note the following fields:
Field
Description
merchant_requested_currencyThe cryptocurrency the customer pays with. At this stage, the currency is not yet known.
merchant_requested_amountThe amount of cryptocurrency - not yet known.
Complete the payment with the following settings:
token- The ID of the payment.
param1- The name of the cryptocurrency, for example, USDC.
param2- The amount of the cryptocurrency.
Request
curl -X post 'https://sandboxapi.rapyd.net/v1/payments/completePayment' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -H 'idempotency: your-idempotency-parameter-here' \ -H 'salt: your-random-string-here' \ -H 'signature: your-calculated-signature-here' \ -H 'timestamp: your-unix-timestamp-here' \ --data-raw '{ "token": "payment_890472b66f16b046e962706e1ea343b2", "param1": "USDC", "param2": "14.47" }'
The platform returns the following response and the PAYMENT_COMPLETED webhook.
Response
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "8ce1b4ae-1c76-4fb6-8aca-9c51aecd7e6b" }, "data": { "id": "payment_f3eba0aaa8cb4b8ceff75dc02d0eb725", "amount": 14.48, "original_amount": 14.48, "is_partial": false, "currency_code": "USD", "country_code": "AT", "status": "CLO", "description": "", "merchant_reference_id": "", "customer_token": "cus_4e25112ac20e144ad073a614dc46934b", "payment_method": "other_d87e86e9e42116cbfc951fe805fdfb53", "payment_method_data": { "id": "other_d87e86e9e42116cbfc951fe805fdfb53", "type": "at_crypto_ewallet", "category": "ewallet", "metadata": {}, "image": "", "webhook_url": "", "supporting_documentation": "", "next_action": "not_applicable", "bic_swift": "", "account_last4": "" }, "auth_code": null, "expiration": 1767881804, "captured": true, "refunded": false, "refunded_amount": 0, "receipt_email": "", "redirect_url": "", "complete_payment_url": "https://complete.rapyd.net", "error_payment_url": "https://error.rapyd.net", "receipt_number": "", "flow_type": "", "address": null, "statement_descriptor": "Doc Team", "transaction_id": "", "created_at": 1767622604, "metadata": {}, "failure_code": "", "failure_message": "", "paid": true, "paid_at": 1767622753, "dispute": null, "refunds": null, "order": null, "outcome": null, "visual_codes": {}, "textual_codes": { "code": "paygw_a58c403afc953e5b333d313b96a5a716" }, "instructions": [ { "name": "instructions", "steps": [ { "step1": "Redirect to PalWallet payment page.", "step2": "Scan the QR code or pay via your crypto wallet." } ] } ], "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861", "ewallets": [ { "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861", "amount": 14.48, "percent": 100, "refunded_amount": 0 } ], "payment_method_options": {}, "payment_method_type": "at_crypto_ewallet", "payment_method_type_category": "ewallet", "fx_rate": 1, "merchant_requested_currency": null, "merchant_requested_amount": null, "fixed_side": "", "payment_fees": null, "invoice": "", "escrow": null, "group_payment": "", "cancel_reason": null, "initiation_type": "customer_present", "mid": "", "next_action": "not_applicable", "error_code": "", "remitter_information": {}, "save_payment_method": false, "merchant_advice_code": null, "merchant_advice_message": null, "transaction_link_id": null } }
Note the following fields:
Field
Description
merchant_requested_currencyThe cryptocurrency the customer pays with. In production, the currency supported by the payment method appears here.
merchant_requested_amountThe amount of cryptocurrency. In production, the actual amount paid by the customer appears here.
statusThe status has changed to CLO (closed).