Skip to content

How a payment works

sequenceDiagram
    participant S as Your server
    participant A as Anypaytree API
    participant C as Customer
    S->>A: POST /api/v1/payments
    A-->>S: paymentUrl
    S->>C: redirect to paymentUrl
    C->>A: pays on the payment page
    A->>S: callback payment.paid
    S-->>A: 2xx
    A->>C: back to your successUrl
  1. Create a payment for the order. You get a paymentUrl.
  2. Send the customer to paymentUrl: a redirect or a link that opens it as its own page. Not an iframe: the card form and 3-D Secure run on the payment provider's domain.
  3. The customer pays. If a card is declined, they can try another one on the same page.
  4. We send a callback payment.paid to your callbackUrl. Check its signature and amount, then fulfil the order.
  5. The customer comes back to your successUrl (or cancelUrl), with orderId and status (paid or cancelled) added to the URL:

    https://shop.example.com/thanks?orderId=4f0c…&status=paid
    

    Without these URLs the customer stays on our page, which shows the result.

The customer's return is not a payment confirmation

Fulfil an order only on the payment.paid callback, or after getting the order and seeing status: paid.

An order nobody pays sends nothing. Close such orders on your side after your own timeout, once getting the order shows it unpaid.