Introduction to Payments


Create and authorize payment

  1. Create a new payment
  2. Authorize payment using a link
  3. Check payment status

1. Create a new payment

POST /payments Create payment

First step is to create a payment entity in CoolPay

Selected parameters. See more in the API documentation.

ParameterDescriptionParameter typeData typeRequired?
order_idUnique order numberformstringtrue
currencyCurrencyformstringtrue

Example request:

1
2
3
4
5
6
curl -u ':APIKEY \
     -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X POST \ -d '{"order_id":"1001","currency":"dkk"}' \ https://api.coolpay.com/payments

Example response (snippet):

1
2
3
4
5
6
7
8
9
{
  "id":99685196,
  "merchant_id":1234,
  "order_id":"1001",
  "type":"Payment",
  "currency":"DKK",
  "state":"initial"
  ...
}
PUT /payments/{id}/link Create or update a card link

Next step is to authorize the payment.

The recommended way is to request the CoolPay API for a payment link, where your customer can fill in their card information.

Selected parameters. See more in the API documentation.

ParameterDescriptionParameter typeData typeRequired?
idTransaction idpathintegertrue
amountAmount to authorizeformintegertrue

Example request:

1
2
3
4
5
6
curl -u ':APIKEY' \
     -H 'content-type:application/json' \
     -H 'Accept-Version:v10' \
     -X PUT \
     -d '{"amount":1000}' \
     https://api.coolpay.com/payments/99685196/link

Example response:

1
2
3
{
  "url":"https://payment.coolpay.com/payments/b4674ca58c6c8a2afeea105fb1b5ca22293a1dc17fa852afa0495010999c2d00"
}

When your customer has filled in the card information using the link, the payment is now authorized.

No funds are withdrawn from your customer yet.

If you are selling a digital products, you can include "auto_capture":"true" in the payment link request, to capture the payment automatically after the authorize.

If you are selling a physical product, you can capture the payment using POST /payments/{id}/capture when you are ready to ship the product.

3. Check payment status

GET /payments/{id} Get payment

Last step is to check the status of the payment.

This could be on a continue-url, where you render a “Payment successful”-message when the payment is complete.

Example request:

1
2
3
4
5
curl -u ':APIKEY' \
     -H 'content-type:application/json' \
     -H 'Accept-Version:v10' \
     -X GET \
     https://api.coolpay.com/payments/99685196

Example response (snippet):

1
2
3
4
5
6
7
8
9
{
  "id":99685196,
  "merchant_id":1234,
  "order_id":"1001",
  "accepted":true,
  "type":"Payment",
  "state":"new"
  ...
}

Opret bruger