Merx

Payment Methods

Merx comes with five payment gateways built in.

Payment Method Provider Keyword
PayPal Payments PayPal paypal
Credit Card
with Payment Intents
Stripe credit-card-sca
Credit Card Stripe credit-card
SEPA Direct Debit Stripe sepa-debit
SOFORT Stripe sofort

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

$merx->completePayment([
  'paymentId' => 'PAYID-XXXXXXXXXXXXXXXXXXXXXXXX',
  'PayerID' => 'XXXXXXXXXXXXX'
]);

Credit Card with Payment Intents

Since Merx 1.2

With Stripe’s Credit Card integration, your customers can pay without leaving the website. You have to provide the ID of an authorized Payment Intent.

Read the cookbook Checkout with Stripe’s Payment Intents to learn more.

This payment method supports Strong Customer Authentication (SCA).

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():

Credit Card

This payment method shouldn’t be used. It requires an older Stripe API and doesn’t support Strong Customer Authentication (SCA) which is required in the European Union. You should use credit-card-sca instead.

With Stripe’s Credit Card integration, your customers can pay without leaving the website. You need to integrate Stripe’s Card Element to get a stripeToken which you have to provide for initializePayment.

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'credit-card',
  'stripeToken' => 'tok_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

SEPA Direct Debit works very similar to Credit Card. Create a Stripe IBAN Element to get a stripeToken.

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'sepa-debit',
  'stripeToken' => 'tok_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():

SOFORT

Initialize Payment

$redirect = $merx->initializePayment([
  'paymentMethod' => 'sofort',
]);
go($redirect); // https://www.sofort.com/payment/…

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

Complete Payment

The redirect url has several get parameters. Use the source parameter for the completePayment method.

site/templates/success.php

$source = get('source'); // src_XXXXXXXXXXXXXXXXXXXXXXXX
$merx->completePayment([
  'source' => $source,
]):