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.

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.

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"
      }
    }'
  
Last modified January 31, 2022