Creating a Swap Transfer

Creating Fiat Swap Transfer(API link)

  • Minimal payload:
    curl --location 'https://sandbox-api.transfi.com/v3/orders' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic ==' \
    --header 'mid: SAH1N3_NA_NA' \
    --data '{
        "userId": "UX-2123123123123",
        "orderType": "swap",
        "purposeCode": "company_expenses",
        "source": {
            "currency": "AED",
            "amount": "100",
            "paymentType": "bank_transfer",
        },
        "destination": {
            "currency": "EUR",
            "paymentType": "bank_transfer",
            "paymentCode": "sepa_bank",
            "additionalPaymentDetails": {
                "iban": "BE6123123123",
                "bic": "DEU123123XX",
                "street": "abcd street",
                "city": "abcd",
                "postalCode": "123123"
            }
        }
    }'
    {
        "status": "success",
        "data": {
            "flow": "FIAT_EXTERNAL_SWAP",
            "flowType": "user-self",
            "orderId": "OR-260824113614797920871545562",
            "feeData": {
                "depositAmount": 100,
                "withdrawAmount": 22.17,
                "exchangeRate": 0.2334036820966644,
                "totalFee": 5
            },
            "payUrl": "https://pay-widget.transfi.com//pay?paytoken=077228d0-163b-4c10-9e2f-dc474975a75d",
            "quoteHistory": {
                "refreshCount": 0,
                "orderCreationQuote": {
                    "isRefreshed": false,
                    "usedQuotes": {
                        "sourceCurrency": "AED",
                        "sourceAmount": 100,
                        "sourceAmountInUsd": 27.23,
                        "sourceCurrencyType": "fiat",
                        "destinationCurrency": "EUR",
                        "destinationAmount": 22.173349799183118,
                        "destinationAmountInUsd": 25.87,
                        "destinationCurrencyType": "fiat",
                        "conversionRate": 0.2334036820966644,
                        "minLimit": 20,
                        "maxLimit": 367250,
                        "direction": "forward",
                        "processingFee": 5,
                        "processingFeeRate": 0.05,
                        "customerFee": 0,
                        "customerFeeRate": 0,
                        "rrFeeRate": 0,
                        "discount": 0,
                        "discountRate": 0,
                        "additionalFee": 0,
                        "fixedFee": {
                            "totalFixedFees": 0,
                            "totalFixedTfFees": 0,
                            "totalFixedCxFees": 0,
                            "fixedFeesCurrency": "AED",
                            "fixedFeeDetails": {
                                "baseFeeFixedRate": 0,
                                "tfFeeFixedRate": 0,
                                "cxFeeFixedRate": 0,
                                "currency": ""
                            }
                        },
                        "totalFee": 5,
                        "feeMode": "percentage",
                        "rateType": "live",
                        "quoteId": "QUOTE-35f2b500-d117-44b3-9652-8b90a04649ad"
                    }
                }
            }
        },
        "traceId": "$(uuidgen)"
    }
  • Full payload:
    curl --location 'https://sandbox-api.transfi.com/v3/orders' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic ==' \
    --header 'mid: SAH1N3_NA_NA' \
    --data '{
        "userId": "UX-2123123123123",
        "orderType": "swap",
        "purposeCode": "company_expenses",
        "purposeCodeReason": "Personal payment",
        "successRedirectUrl": "https://yourapp.com/success",
        "failureRedirectUrl": "https://yourapp.com/failure",
        "headlessMode": true,
        "sourceUrl": "https://yourapp.com/source"
        "partnerId": "1234567890",
        "customerMetaData": {
            "customerId": "1234567890",
            "customerName": "John Doe",
            "customerEmail": "[email protected]"
        },
        "deviceDetails": {
            "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
            "ipInfo": {
              "ip": "123.123.123.123",
              "countryCode3": "IND"
            }
        },  
        "source": {
            "currency": "AED",
            "amount": "100",
            "paymentType": "bank_transfer",
            "paymentCode": "bank_transfer",
            "additionalPaymentDetails": {
                "phoneCode": "+91",
                "phone": "12341234123",
                "street": "abcd",
                "city": "abcd",
                "state": "abcd"
            }
        },
        "destination": {
            "currency": "EUR",
            "paymentType": "bank_transfer",
            "paymentCode": "sepa_bank",
            "additionalPaymentDetails": {
                "iban": "BE6123123123",
                "bic": "DEU123123XX",
                "street": "abcd street",
                "city": "abcd",
                "postalCode": "123123"
            }
        },
         "customization": {
            "locale": "id"
         },
    }'
    {
        "status": "success",
        "data": {
            "flow": "FIAT_EXTERNAL_SWAP",
            "flowType": "user-self",
            "orderId": "OR-260824113614797920871545562",
            "feeData": {
                "depositAmount": 100,
                "withdrawAmount": 22.17,
                "exchangeRate": 0.2334036820966644,
                "totalFee": 5
            },
            "payUrl": "https://pay-widget.transfi.com//pay?paytoken=077228d0-163b-4c10-9e2f-dc474975a75d",
            "paymentsData": {
                "accountDetails": {
                    "beneficiaryName": "John d",
                    "beneficiaryBankName": "JP Morgan Chase",
                    "bankAddress": "383 MADISON AVENUE, NEW YORK, NY, 10179",
                    "beneficiaryBankAccountNumber": "1234123123123",
                    "beneficiaryAccountType": "checking",
                    "swiftCode": "ABCDABCD",
                    "beneficiaryAddress": "abc,abc,asd,IN"
                },
                "type": "bankTransfer",
                "extra": {
                    "accountId": "eab6881e-123-123-123-123123"
                }
            },
            "quoteHistory": {
                "refreshCount": 0,
                "orderCreationQuote": {
                    "isRefreshed": false,
                    "usedQuotes": {
                        "sourceCurrency": "AED",
                        "sourceAmount": 100,
                        "sourceAmountInUsd": 27.23,
                        "sourceCurrencyType": "fiat",
                        "destinationCurrency": "EUR",
                        "destinationAmount": 22.173349799183118,
                        "destinationAmountInUsd": 25.87,
                        "destinationCurrencyType": "fiat",
                        "conversionRate": 0.2334036820966644,
                        "minLimit": 20,
                        "maxLimit": 367250,
                        "direction": "forward",
                        "processingFee": 5,
                        "processingFeeRate": 0.05,
                        "customerFee": 0,
                        "customerFeeRate": 0,
                        "rrFeeRate": 0,
                        "discount": 0,
                        "discountRate": 0,
                        "additionalFee": 0,
                        "fixedFee": {
                            "totalFixedFees": 0,
                            "totalFixedTfFees": 0,
                            "totalFixedCxFees": 0,
                            "fixedFeesCurrency": "AED",
                            "fixedFeeDetails": {
                                "baseFeeFixedRate": 0,
                                "tfFeeFixedRate": 0,
                                "cxFeeFixedRate": 0,
                                "currency": ""
                            }
                        },
                        "totalFee": 5,
                        "feeMode": "percentage",
                        "rateType": "live",
                        "quoteId": "QUOTE-35f2b500-d117-44b3-9652-8b90a04649ad"
                    }
                }
            }
        },
        "traceId": "$(uuidgen)"
    }

