Alternate Payment with Token
Once you have received the APM single-use token from Paysafe Checkout, you can use it to make a payment using the Alternate Payments API.
If your transactions are in multiple currencies you need to consider how you will handle the multiple merchant accounts involved and select the correct one to use when taking payment.
- for Interac: CAD only
The payment endpoint uses the server-to-server API key. Do not use the Alternate Payments API from the client's web browser as this will expose this key.
Call the following Alternate Payments API endpoint from your server to make the payment:
POST /alternatepayments/v1/accounts/account_id/payments
curl -X POST https://api.test.paysafe.com/alternatepayments/v1/accounts/1001199750/payments \
-u test_username:B-qa2-0-59564dfa-0-302c021426a55dde98dc2a052cccc1ddc8daa776a7a4fe2e0214080388fded986767abc445e58af123c01003cb8b \
-H 'Content-Type: application/json' \
-d ' {
"merchantRefNum": "1537363109",
"amount": 5000,
"settleWithAuth": false,
"returnLinks": [{
"rel": "default",
"href": "https://mysite.com/return"
}],
"paymentType": "INTERAC",
"paymentToken": "AP97U2uORetNQZaO"
} '
Prior to trying the example, you should:
- Replace the account number (1001199750) in the URL with the Test account number you received from Paysafe for the APM provider.
- Replace the API key user name and password (after the -u) with the Test API key you received from Paysafe.
- Replace the payment type (INTERAC), if necessary, with the type of payment you are making; at present only Interac is supported.
- Replace the payment token (AP97U2uORetNQZaO) with the Test token you obtained in the resultCallback method (in the case where you have set the environment parameter to TEST).
The APM Payment request contains the following parameters.
Element | Type | Description |
---|---|---|
amount | integer max=999999999 | This is the amount of the request, in minor units. |
merchantRefNum | string length<=255 | This is the merchant reference number created by the merchant and submitted as part of the request. |
settleWithAuth | boolean | This indicates whether the request is an Authorization only (no Settlement). This must be set to false. |
paymentType | enum | This specifies the type of payment. This must be set to the payment type from the supported providers list, i.e., INTERAC. |
paymentToken | string | This is the payment token returned by Paysafe Checkout for the APM request. |
{
"id": "0643c070-15c0-4218-8af1-1dc82b4f93fc",
"merchantRefNum": "1537363109",
"amount": 5000,
"currencyCode": "CAD",
"paymentType": "INTERAC",
"settleWithAuth": false,
"availableToSettle": 5000,
"availableToRefund": 0,
"txnTime": "2018-09-19T13:17:35Z",
"status": "COMPLETED",
"gatewayResponse": {
"id": "d3188d9c-f81a-4958-8505-03764bf577f2"
"processor": "INTERAC"
},
"links": [{
"rel": "self",
"href": "https://api.test.paysafe.com/alternatepayments/v1/accounts/1001199750/payments/0643c070-15c0-4218-8af1-1dc82b4f93fc"
}]
}
The APM Payment response contains the following additional parameters.
Element | Type | Description |
---|---|---|
id | string | This is the unique ID for this APM payment. |
currencyCode | string | This is the currency of the payment. Defaults to the account currency. |
availableToSettle | number | This is the amount remaining to settle, in minor units. |
availableToRefund | number | This is the amount remaining to refund, in minor units. |
txnTime | UTC formatted date | This is the date and time the transaction was processed. E.g., 2017-12-11T16:33:49Z |
status | enum | This is the status of the request. |
gatewayResponse | object | These are the details returned from the external gateway. |
links | array of link objects | This is an array of links related to the resource. |