-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from segsalerty2013/dev
Add http example for integrations
- Loading branch information
Showing
6 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
require_once('./vendor/autoload.php'); | ||
require_once('init.php'); | ||
|
||
use Opay\Payload\OrderStatusRequest; | ||
|
||
$inputJSON = file_get_contents('php://input'); | ||
$input = json_decode($inputJSON, TRUE); //convert JSON into array | ||
$payload = $input['payload']; | ||
file_put_contents('./log_'.date("j.n.Y").'.log', 'payload: '.json_encode($payload). "\n", FILE_APPEND); | ||
|
||
$_orderStatusRequest = new OrderStatusRequest($payload['transactionId'], $payload['reference']); | ||
|
||
$merchantCashier->orderStatus($_orderStatusRequest); | ||
|
||
$response = $merchantCashier->getOrderStatusApiResult(); | ||
|
||
file_put_contents('./log_'.date("j.n.Y").'.log', 'code: '.json_encode($response->getCode()). "\n", FILE_APPEND); | ||
file_put_contents('./log_'.date("j.n.Y").'.log', 'data: '.json_encode($response->getData()). "\n", FILE_APPEND); | ||
|
||
// Example of data posted in callback | ||
// { | ||
// "payload": { | ||
// "country": "NG", | ||
// "instrumentId": "useless", | ||
// "fee": "0.00", | ||
// "channel": "Web", | ||
// "reference": "test_20196699559858800", | ||
// "updated_at": "2019-12-13T09:36:58Z", | ||
// "currency": "NGN", | ||
// "refunded": false, | ||
// "instrument-id": "useless", | ||
// "timestamp": "2019-12-13T09:36:58Z", | ||
// "amount": "0.10", | ||
// "instrumentType": "coins", | ||
// "instrument_id": "useless", | ||
// "transactionId": "191213140104849949", | ||
// "token": "191213140104849949", | ||
// "bussinessType": "Consumption_H5", | ||
// "payChannel": "BalancePayment", | ||
// "status": "failed" | ||
// }, | ||
// "sha512": "9cc847600cb7104b0a5a48976e70cf74763eb69f123a282975de1c3a751128c12d437b1f7c7d4a24bdb82b79aaa477e98e81bc66be8e8d8c3c15cdfcea730553", | ||
// "type": "transaction-status" | ||
// } | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require_once('./vendor/autoload.php'); | ||
|
||
use Opay\MerchantCashier; | ||
|
||
$merchantCashier = new MerchantCashier( | ||
"http://api.test.opaydev.com:8081", | ||
"qazwert12345!@#$", | ||
"fKJ8jwsj1nHNkKon", | ||
"256619112122000"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
require_once('./vendor/autoload.php'); | ||
require_once('init.php'); | ||
|
||
use Opay\Payload\OrderRequest; | ||
use Opay\Utility\OpayConstants; | ||
|
||
$reference = "test_20196659118854400"; | ||
|
||
$_orderRequest = new OrderRequest([OpayConstants::PAYMENT_CHANNEL_BALANCE_PAYMENT, OpayConstants::PAYMENT_CHANNEL_BONUS_PAYMENT], $reference, | ||
"WOW. The best wireless earphone in history. Cannot agree more! Right!", [OpayConstants::PAYMENT_METHODS_ACCOUNT, OpayConstants::PAYMENT_METHODS_QRCODE], OpayConstants::CURRENCY_NAIRA, | ||
"100", "+2349876543210", getUserIP(), "http://a7384c7d.ngrok.io/callback.php", | ||
"http://a7384c7d.ngrok.io/order_status.php", "Jerry's shop", "Apple AirPods Pro"); | ||
|
||
$merchantCashier->order($_orderRequest); | ||
|
||
$response = $merchantCashier->getOrderApiResult(); | ||
|
||
echo "status : ". $response->getCode(). "<br/>"; | ||
|
||
if($response->getCode() === "00000") { | ||
var_dump($response->getData()); | ||
} | ||
|
||
function getUserIP() { | ||
$ipaddress = ''; | ||
if (isset($_SERVER['HTTP_CLIENT_IP'])) | ||
$ipaddress = $_SERVER['HTTP_CLIENT_IP']; | ||
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) | ||
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; | ||
else if(isset($_SERVER['HTTP_X_FORWARDED'])) | ||
$ipaddress = $_SERVER['HTTP_X_FORWARDED']; | ||
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) | ||
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; | ||
else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) | ||
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; | ||
else if(isset($_SERVER['HTTP_FORWARDED'])) | ||
$ipaddress = $_SERVER['HTTP_FORWARDED']; | ||
else if(isset($_SERVER['REMOTE_ADDR'])) | ||
$ipaddress = $_SERVER['REMOTE_ADDR']; | ||
else | ||
$ipaddress = 'UNKNOWN'; | ||
return $ipaddress; | ||
} | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
var_dump($_REQUEST); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters