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": "USD",
            "amount": "10",
            "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",
            "orderId": "OR-2510010937441887629",
            "payUrl": "https://sandbox-pay-widget.transfi.com/pay?paytoken=123-123-123-123-123123"
        }
    }
  • 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": "USD",
            "amount": "10",
            "paymentType": "bank_transfer",
            "paymentCode": "swift",
            "additionalPaymentDetails": {
                "phoneCode": "+91",
                "phone": "12341234123",
                "street": "abcd",
                "city": "abcd",
                "state": "abcd",
                "documentType": "passport",
                "documentNumber": "abcde",
                "dob": "01-01-2000"
            }
        },
        "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",
            "orderId": "OR-2510031348048279781",
            "amount": 10,
            "payUrl": "https://sandbox-pay-widget.transfi.com/pay?paytoken=123123-123-123-123-123123",
            "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"
                }
            },
    
        }
    }

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",
            "walletAddress": "0x12312312312390ABCDEF1234567890ABCDEF",
            "amount": "119.282956035"
        },
    
        "destination": {
            "currency": "USDC",
            "walletAddress": "0x123123123123ASDFASDFSDF234567890ABCDEF"
        }
    }'
    {
        "status": "success",
        "data": {
            "flow": "CRYPTO_EXTERNAL_SWAP",
            "orderId": "OR-2510010958112819394",
            "amount": 119.282956,
            "walletAddress": "dummy_0x63d12341234123442fwrwwr"
        }
    }

  • 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",
            "walletAddress": "0x12312312312390ABCDEF1234567890ABCDEF",
            "amount": "119.282956035"
        },
    
        "destination": {
            "currency": "USDC",
            "walletAddress": "0x123123123123ASDFASDFSDF234567890ABCDEF"
        }
    }'
    {
        "status": "success",
        "data": {
            "flow": "CRYPTO_EXTERNAL_SWAP",
            "orderId": "OR-2510010958112819394",
            "amount": 119.282956,
            "walletAddress": "dummy_0x63d12341234123442fwrwwr"
        }
    }

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.