Accept APMs from your server
Create an alternative payment method charge with the API, redirect the customer to approve it, and confirm the outcome with webhooks.
From your server, an APM payment takes three steps. You create the charge with
POST /v1/charges, create a
linked authentication session to get the redirect URL, and redirect the
customer to the method to approve the payment. The examples use Skrill, and the
same steps apply to any method whose page lists server-to-server.
Requirements
Before you start, make sure you have:
- The method enabled on your account and turned on in the Pay.com dashboard.
- Your API keys.
- A webhook endpoint that receives charge events. See Webhooks.
Accept an APM payment
Each request goes to https://api.sandbox.pay.com/v1 in the sandbox and
https://api.pay.com/v1 live.
- 1
Create the charge
Send
POST /v1/chargeswithsource_data.typeset to the method's type. Amounts are in minor units, so10000is $100.00.{ "amount": 10000, "currency": "usd", "source_data": { "type": "skrill", "billing_details": { "name": "Jane Smith", "email": "jane.smith@example.com" } }, "customer_reference_id": "cust-001", "reference": "order-12345", "description": "Order #12345" }{ "id": "chrg_702172227948251136", "resource": "charge", "amount": 10000, "currency": "usd", "status": "requires_authentication", "payment_method_details": { "type": "skrill" }, "reference": "order-12345", "test_mode": true }Put a method's own fields in
source_data.<type>, such assource_data.ideal, and the customer's details insource_data.billing_details. Each method's page lists the fields it needs.The charge's
statusisrequires_authenticationuntil the customer approves the payment. A charge that returnspendingorsucceededneeds no redirect, so wait for its webhook event. - 2
Create a linked authentication session
Send
POST /v1/sessions/authentication/linkedwith the charge'sidasresourceand thereturn_urlto return the customer to.confirmdefaults totrue, so Pay.com completes the charge when the customer approves it. Each charge supports one linked authentication session.{ "resource": "chrg_702172227948251136", "return_url": "https://your-site.com/payment/complete" }{ "id": "sca_702172392511768576", "resource": "authentication_session", "status": "open", "return_url": "https://your-site.com/payment/complete", "url": "https://alternatives.sandbox.pay.com/authenticate?client_secret=...", "test_mode": true } - 3
Redirect the customer
Send the customer to the session's
urlwith a full-page redirect, because some methods don't load in an iframe. After they approve or cancel the payment, the method returns them to yourreturn_url. Fulfill the order when you receive thecharge.succeededwebhook event, and handlecharge.failedas a canceled, declined, or abandoned payment.If the customer doesn't finish, the charge stays
requires_authenticationuntil the authentication session expires, 60 minutes by default. For most methods, it then moves tofailed, and thecharge.failedevent fires.
Listen for webhooks
Subscribe to these events, and verify the Pay-Signature header before you act
on one. See Verify webhook signatures.
charge.pending: The customer approved the payment, and the method hasn't confirmed it yet.charge.succeeded: The payment completed. Fulfill the order.charge.failed: The customer canceled, the method declined the payment, or the authentication session expired.
Test in the sandbox
Test with your sandbox API key (sk-pay-com-sandbox-...) against
https://api.sandbox.pay.com/v1. Sandbox payments never move real funds. See
Environments.
Some methods open a payment simulator at the authentication session's url,
where you choose the payment's outcome. For the others, you can check each step
up to the method's page. Each method's Add to checkout page describes how
to test it.
Next steps
- iDEAL server-to-server: Follow one method's full guide, with its bank selection.
- Payment methods: Find each method's type, required fields, and options.
- Refund a charge: Refund APM payments in full or in part.
- Webhooks: Set up your endpoint and verify signatures.