ovri / payment
Composer 库,用于 Ovri.com / Ovri.app 支付网关
1.0.1
2022-10-25 10:54 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.4
README
OVRI 是一种由 Fintech IPS INTERNATIONAL 提供的支付解决方案,可在以下网址获得:[https://www.ovri.com/]. 此库是 OVRI API 的 PHP 客户端。它允许您通过 Ovri 信用卡解决方案发起支付。
安装
官方安装方法是通过 composer 和其 Packagist 包 ovri/payment。
$ composer require ovri/payment
用法
库的最简单用法如下
<?php require_once __DIR__ . '/vendor/autoload.php'; $Ovri = 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>"; } } }
要设置另一种类型的支付,如分期付款,请参阅 API 文档了解可以在 $data[] 中插入哪些参数。
可选:您可以验证支付状态以查看支付是否完成。
<?php require_once __DIR__ . '/vendor/autoload.php'; $Ovri = 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>'; }
即时支付通知 (IPN)
如果您想的话,可以动态配置一个 URL,Ovri 在支付结束时自动调用该 URL 以通知您的服务器交易结果。
您需要做的只是启动支付时添加一个参数。
在上面的示例中,支付参数如下
$data = [
'amount' => '<amount-transaction>',
'RefOrder' => '<your-reference-order-id>',
'Customer_Email' => '<customer-email>
];
添加通知 URL 后将变为
$data = [
'amount' => '<amount-transaction>',
'RefOrder' => '<your-reference-order-id>',
'Customer_Email' => '<customer-email>,
'urlIPN' => '<votre-url-de-notification>'
];
请注意,所需的最小参数包括:金额、RefOrder、Customer_Email、Customer_Name、Customer_FirstName