For any question, we are one click away

Contact us

Direct integration

In this scheme, an online store has its own payment page to collect card data natively through its web site.

First, you should subscribe to the following webhooks (see Webhooks for details):

sequenceDiagram participant C as Customer participant OS as Online store participant PG as Payment Gateway autonumber activate C C ->> OS: Initiate payment activate OS OS -->> C: Open payment page C ->> OS: Enter card data OS ->> PG: Create Payment
("/payments" request) activate PG PG -->> PG: Create Payment PG -->> OS: "payment.created" webhook OS ->> PG: HTTP Code = 200 PG -->> OS: Response rect rgb(191, 223, 255) alt 3 DS is required OS -->> C: Redirect to ACS for 3DS verification C ->> PG: Confirm Payment end end PG -->> PG: Process payment PG -->> OS: "payment.succeeded" webhook OS ->> PG: HTTP Code = 200 rect rgb(191, 223, 255) opt Retrieving Payment status OS ->> PG: Retrieve a Payment
("/payments/{id}" request) PG -->> OS: Payment with "status=succeeded" end end deactivate OS deactivate PG
  1. A customer selects a product in the online store, and then clicks Buy.
  2. The online store server receives a purchase request and opens a payment page.
  3. The customer enters their card details on the online store payment page.
  4. The online store server sends /payments request to the Payment Gateway to create a Payment (see API Reference for details). The request should contain amount parameter (the amount of the payment in minor currency units, e.g. in cents) and currency parameter (three-letter code of the payment currency, according to ISO 4217). Additionally, you should pass either paymentMethod block with card data or storedPaymentMethodId parameter (the identifier of a Stored Payment Method).

    Request example:

    curl -X POST "https://dev.bpcbt.com/api2/payments" \
    -H "X-Api-Key: 6HUXQFbeomV1zf5i8cgm5W8KfncENVEa5uh8RngB" \
    -H "X-Version: 2023-10-31" \
    -H "Content-Type: application/json" \
    -d '{
    "amount": 70000,
    "captureMethod": "automatic",
    "currency": "eur",
    "customerDetails": {
        "address": {
        "city": "Test city",
        "country": "CY",
        "line1": "Test address1",
        "line2": "Test address2",
        "postalCode": "Test postal code",
        "state": "Test state"
        },
        "email": "test@example.com",
        "name": "TEST CARDHOLDER",
        "phone": "+449998887766"
    },
      "description": "Some description",
    "metadata": {},
    "paymentMethod": {
        "type": "card",
        "card": {
        "cvc": "123",
        "expiryMonth": 12,
        "expiryYear": 2024,
        "holderName": "TEST CARDHOLDER",
        "number": "4444555511113333"
        }
    },
    "paymentMethodOptions": {
        "card": {
        "threeDSecureMode": "automatic",
        "verify": false
        }
    },
    "returnUrl": "https://mybestmerchantreturnurl.com/"
    }'
    
  5. Payment Gateway creates a Payment.

  6. Payment Gateway sends payment.created webhook to the online store.

  7. Online store server sends HTTP Code = 200 in response.

  8. Payment Gateway sends the response for the /payments request.

    • If the response contains the nextAction block, this means that 3-D Secure is required. Steps 9 and 10 are performed.
    • If the response does not contain the nextAction block, 3-D Secure is not required. In this case, Steps 9 and 10 are omitted, go to Step 11.
    • If the payment was successfull, the response contains status=succeeded.

    Response example:

    {
    "id": "p_HbtjsyTuig5SWYufjsFeTNAX3WisQFUSvbroA1C48Y5XN8Pstcdw",
    "amount": 70000,
    "amountCapturable": 0,
    "amountReceived": 70000,
    "captureMethod": "automatic",
    "created": "2024-03-31T23:40:24Z",
    "currency": "eur",
    "customerDetails": {
        "address": {
            "city": "Test city",
            "country": "CY",
            "line1": "Test address1",
            "line2": "Test address2",
            "postalCode": "Test postal code",
            "state": "Test state"
        },
        "email": "test@example.com",
        "name": "TEST CARDHOLDER",
        "phone": "+449998887766"
    },
    "description": "Some description",
    "metadata": {},
    "paymentMethod": {
        "card": {
            "expiryMonth": 12,
            "expiryYear": 2024,
            "holderName": "TEST CARDHOLDER",
            "maskedNumber": "444455**3333"
        },
        "type": "card"
    },
    "paymentMethodOptions": {
        "card": {
            "threeDSecureMode": "automatic",
            "verify": false
        }
    },
    "returnUrl": "https://mybestmerchantreturnurl.com/",
    "status": "succeeded"
    }
    
  9. Online store redirects the customer to the URL for 3-D Secure verification.

  10. The customer confirms payment.

  11. Payment Gateway processes payment.

  12. Payment Gateway sends payment.succeeded webhook to the online store.

  13. Online store server sends HTTP Code = 200 in response.

  14. Online store sends /payments/{id} request to retrieve a Payment.

  15. In response, Payment Gateway sends the Payment object with status=succeeded.

Categories:
eCommerce API V2
Categories
Search results