PHP code example of jrodella / payment-form-api
1. Go to this page and download the library: Download jrodella/payment-form-api 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/ */
jrodella / payment-form-api example snippets
$ctxMode = 'TEST';
$keyTest = '1111111111111111';
$keyProd = '2222222222222222';
$algo = 'SHA-1';
$request = new \Lyranetwork\Request();
$request->set('ctx_mode', $ctxMode);
$request->set('key_test', $keyTest);
$request->set('key_prod', $keyProd);
$request->set('sign_algo', $algo);
$request->set('site_id', '12345678');
$request->set('amount', '100'); // amount in cents
$request->set('currency', '978');
$request->set('capture_delay', '');
$request->set('validation_mode', '');
echo $request->getRequestHtmlForm(); // display generated payment form
$keyTest = '1111111111111111';
$keyProd = '2222222222222222';
$algo = 'SHA-1';
$response = new \LyraNetwork\Response($_REQUEST, $keyTest, $keyProd, $algo);
if (! $response->isAuthentified()) {
// Unauthenticated response received
die('An error occurred while computing the signature.');
}
$order = get_my_order($response->get('order_id'));
if ($response->isAcceptedPayment()) {
// update order status, reduce products stock, send customer notifications, ...
update_my_order($order, 'success');
// redirect to success page
} elseif ($response->isCancelledPayment()) {
// redirect to cart page to allow re-order
} else {
// failed payment logic here
update_my_order($order, 'failed');
// redirect to failure or cart page
}