1. Go to this page and download the library: Download simplon/payment 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/ */
simplon / payment example snippets
$authPayPal = \Simplon\Payment\PayPal\Auth::init()
->setUsername('MERCHANT_USER')
->setPassword('MERCHANT_PASSWORD')
->setSignature('MERCHANT_SIGNATURE')
->setSandboxMode(TRUE); // for production = FALSE
$items = array();
// add item
$items[] = (new \Simplon\Payment\ProductItem())
->setRefId('12345')
->setName('Super Mega Pack')
->setDescription('500 Diamonds with 50% discount')
->setPrice(15)
->setQuantity(1)
->setTax(19);
// add item
$items[] = (new \Simplon\Payment\ProductItem())
->setName('Strong Hammer')
->setPrice(3.99)
->setQuantity(1);
// create instance of PayPalStart
$paypal = new \Simplon\Payment\PayPal\PayPalStart($authPayPal);
// request token
$paypal
->setOrderItemsMany($items)
->setUrlSuccess(URL_SUCCESS)
->setUrlCancel(URL_CANCEL)
->setCommitOnPayPal(TRUE)
->requestCheckoutToken();
// show token
echo $paypal->getCheckoutToken(); // prints checkoutToken
// auth
$authPayPal = \Simplon\Payment\PayPal\Auth::init(); // do the same as above ...
// create instance of PayPalProcess
$paypal = new \Simplon\Payment\PayPal\PayPalProcess($authPayPal);
// set received checkoutToken
$paypal->setCheckoutToken($_GET['token']);
// request checkout details based on checkoutToken
$paypal->requestGetExpressCheckoutDetails();
// get created VO
$detailsResponseVo = $paypalSession->getGetExpressCheckoutDetailsResponseVo();
// here goes code for request checkout details ...
$paypal->requestDoExpressCheckoutPayment(
$detailsResponseVo->getPayerId(),
$detailsResponseVo->getOrderAmount(),
$detailsResponseVo->getCurrencyCode()
);
// resonse data are within this VO
$paymentResponseVo = $paypalSession->getDoExpressCheckoutPaymentResponseVo();