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
- Create a payment for the order. You get a
paymentUrl. - 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. - The customer pays. If a card is declined, they can try another one on the same page.
- We send a callback
payment.paidto yourcallbackUrl. Check its signature and amount, then fulfil the order. -
The customer comes back to your
successUrl(orcancelUrl), withorderIdandstatus(paidorcancelled) added to the URL:https://shop.example.com/thanks?orderId=4f0c…&status=paidWithout 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.