PHP code example of academe / omnipay-mpay24
1. Go to this page and download the library: Download academe/omnipay-mpay24 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
academe / omnipay-mpay24 example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Mpay24_Seamless');
$gateway->setMerchantId('12345');
$gateway->setPassword('AB1234cd56');
$gateway->setTestMode(true);
$request = $gateway->token([
'language' => 'en',
//'customerId' => 'foo',
//'profileId' => 'bar',
//'style' => 'fizz',
]);
$response = $request->send();
if (! $response->isSuccessful()) {
// Token could not be generated.
echo '<p>Error: '.$response->getReturnCode().'</p>';
exit;
}
$response->getRedirectUrl();
$response->getToken();
<iframe src=" echo $response->getRedirectUrl();
use Omnipay\Omnipay;
use Omnipay\Common\CreditCard;
$gateway = Omnipay::create('Mpay24_Seamless');
$gateway->setMerchantId('12345');
$gateway->setPassword('AB1234cd56');
$gateway->setTestMode(true);
$card = new CreditCard([
'name' => 'Fred Bloggs',
//
'billingName' => 'Fred Billing',
'billingAddress1' => 'Street 1',
'billingAddress2' => 'Street 2',
'billingCity' => 'City',
'billingPostcode' => 'Postcode',
'billingCountry' => 'GB',
//
'shippingName' => 'Fred Shipping',
'shippingAddress1' => 'Street 1',
'shippingAddress2' => 'Street 2',
'shippingCity' => 'City',
'shippingPostcode' => 'Postcode',
'shippingCountry' => 'GB',
]);
$request = $gateway->purchase([
'paymentType' => 'TOKEN', // or PAYPAL etc. e.g $_POST['type'] in this example.
'amount' => '9.98',
'currency' => 'EUR',
'token' => $token, // e.g. $_POST['token']
'transactionId' => $transactionId,
'description' => 'Test Order',
'returnUrl' => 'https://example.com/complete/success',
'errorUrl' => 'https://example.com/complete/error',
'notifyUrl' => 'https://example.com/notify',
'language' => 'en',
'card' => $card,
]);
$response = $request->send();
if (! $response->isSuccessful() && $response->isRedirect()) {
$response->redirect();
exit;
}
use Omnipay\Omnipay;
use Omnipay\Common\CreditCard;
$gateway = Omnipay::create('Mpay24_PaymentPage');
$gateway->setMerchantId('12345');
$gateway->setPassword('AB1234cd56');
$gateway->setTestMode(true);
$request = $gateway->purchase([
'amount' => '9.98',
'currency' => 'EUR',
'token' => $token, // e.g. $_POST['token']
'transactionId' => $transactionId,
'description' => 'Test Order',
'returnUrl' => 'https://example.com/complete/success',
'errorUrl' => 'https://example.com/complete/error',
'notifyUrl' => 'https://example.com/notify',
'language' => 'en',
'card' => $card, // Names, addresses
'items' => $items,
]);
$response = $request->send();
'paymentType' => 'CC',
'brand' => 'VISA',
'paymentMethods' => [
["paymentType" => "CC", "brand" => "VISA"],
["paymentType" => "CC", "brand" => "MASTERCARD"],
["paymentType" => "PAYPAL", "brand" => "PAYPAL"],
],
// Or you can supply 'paymentMethods' as a JSON string.
$gateway = Omnipay::create('Mpay24_Backend');
// Set the usual merchant ID and test mode flags.
$request = $gateway->purchase([
'amount' => '9.99',
'currency' => 'EUR',
'transactionId' => 'new-transaction-id',
'description' => 'Recurring Payment Description',
'card' => [
'name' => 'Customer Name',
],
'notifyUrl' => 'https://omnipay.acadweb.co.uk/mpay24/notify.php?foo=bar&fee=fah', // mandatory
'language' => 'de',
'cardReference' => 'card-12345',
]);
$request = $gateway->acceptNotification();
// $request->getTransactionId();
// $request->getTransactionReference();
// $request->getTransactionStatus();
// $request->getMoney();
// $request->isSuccessful();
// $request->getData();