Merx

Payment Methods

Merx comes with 4 payment gateways built in.

Payment Method Provider Keyword
PayPal Payments PayPal paypal
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([
  'payment-method' => '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 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,
]):