Skip to main content

How to do a transaction in APS

Transaction in APS is a 2 step process:

  1. Creating a transaction:
curl --location --globoff 'https://api.payhub.cm.com/v1/accounts/{{logical-account-id}}/transactions' \
--header 'X-CM-SSO-ACCOUNTGUID: {{your-account-guid}}' \
--header 'Content-Type: application/json' \
--data '{
"additionalData": {
"language": "en",
"email":"{{email-id}}"
},
"amount": {
"currency": "USD",
"amount": "1999"
},
"connectionId": "{{connection-id}}",
"description": "Random Product for Testing",
"allowedMethods": [
"VISA"
],
"expiresAtUtc": "2025-05-05T08:39:55.719Z",
"reference": "PROTEST-000001",
"returnUrlSuccess": "https://www.yourwebsite.com/transaction-success",
"returnUrlFailure": "https://www.yourwebsite.com/transaction-failure",
"webhook": "https://www.yourwebsite.com/webhook"
}'
  • For Amazon Payment Service, language and email are required field to create any transaction.
  • APS supports en and ar languages. If not given, it takes en by default.
  • The customer’s APS account should have all the currencies enabled in which they are going to do the transactions.
  • allowedMethods has the list of card types allowed, make sure all those cards are enabled in the APS. If allowedMethods is an empty list ([]), we are assuming all the cards are accepted.
  • reference has to be unique for every transaction. This will used for refund also.

It gives the following response:

{
"id": "092dbf38-7517-4336-91d0-e5d0d45ec63d",
"accountId": "{{your-logical-account-id}}",
"amount": {
"currency": "USD",
"amount": "1999.00"
},
"status": "Created",
"type": "Payment",
"reference": "PROTEST-000001",
"allowedMethods": [],
"providerReference": "",
"providerData": {},
"description": "Random Product for Testing",
"connectionId": "{{your-amazon-connection-id}}",
"relatedTransactionId": null,
"expiresAtUtc": "2025-05-05T08:39:55.719Z",
"additionalData": {},
"redirectUrl": "https://payhub.cm.com/l/W10kiPW2ZtrtfvRONTqJCu",
"returnUrlSuccess": "https://www.yourwebsite.com/transaction-success",
"returnUrlFailure": "https://www.yourwebsite.com/transaction-failure"
}
  1. Once you click on the redirect URL in the response it will take you to the Amazon Payment Service payment window:

    Amazon Payment Service payment window

    Successful transaction looks like this:

    Successful APS transaction result screen

After the transaction gets completed it will redirect you to either returnUrlSuccess or returnUrlFailure based on the status of your transaction.

You can find the test cards here: https://paymentservices.amazon.com/docs/EN/12.html

Use this account for prod testing:

https://www.cm.com/en-gb/app/marketplace/05e1ee3f-301d-4648-a165-df012dad4902/payment/f1a122e6-a38e-451e-831a-beed7a38aeff