Merx

Payment Methods

Merx comes with five payment gateways built in.

Payment Method Provider Keyword
PayPal Payments PayPal paypal
Credit Card Stripe credit-card-sca
iDEAL Stripe ideal
SEPA Direct Debit Stripe sepa-debit
Klarna Stripe klarna

If you want to use another payment provider read the Custom Payment Gateways cookbook to learn how to create your own custom payment gateway.

Source Code

PayPal

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'paypal',
]);
go($redirect); // https://www.paypal.com/cgi-bin/webscr…

Complete Payment

site/templates/success.php

$payerID = get('PayerID');

$merx->completePayment([
  'PayerID' => $payerID,
]);

Credit Card

For historical reasons this payment method is called credit-card-sca instead of credit-card. SCA stands for Strong customer authentication.

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'credit-card-sca',
  'stripePaymentIntentId' => 'pi_XXXXXXXXXXXXXXXXXXXXXXXX'
]);
go($redirect); // /success

Complete Payment

You don’t have to provide any additional information for the completePayment method.

site/templates/success.php

$merx->completePayment():

iDEAL

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'ideal',
]);
go($redirect); // customer’s banking website

iDEAL redirects customers to their online banking environment to authenticate a payment using a second factor of authentication. There is immediate notification about the success or failure of a payment. The exact customer experience depends on their bank.

Complete Payment

site/templates/success.php

$paymentIntent = get('payment_intent'); // pi_XXXXXXXXXXXXXXXXXXXXXXXX

$merx->completePayment([
  'payment_intent' => $paymentIntent,
]);

SEPA Direct Debit

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'sepa-debit',
  'stripePaymentIntentId' => 'pi_XXXXXXXXXXXXXXXXXXXXXXXX',
]);
go($redirect); // /success

Complete Payment

You don’t have to provide any additional information for the completePayment method.

site/templates/success.php

$merx->completePayment():

SEPA Direct Debit payments are not marked as paymentComplete immediately, because this payment method has a delayed notification of payment success. You can use Stripe Webhooks to mark SEPA Direct Debit payments as completed.

Klarna

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'klarna',
]);
go($redirect); // https://payments.klarna.com

You are redirected to klarna.com where the customer has to accept the payment.

Complete Payment

site/templates/success.php

$paymentIntent = get('payment_intent'); // pi_XXXXXXXXXXXXXXXXXXXXXXXX

$merx->completePayment([
  'payment_intent' => $paymentIntent,
]);