In the successful response from the api-call you will get the paymentUrl, to which you need to redirect your user to complete the payment. Once the user completes the payment, we will initiate the fait transfer to the user.


Creating Crypto Swap Transfer(API link)

  • Minimal payload:
    curl --location 'https://sandbox-api.transfi.com/v3/orders' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic ==' \
    --header 'mid: SAH1N3_NA_NA' \
    --data '{
        "userId": "UX-2123123123123",
        "orderType": "swap",
        "purposeCode": "company_expenses",
        "source": {
            "currency": "USDTPOLYGON",
            "amount": "42"
        },
        "destination": {
            "currency": "USDCSOL",
            "walletAddress": "62zUzmtENeUX2KgboHUyVB71g5HQ4tv6arMVsESqagL5"
        }
    }'
    {
        "status": "success",
        "data": {
            "flow": "CRYPTO_EXTERNAL_SWAP",
            "flowType": "user-self",
            "orderId": "OR-260824112622050904850844331",
            "payUrl": "https://pay-widget.transfi.com//crypto-pay?paytoken=175e7d8f-69cd-4e2e-b93b-9af3f5dc118e",
            "amount": 42,
            "cryptoCurrency": "USDT",
            "cryptoNetwork": "polygon",
            "walletAddress": "0x5c338eAB5D41332f8c719021Ac24cdfF5583d457",
            "feeData": {
                "depositAmount": 42,
                "withdrawAmount": 39.88783,
                "exchangeRate": 0.9999103871091857,
                "totalFee": 2.108595
            },
            "quoteHistory": {
                "refreshCount": 0,
                "orderCreationQuote": {
                    "isRefreshed": false,
                    "usedQuotes": {
                        "sourceCurrency": "USDTPOLYGON",
                        "sourceAmount": 42,
                        "sourceAmountInUsd": 41.99,
                        "sourceCurrencyType": "crypto",
                        "destinationCurrency": "USDCSOL",
                        "destinationAmountInUsd": 39.88,
                        "destinationCurrencyType": "crypto",
                        "conversionRate": 0.9999103871091857,
                        "processingFee": 2.1,
                        "processingFeeRate": 0.05,
                        "customerFee": 0,
                        "customerFeeRate": 0,
                        "discount": 0,
                        "discountRate": 0,
                        "additionalFee": 0,
                        "additionalFeeRate": 0,
                        "fixedFee": {},
                        "totalFee": 2.108595,
                        "feeMode": "percentage",
                        "rateType": "live",
                        "quoteId": "QUOTE-f649a1f9-1457-41e5-af88-2430b821ab11",
                        "networkFee": 0.008595
                    }
                }
            }
        },
        "traceId": "d38f2060-4d2f-4e20-9e36-e75b650caa80"
    }

  • Full payload:
    curl --location 'https://sandbox-api.transfi.com/v3/orders' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic ==' \
    --header 'mid: SAH1N3_NA_NA' \
    --data '{
        "userId": "UX-2123123123123",
        "orderType": "swap",
        "purposeCode": "company_expenses",
        "purposeCodeReason": "Personal payment",
        "sourceUrl": "https://yourapp.com/source",
        "successRedirectUrl": "https://yourapp.com/success",
        "failureRedirectUrl": "https://yourapp.com/failure",
        "partnerId": "1234567890",
        "customerMetaData": {
            "customerId": "1234567890",
            "customerName": "John Doe",
            "customerEmail": "[email protected]"
        },
        "deviceDetails": {
            "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
            "ipInfo": {
              "ip": "123.123.123.123",
              "countryCode3": "IND"
            }
        }, 
        "source": {
            "currency": "USDTPOLYGON",
            "amount": "42"
        },
    
        "destination": {
            "currency": "USDCSOL",
            "walletAddress": "62zUzmtENeUX2KgboHUyVB71g5HQ4tv6arMVsESqagL5"
        },
         "customization": {
            "locale": "id"
         },
    }'
    {
        "status": "success",
        "data": {
            "flow": "CRYPTO_EXTERNAL_SWAP",
            "flowType": "user-self",
            "orderId": "OR-260824112622050904850844331",
            "payUrl": "https://pay-widget.transfi.com//crypto-pay?paytoken=175e7d8f-69cd-4e2e-b93b-9af3f5dc118e",
            "amount": 42,
            "cryptoCurrency": "USDT",
            "cryptoNetwork": "polygon",
            "walletAddress": "0x5c338eAB5D41332f8c719021Ac24cdfF5583d457",
            "feeData": {
                "depositAmount": 42,
                "withdrawAmount": 39.88783,
                "exchangeRate": 0.9999103871091857,
                "totalFee": 2.108595
            },
            "quoteHistory": {
                "refreshCount": 0,
                "orderCreationQuote": {
                    "isRefreshed": false,
                    "usedQuotes": {
                        "sourceCurrency": "USDTPOLYGON",
                        "sourceAmount": 42,
                        "sourceAmountInUsd": 41.99,
                        "sourceCurrencyType": "crypto",
                        "destinationCurrency": "USDCSOL",
                        "destinationAmountInUsd": 39.88,
                        "destinationCurrencyType": "crypto",
                        "conversionRate": 0.9999103871091857,
                        "processingFee": 2.1,
                        "processingFeeRate": 0.05,
                        "customerFee": 0,
                        "customerFeeRate": 0,
                        "discount": 0,
                        "discountRate": 0,
                        "additionalFee": 0,
                        "additionalFeeRate": 0,
                        "fixedFee": {},
                        "totalFee": 2.108595,
                        "feeMode": "percentage",
                        "rateType": "live",
                        "quoteId": "QUOTE-f649a1f9-1457-41e5-af88-2430b821ab11",
                        "networkFee": 0.008595
                    }
                }
            }
        },
        "traceId": "d38f2060-4d2f-4e20-9e36-e75b650caa80"
    }

In response you will receive walletAddress with amount to be transferred. Once the user transfers the crypto to that wallet, we will initiate the crypto transfer.


Note: Amount to be transferred can be passed in either source or destination.

Examples:

{
    "source": {
        "currency": "USD",
        "amount": "100"
    },
    "destination": {
        "currency": "EUR"
    }
}
{
    "source": {
        "currency": "USD"
    },
    "destination": {
        "currency": "EUR",
        "amount": "100"
    }
}
  1. Amount is sent in source object: In this case, user needs to do a payin of 100 USD. Amount of EUR that will be sent to user will be calculated (~81 EUR). (This is usually preferred)
  2. Amount is sent in destination object: In this case, amount of USD that user needs to send will be calculated (~81 USDC) and 100 EUR will be sent to user.

Did this page help you?