Alternative payment methods (server version)

We recommend that you use our client API to support Alternative Payment Methods (APMs) but you can also access the relevant information on your server (to generate a web page with static APM links, say). See the client API page for a description of the asynchronous payment flow that APMs use.

Fetch a list of available APMs

The first step is to generate a list of available APMs for the user to choose from. The relevant information about the APMs is kept in the GatewayConfiguration objects that represent them. There are gateway configurations for all payment methods but you can filter the list to include only APMs, as shown in the example below. Once you have the list, you can iterate over it to present the options in any way you like. For example, on a web page, you might create a menu or a list of links for the APMs.

You will probably find it useful to expand the gateway field of the GatewayConfiguration objects when you list them because the Gateway object contains the APM's name, logo and other details you might want to display.

You should design your UI to send the gateway configuration id field of the chosen APM back to your server. You will need this ID to redirect the customer to the APM's payment page.

curl <https://api.processout.com/gateway-configurations?filter=alternative-payment-methods&expand_merchant_accounts=true>   
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB
client.newGatewayConfiguration().all({
    filter:                   "alternative-payment-methods",
    expand_merchant_accounts: true
}).then(function(confs) {
    // Iterate over the available confs and display them
}, function(err) {
    // An error occured
});
confs = client.new_gateway_configuration().create({
    "filter":                   "alternative-payment-methods",
    "expand_merchant_accounts": True
})
# Iterate over the available confs and display them
confs = client.gateway_configuration.new().all(
    filter:                   "alternative-payment-methods",
    expand_merchant_accounts: true
)
# Iterate over the available confs and display them
$confs = $client->newGatewayConfiguration()->all(array(
    "filter":                   "alternative-payment-methods",
    "expand_merchant_accounts": true
));
// Iterate over the available confs and display them
confs, err := client.NewGatewayConfiguration().All(processout.GatewayConfigurationAllParameters{
    ExpandMerchantAccounts: true,
    Options: &processout.Options{
        Filter: "alternative-payment-methods",
    },
})
if err != nil {
    panic(err)
}
// Iterate over the available confs and display them

Creating the invoice

You must include a return_url in your invoice as you would when you accept an APM payment with the client API (see the page for the client API to learn more about this). This is so that the APM's page can redirect back to your app. However, on the server, you should also add a skip_processoutjs field to the invoice's metadata, to avoid executing any redundant client-side JavaScript.

curl https://api.processout.com/invoices \
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB \
    -d name="Awesome invoice" \
    -d amount="9.99" \
    -d currency=USD \
    -d return_url="https://www.super-merchant.com/return" \
    -d metadata[skip_processoutjs]=true
client.newInvoice().create({
    name:       "Amazing item",
    amount:     "4.99",
    currency:   "USD",
    return_url: "https://www.super-merchant.com/return",
    metadata: {
      skip_processoutjs: "true"
    }
}).then(function(invoice) {
    // Continue
}, function(err) {
    // An error occured
});
invoice = client.new_invoice().create({
    "name":       "Amazing item",
    "amount":     "4.99",
    "currency":   "USD",
    "return_url": "https://www.super-merchant.com/return",
    "metadata": {
      "skip_processoutjs": "true"
    }
})
invoice = client.invoice.create(
    name:       "Amazing item",
    amount:     "4.99",
    currency:   "USD",
    return_url: "https://www.super-merchant.com/return",
    metadata: {
      skip_processoutjs: "true"
    }
)
$invoice = $client->newInvoice()->create(array(
    "name"       => "Amazing item",
    "amount"     => "4.99",
    "currency"   => "USD",
    "return_url" => "https://www.super-merchant.com/return",
    "metadata": array(
      "skip_processoutjs" => "true"
    )
));
iv, err := client.NewInvoice().Create(processout.InvoiceCreateParameters{
    Invoice: &processout.Invoice{
        Name:      processout.String("Amazing item"),
        Amount:    processout.String("4.99"),
        Currency:  processout.String("USD"),
        ReturnURL: processout.String("https://www.super-merchant.com/return"),
        Metadata:  &map[string]string{
          "skip_processoutjs": "true",
        },
    },
})
if err != nil {
    panic(err)
}

Redirecting your customer to the APM

When you have the invoice ID and the chosen gateway configuration ID, you should redirect the customer to a special URL that passes them on to the APM page.

This URL has the following format:

https://checkout.processout.com/<project_id>/<invoice_id>/redirect/<gateway_configuration_id>.apmname<?optional_parameters>
https://checkout.processout.com/test-proj_hgnt3R60AojpA3D4ZAFeYQuNRAtT1FDr/iv_ctBHCuUrbxfySdiivnJFdbZXuSaaeNyh/redirect/gway_conf_bqg2oivqet5d5rl7lm70fubyko6h7edk.adyenideal?additional_data[issuer_code]=1121 

Completing the payment when the customer returns

After the customer has authenticated their payment on the APM page, they will be redirected back to the return_url you set in the invoice. This URL will receive a POST parameter, which contains the payment token for the APM.

token=gway_req_V2UncmUgaGlyaW5nIQ==

From this point on, the payment process is similar to a card payment. You can use the token to capture the payment on your server in the handler that is activated by this URL. If the gateway supports authorizations, you can use the same token to authorize the payment before capturing it.

See the pages about authorizing a payment and capturing a payment for full details.