forked from kevinowino869/mitrobill
plugin system for payment gateway
This commit is contained in:
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
*
|
||||
* Payment Gateway duitku.com
|
||||
**/
|
||||
|
||||
class PGDuitku
|
||||
{
|
||||
protected $user;
|
||||
protected $trx;
|
||||
|
||||
public function __construct($trx, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->trx = $trx;
|
||||
}
|
||||
|
||||
|
||||
function createTransaction($channel)
|
||||
{
|
||||
global $_c;
|
||||
$json = [
|
||||
'paymentMethod' => $channel,
|
||||
'paymentAmount' => $this->trx['price'],
|
||||
'merchantCode' => $_c['duitku_merchant_id'],
|
||||
'merchantOrderId' => $this->trx['id'],
|
||||
'productDetails' => $this->trx['plan_name'],
|
||||
'merchantUserInfo' => $this->user['fullname'],
|
||||
'customerVaName' => $this->user['fullname'],
|
||||
'email' => (empty($this->user['email'])) ? $this->user['username'] . '@' . $_SERVER['HTTP_HOST'] : $this->user['email'],
|
||||
'phoneNumber' => $this->user['phonenumber'],
|
||||
'itemDetails' => [
|
||||
[
|
||||
'name' => $this->trx['plan_name'],
|
||||
'price' => $this->trx['price'],
|
||||
'quantity' => 1
|
||||
]
|
||||
],
|
||||
'returnUrl' => U . 'order/view/' . $this->trx['id'] . '/check',
|
||||
'signature' => md5($_c['duitku_merchant_id'] . $this->trx['id'] . $this->trx['price'] . $_c['duitku_merchant_key'])
|
||||
];
|
||||
return json_decode(Http::postJsonData($this->getServer() . 'v2/inquiry', $json), true);
|
||||
/*
|
||||
{
|
||||
"merchantCode": "DXXXX",
|
||||
"reference": "DXXXXCX80TZJ85Q70QCI",
|
||||
"paymentUrl": "https://sandbox.duitku.com/topup/topupdirectv2.aspx?ref=BCA7WZ7EIDXXXXWEC",
|
||||
"vaNumber": "7007014001444348",
|
||||
"qrString": "",
|
||||
"amount": "40000",
|
||||
"statusCode": "00",
|
||||
"statusMessage": "SUCCESS"
|
||||
}
|
||||
00 - Success
|
||||
01 - Pending
|
||||
02 - Canceled
|
||||
*/
|
||||
}
|
||||
|
||||
function getStatus()
|
||||
{
|
||||
global $_c;
|
||||
$json = [
|
||||
'merchantCode' => $_c['duitku_merchant_id'],
|
||||
'merchantOrderId' => $this->trx['id'],
|
||||
'signature' => md5($_c['duitku_merchant_id'] . $this->trx['id'] . $_c['duitku_merchant_key'])
|
||||
];
|
||||
return json_decode(Http::postJsonData($this->getServer() . 'transactionStatus', $json), true);
|
||||
/*
|
||||
{
|
||||
"merchantOrderId": "abcde12345",
|
||||
"reference": "DXXXXCX80TZJ85Q70QCI",
|
||||
"amount": "100000",
|
||||
"statusCode": "00",
|
||||
"statusMessage": "SUCCESS"
|
||||
}
|
||||
00 - Success
|
||||
01 - Pending
|
||||
02 - Canceled
|
||||
*/
|
||||
}
|
||||
|
||||
private function getServer()
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'Live') {
|
||||
return 'https://passport.duitku.com/webapi/api/merchant/';
|
||||
} else {
|
||||
return 'https://sandbox.duitku.com/webapi/api/merchant/';
|
||||
}
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
*
|
||||
* Payment Gateway Tripay
|
||||
**/
|
||||
|
||||
class PGTripay
|
||||
{
|
||||
protected $user;
|
||||
protected $trx;
|
||||
|
||||
public function __construct($trx, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->trx = $trx;
|
||||
}
|
||||
|
||||
function getSignature()
|
||||
{
|
||||
global $_c;
|
||||
return hash_hmac('sha256', $_c['tripay_merchant'] . $this->trx['id'] . $this->trx['price'], $_c['tripay_secret_key']);
|
||||
}
|
||||
|
||||
function createTransaction($channel)
|
||||
{
|
||||
global $_c;
|
||||
$json = [
|
||||
'method' => $channel,
|
||||
'amount' => $this->trx['price'],
|
||||
'merchant_ref' => $this->trx['id'],
|
||||
'customer_name' => $this->user['fullname'],
|
||||
'customer_email' => (empty($this->user['email'])) ? $this->user['username'] . '@' . $_SERVER['HTTP_HOST'] : $this->user['email'],
|
||||
'customer_phone' => $this->user['phonenumber'],
|
||||
'order_items' => [
|
||||
[
|
||||
'name' => $this->trx['plan_name'],
|
||||
'price' => $this->trx['price'],
|
||||
'quantity' => 1
|
||||
]
|
||||
],
|
||||
'return_url' => U . 'order/view/' . $this->trx['id'] . '/check',
|
||||
'signature' => $this->getSignature()
|
||||
];
|
||||
return json_decode(Http::postJsonData($this->getServer() . 'transaction/create', $json, ['Authorization: Bearer ' . $_c['tripay_api_key']]), true);
|
||||
/*
|
||||
{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": {
|
||||
"reference": "T0001000000000000006",
|
||||
"merchant_ref": "INV345675",
|
||||
"payment_selection_type": "static",
|
||||
"payment_method": "BRIVA",
|
||||
"payment_name": "BRI Virtual Account",
|
||||
"customer_name": "Nama Pelanggan",
|
||||
"customer_email": "emailpelanggan@domain.com",
|
||||
"customer_phone": "081234567890",
|
||||
"callback_url": "https://domainanda.com/callback",
|
||||
"return_url": "https://domainanda.com/redirect",
|
||||
"amount": 1000000,
|
||||
"fee_merchant": 1500,
|
||||
"fee_customer": 0,
|
||||
"total_fee": 1500,
|
||||
"amount_received": 998500,
|
||||
"pay_code": "57585748548596587",
|
||||
"pay_url": null,
|
||||
"checkout_url": "https://tripay.co.id/checkout/T0001000000000000006",
|
||||
"status": "UNPAID",
|
||||
"expired_time": 1582855837,
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function getStatus($trxID)
|
||||
{
|
||||
global $_c;
|
||||
return json_decode(Http::getData($this->getServer() . 'transaction/detail?'.http_build_query(['reference'=>$trxID]), [
|
||||
'Authorization: Bearer ' . $_c['tripay_api_key']
|
||||
]), true);
|
||||
/*
|
||||
{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": {
|
||||
"reference": "T0001000000000000006",
|
||||
"merchant_ref": "INV345675",
|
||||
"payment_selection_type": "static",
|
||||
"payment_method": "BRIVA",
|
||||
"payment_name": "BRI Virtual Account",
|
||||
"customer_name": "Nama Pelanggan",
|
||||
"customer_email": "emailpelanggan@domain.com",
|
||||
"customer_phone": "081234567890",
|
||||
"callback_url": "https://domainanda.com/callback",
|
||||
"return_url": "https://domainanda.com/redirect",
|
||||
"amount": 1000000,
|
||||
"fee_merchant": 1500,
|
||||
"fee_customer": 0,
|
||||
"total_fee": 1500,
|
||||
"amount_received": 998500,
|
||||
"pay_code": "57585748548596587",
|
||||
"pay_url": null,
|
||||
"checkout_url": "https://tripay.co.id/checkout/T0001000000000000006",
|
||||
"status": "PAID",
|
||||
"expired_time": 1582855837,
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private function getServer()
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'Live') {
|
||||
return 'https://tripay.co.id/api/';
|
||||
} else {
|
||||
return 'https://tripay.co.id/api-sandbox/';
|
||||
}
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
*
|
||||
* Payment Gateway Xendit
|
||||
**/
|
||||
|
||||
class PGXendit {
|
||||
protected $user;
|
||||
protected $trx;
|
||||
protected $channel;
|
||||
|
||||
public function __construct($trx,$user) {
|
||||
$this->user = $user;
|
||||
$this->trx = $trx;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function createInvoice()
|
||||
{
|
||||
global $_c;
|
||||
$json = [
|
||||
'external_id' => $this->trx['id'],
|
||||
'amount' => $this->trx['price'],
|
||||
'description' => $this->trx['plan_name'],
|
||||
'customer' => [
|
||||
'mobile_number' => $this->user['phonenumber'],
|
||||
],
|
||||
'customer_notification_preference' => [
|
||||
'invoice_created' => ['whatsapp', 'sms'],
|
||||
'invoice_reminder' => ['whatsapp', 'sms'],
|
||||
'invoice_paid' => ['whatsapp', 'sms'],
|
||||
'invoice_expired' => ['whatsapp', 'sms']
|
||||
],
|
||||
'payment_methods ' => explode(',', $_c['xendit_channel']),
|
||||
'success_redirect_url' => U . 'order/view/' . $this->trx['id'] . '/check',
|
||||
'failure_redirect_url' => U . 'order/view/' . $this->trx['id'] . '/check'
|
||||
];
|
||||
|
||||
return json_decode(Http::postJsonData($this->getServer() . 'invoices', $json, ['Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')]), true);
|
||||
/*
|
||||
{
|
||||
"id": "631597513897510bace2459d", #gateway_trx_id
|
||||
"external_id": "test-va-success-1662359375",
|
||||
"user_id": "599bd7f1ccab55b020bb1147",
|
||||
"status": "PENDING",
|
||||
"merchant_name": "Xendit",
|
||||
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
||||
"amount": 3000000,
|
||||
"description": "Test - VA Successful invoice payment",
|
||||
"expiry_date": "2022-09-06T06:29:37.251Z",
|
||||
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
||||
"created": "2022-09-05T06:29:37.954Z",
|
||||
"updated": "2022-09-05T06:29:37.954Z"
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function getInvoice($xendittrxID)
|
||||
{
|
||||
global $_c;
|
||||
return json_decode(Http::getData($this->getServer() . 'invoices/' . $xendittrxID, [
|
||||
'Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')
|
||||
]), true);
|
||||
/*
|
||||
{
|
||||
"id": "631597513897510bace2459d", #gateway_trx_id
|
||||
"external_id": "test-va-success-1662359375",
|
||||
"user_id": "599bd7f1ccab55b020bb1147",
|
||||
"status": "PENDING", // CHECK THIS
|
||||
"merchant_name": "Xendit",
|
||||
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
||||
"amount": 3000000,
|
||||
"description": "Test - VA Successful invoice payment",
|
||||
"expiry_date": "2022-09-06T06:29:37.251Z",
|
||||
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
||||
"created": "2022-09-05T06:29:37.954Z",
|
||||
"updated": "2022-09-05T06:29:37.954Z"
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private function getServer(){
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'Live') {
|
||||
return 'https://api.xendit.co/v2/';
|
||||
} else {
|
||||
return 'https://api.xendit.co/v2/';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user