Charge
A charge is a one-step payment flow that combines the Authorize-Capture steps into a single transaction. Funds are transferred from your customer’s account to your acquiring bank once the payment has been authorized.
Let’s proceed to create a charge. If you imported our Postman Collection, you can follow-along with the examples by invoking the requests in the Charge folder.
Provider Support
The requests described below are not necessarily supported by all providers. To see which requests are supported by a specific provider, refer to the relevant Provider Integration Guide in the menu on the left.Step 1: Create the Payment
As you may recall, the first step in a payment flow is always to create a payment using the Create Payment API.
Payment Object
The Create Payment API creates a payment object. The payment object provides a single reference to all the transactions that make up a payment. For more information, see Understanding the Payment Object.Create the payment as follows:
var request = new XMLHttpRequest();
request.open('POST', 'https://api.paymentsos.com/payments');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('api-version', '1.3.0');
request.setRequestHeader('x-payments-os-env', 'test');
request.setRequestHeader('app-id', 'com.zooz.docapp');
request.setRequestHeader('private-key', 'bede7ee5-eaaq-4c9a-bc1f-617ba28256ae');
request.setRequestHeader('idempotency-key', 'cust-34532-trans-001356-p');
var body = {
'amount': 34800,
'currency': 'EUR',
'statement_soft_descriptor': 'Oil lamp'};
request.send(JSON.stringify(body));
curl --compressed -X POST \
https://api.paymentsos.com/payments \
-H 'Content-Type: application/json' \
-H 'api-version: 1.3.0' \
-H 'x-payments-os-env: test' \
-H 'app-id: com.zooz.docapp' \
-H 'private-key: bede7ee5-eaaq-4c9a-bc1f-617ba28256ae' \
-H 'idempotency-key: cust-34532-trans-001356-p' \
-d '{
"amount": 31602077,
"currency": "EUR",
"statement_soft_descriptor": "Oil lamp"
}'
Step 2: Create Charge
The next step is to create the charge. This will transfer the funds to your bank account. Here’s an example:
var request = new XMLHttpRequest();
request.open('POST', 'https://api.paymentsos.com/payments/{payment_id}/charges');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('api-version', '1.3.0');
request.setRequestHeader('x-payments-os-env', 'test');
request.setRequestHeader('app-id', 'com.zooz.docapp');
request.setRequestHeader('private-key', '0047c4ef-f658-4e6d-a040-5882e2285f34');
request.setRequestHeader('idempotency-key', 'cust-34532-trans-001356-c');
var body = {
'payment_method': {
'type': 'tokenized',
'token': 'f2b9357d-25b1-435b-87c2-b8c00fda6faf'}};
request.send(JSON.stringify(body));
curl --compressed -X POST \
https://api.paymentsos.com/payments/{payment_id}/charges \
-H 'Content-Type: application/json' \
-H 'api-version: 1.3.0' \
-H 'x-payments-os-env: test' \
-H 'app-id: com.zooz.docapp' \
-H 'private-key: bede7ee5-eaaq-4c9a-bc1f-617ba28256ae' \
-H 'idempotency-key: cust-34532-trans-001356-p' \
-d '{
"payment_method": {
"type": "tokenized",
"token": "f2b9357d-25b1-435b-87c2-b8c00fda6faf"
}
}'
Notes
- If you are SAQ D compliant, you can pass full credit card details without using our tokenization service. To do so, you must pass a payment method
type
ofuntokenized
and asource_type
ofcredit_card
in the request body. For the complete body structure, see the Create Authorization request in the Payments API reference. - If you use an external MPI (merchant plug-in) to authorize a card using 3D Secure, then you can pass the 3DS data returned from the MPI in the
three_d_secure_attributes.external
object of a Create Authorization or Create Charge request. This requires that you configure a route rule to direct the request to a provider that can process data received from an external 3DS service. For more information, see Routing Transactions to a Provider Supporting External 3DS.
Last modified January 31, 2022