Skip to Content
Docs

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. 1

    Create the charge

    Send POST /v1/charges with source_data.type set to the method's type. Amounts are in minor units, so 10000 is $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"
    }

    Put a method's own fields in source_data.<type>, such as source_data.ideal, and the customer's details in source_data.billing_details. Each method's page lists the fields it needs.

    The charge's status is requires_authentication until the customer approves the payment. A charge that returns pending or succeeded needs no redirect, so wait for its webhook event.

  2. 2

    Create a linked authentication session

    Send POST /v1/sessions/authentication/linked with the charge's id as resource and the return_url to return the customer to. confirm defaults to true, 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"
    }
  3. 3

    Redirect the customer

    Send the customer to the session's url with 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 your return_url. Fulfill the order when you receive the charge.succeeded webhook event, and handle charge.failed as a canceled, declined, or abandoned payment.

    If the customer doesn't finish, the charge stays requires_authentication until the authentication session expires, 60 minutes by default. For most methods, it then moves to failed, and the charge.failed event 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

Was this page helpful?