PHP code example of ovri / payment

1. Go to this page and download the library: Download ovri/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/ */

    

ovri / payment example snippets




 = new Ovri\Payment([
	'MerchantKey' => '<your-merchant-key>',
	'SecretKey' => '<your-secret-key>',
	'API' => 'https://api.ovri.app'
]);

$data = [
	'amount' => '<amount-transaction>',
	'RefOrder' => '<your-reference-order-id>',
	'Customer_Email' => '<customer-email>',
	'Customer_Name' => '<customer-lastname>',
	'Customer_FirstName' => '<customer-firstname>'
];

$reponse = $Ovri->initializePayment($data);
//201 success request (others code = failed)
if ($reponse['http'] === 201) {
	//Code is internal Ovri coding (200 success others is failed)
	if ($reponse['Code'] === 200) {
		//Either you redirect the customer to the WEB payment url
		header('Location: ' . $reponse['DirectLinkIs']);
		//Or you just get the token to initiate one of our JS SDK libraries
		//@token is $reponse['SACS']
	}
} else {
	//Error and display result
	foreach ($reponse as $key => $value) {
		//If key Explanation or MissingParameters array for explain error
		if ($key === 'Explanation' || $key === 'MissingParameters') {
			echo "<b>$key</b> =>  " . print_r($value, TRUE) . "<br>";
		} else {
			echo "<b>$key</b> =>  $value <br>";
		}
	}
}



 = new Ovri\Payment([
'MerchantKey' => '<your-merchant-key>',
'SecretKey' => '<your-secret-key>',
'API' => 'https://api.ovri.app'
]);

$data = [
	'MerchantOrderId' => '<your-reference-order-id>'
];

$reponse = $Ovri->getStatusPayment($data); 
if ($reponse['http'] === 201) {
	//Display All transaction information (success)
	echo '<h1>Success request</h1>';
	echo '<pre>' . print_r($reponse, true) . '</pre>';
} else {
	//Display Failed message
	echo '<h1>Failed request</h1>';
	echo '<pre>' . print_r($reponse, true) . '</pre>';
}

$data = [
	'amount' => '<amount-transaction>',
	'RefOrder' => '<your-reference-order-id>',
	'Customer_Email' => '<customer-email>
];

$data = [
	'amount' => '<amount-transaction>',
	'RefOrder' => '<your-reference-order-id>',
	'Customer_Email' => '<customer-email>,
	'urlIPN' => '<votre-url-de-notification>'
];