Checkout Payment

A quick introduction how to create a checkout for all payment system

Overview

  1. Initialize SDK
  2. Create an order
  3. Create a checkout
  4. Examples

📘

This guide covers the Redirect Integration

1. Initialize SDK

var mpay24 = require('mpay24-node');
mpay24.init('merchantID','password', 'TEST');
require_once("../bootstrap.php");
use Mpay24\Mpay24;
use Mpay24\Mpay24Order; //if you are using paymentPage

$mpay24 = new Mpay24('9****', '*********');

2. Create a order object (MDXI)

const mdxi = {
  tid: 'test',
  price: '1.00'
};
$mdxi = new Mpay24Order();
$mdxi->Order->Tid = "123";
$mdxi->Order->Price = "1.00";
$mdxi->Order->URL->Success      = 'http://yourpage.com/success';
$mdxi->Order->URL->Error        = 'http://yourpage.com/error';
$mdxi->Order->URL->Confirmation = 'http://yourpage.com/confirmation';

How to create a shopping cart, customer and more: MDXI XML

3. Create checkout

mpay24.selectPayment(mdxi).then(function(result) {
  result.location // redirect location to mpay24 checkout
});
$paymentPageURL = $mpay24->paymentPage($mdxi)->getLocation(); // redirect location to the payment page

header('Location: '.$paymentPageURL);

Example: Node.js

This is the most minimal example to initialize a checkout.
The customer should be redirected to the URL returned by the method.

var express = require('express');
var mpay24 = require('mpay24-node');
var app = express();

mpay24.init('merchantID','password', 'TEST');

app.get('/', function (req, res) {
  mpay24.selectPayment({
    tid: 'test',
    price: '1.00'
	}).then(function(result) {
  	res.redirect(result.location);
	}).catch(err => {
    res.send(err);
  });
});

app.listen(3000, function () {
  console.log('Started');
});

If you access 127.0.0.1:3000 you should be redirected to the mpay24 checkout

Example: PHP

  1. Upload the PHP SDK from github: mpay24-sdk
  2. Configure your SOAP username/password in config.php
  3. Create a new .php file with following content
<?php
require("../bootstrap.php");
use Mpay24\Mpay24Order;
use Mpay24\Mpay24;

$mpay24 = new Mpay24();
$mdxi                           = new Mpay24Order();
$mdxi->Order->Tid               = "123 TID";
$mdxi->Order->Price             = "1.00";
$mdxi->Order->URL->Success      = "http://yourdomain.com/success";
$mdxi->Order->URL->Error        = "http://yourdomain.com/error";
$mdxi->Order->URL->Confirmation = "http://yourdomain.com/confirmation";

header("Location: " . $mpay24->paymentPage($mdxi)->getLocation());

If you access https://yoururl.com/test.php you should be redirected to the mpay24 checkout