Initial Commit
This commit is contained in:
commit
3521dca830
|
|
@ -0,0 +1,3 @@
|
|||
/vendor
|
||||
/.idea
|
||||
/.DS_Store
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":1,"defects":{"Tests\\Unit\\AuthorizeDotNetPayTest::charge_amount_returns_amount_in_usd_if_currency_is_not_supported":4,"Tests\\Unit\\AuthorizeDotNetPayTest::view_returns_view_with_correct_data":4,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testChargeAmount":3,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testIpnResponseSuccess":3,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testChargeCustomer":4,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_charge_amount_converts_to_usd_if_not_supported_currency":3,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_ipn_response_returns_complete_if_transaction_is_successful":4},"times":{"Tests\\Unit\\AuthorizeDotNetPayTest::charge_amount_returns_amount_in_usd_if_currency_is_not_supported":0.003,"Tests\\Unit\\AuthorizeDotNetPayTest::charge_amount_returns_amount_if_currency_is_supported":0,"Tests\\Unit\\AuthorizeDotNetPayTest::view_returns_view_with_correct_data":0.001,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testGetUsername":0.051,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testChargeAmount":0.009,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testIpnResponseSuccess":0.011,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testIpnResponseFailure":0.008,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testChargeCustomer":0.015,"Xgenious\\Paymentgateway\\Tests\\Features\\ZitoPayTest::testSupportedCurrencyList":0.008,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_charge_amount_returns_correct_amount":0.053,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_charge_amount_converts_to_usd_if_not_supported_currency":0.008,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_supported_currency_list_returns_array":0.008,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_gateway_name_returns_zitopay":0.008,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_ipn_response_returns_complete_if_transaction_is_successful":0.011,"Xgenious\\Paymentgateway\\Tests\\Gateways\\ZitoPayTest::test_ipn_response_returns_failed_if_transaction_is_not_successful":0.01}}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"name": "xgenious/paymentgateway",
|
||||
"description": "a laravel package to manage multiple payment gateway",
|
||||
"keywords": [
|
||||
"Laravel",
|
||||
"xgenious"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sharifur Rahman",
|
||||
"email": "dvrobin4@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/Sharifur/paymentgateway",
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"laravel/framework": "^9.0",
|
||||
"stripe/stripe-php": "^7.103",
|
||||
"srmklive/paypal": "~3.0",
|
||||
"midtrans/midtrans-php": "^2.5",
|
||||
"anandsiddharth/laravel-paytm-wallet": "^2.0.0",
|
||||
"razorpay/razorpay": "2.*",
|
||||
"mollie/laravel-mollie": "^2.0",
|
||||
"unicodeveloper/laravel-paystack": "1.0.*",
|
||||
"mercadopago/dx-php":"^2.4.4",
|
||||
"tzsk/payu": "^6.0.0",
|
||||
"square/square": "18.0.0.20220420",
|
||||
"cinetpay/cinetpay-php": "^1.9",
|
||||
"paytabscom/laravel_paytabs": "dev-master",
|
||||
"jomweb/billplz-laravel" : "^v3.0.0",
|
||||
"sharifur/payfast" : "^v1.0.0",
|
||||
"authorizenet/authorizenet": "^2.0",
|
||||
"php-http/message": "^1.16",
|
||||
"php-http/message-factory": "^1.1",
|
||||
"iyzico/iyzipay-php": "^2.0",
|
||||
"stevebauman/location": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"orchestra/testbench": "^7.0",
|
||||
"phpstan/phpstan": "^0.12"
|
||||
},
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Xgenious\\Paymentgateway\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Xgenious\\Paymentgateway\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Xgenious\\Paymentgateway\\Providers\\PaymentgatewayServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit -c ./phpunit.xml --colors=always",
|
||||
"analysis": "vendor/bin/phpstan analyse"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"php-http/discovery": true
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* paymentgateway package config file
|
||||
*/
|
||||
return [
|
||||
// Place your package's config settings here.
|
||||
'stripe' => [
|
||||
'secret_key' => env('STRIPE_SECRET_KEY',null),
|
||||
'public_key' => env('STRIPE_PUBLIC_KEY',null)
|
||||
],
|
||||
'paypal' =>[
|
||||
'mode' => env('PAYPAL_MODE', 'sandbox'), // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
|
||||
'sandbox' => [
|
||||
'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID', ''),
|
||||
'client_secret' => env('PAYPAL_SANDBOX_CLIENT_SECRET', ''),
|
||||
'app_id' => env('PAYPAL_SANDBOX_APP_ID', ''),
|
||||
],
|
||||
'live' => [
|
||||
'client_id' => env('PAYPAL_LIVE_CLIENT_ID', ''),
|
||||
'client_secret' => env('PAYPAL_LIVE_CLIENT_SECRET', ''),
|
||||
'app_id' => env('PAYPAL_LIVE_APP_ID', ''),
|
||||
],
|
||||
|
||||
'payment_action' => env('PAYPAL_PAYMENT_ACTION', 'Sale'), // Can only be 'Sale', 'Authorization' or 'Order'
|
||||
'currency' => env('SITE_GLOBAL_CURRENCY', 'USD'),
|
||||
'notify_url' => env('PAYPAL_NOTIFY_URL', ''), // Change this accordingly for your application.
|
||||
'locale' => env('PAYPAL_LOCALE', 'en_US'), // force gateway language i.e. it_IT, es_ES, en_US ... (for express checkout only)
|
||||
'validate_ssl' => env('PAYPAL_VALIDATE_SSL', true), // Validate SSL when creating api client.
|
||||
],
|
||||
'midtrans' => [
|
||||
'merchant_id' => env('MIDTRANS_MERCHANT_ID', null),
|
||||
'server_key' => env('MIDTRANS_SERVER_KEY', null),
|
||||
'client_key' => env('MIDTRANS_CLIENT_KEY', null),
|
||||
'envaironment' => env('MIDTRANS_ENVAIRONTMENT', false) // Set to Development/Sandbox Environment (default). Set to true for Production Environment (accept real transaction).
|
||||
],
|
||||
'paytm' => [
|
||||
'env' => env('PAYTM_ENVIRONMENT','local'), // values : (local | production)
|
||||
'merchant_id' => env('PAYTM_MERCHANT_ID'),
|
||||
'merchant_key' => env('PAYTM_MERCHANT_KEY'),
|
||||
'merchant_website' => env('PAYTM_MERCHANT_WEBSITE'),
|
||||
'channel' => env('PAYTM_CHANNEL'),
|
||||
'industry_type' => env('PAYTM_INDUSTRY_TYPE'),
|
||||
],
|
||||
'razorpay' => [
|
||||
'api_key' => env('RAZORPAY_API_KEY',null),
|
||||
'api_secret' => env('RAZORPAY_API_SECRET',null),
|
||||
],
|
||||
'mollie' => [
|
||||
'public_key' => env('MOLLIE_KEY',null)
|
||||
],
|
||||
'flutterwave' => [
|
||||
'public_key' => env('FLW_PUBLIC_KEY',null),
|
||||
'secret_key' => env('FLW_SECRET_KEY',null),
|
||||
'secret_hash' => env('FLW_SECRET_HASH','abcd'),
|
||||
],
|
||||
'paystack' => [
|
||||
'public_key' => env('PAYSTACK_PUBLIC_KEY',null),
|
||||
'secret_key' => env('PAYSTACK_SECRET_KEY',null),
|
||||
'payment_url' => env('PAYSTACK_PAYMENT_URL','https://api.paystack.co'),
|
||||
'merchant_email' => env('MERCHANT_EMAIL',''),
|
||||
],
|
||||
'payfast' => [
|
||||
'merchant_id' => env('PF_MERCHANT_ID'),
|
||||
'merchant_key' => env('PF_MERCHANT_KEY'),
|
||||
'passpharse' => env('PAYFAST_PASSPHRASE'),
|
||||
'environment' => env('PF_MERCHANT_ENV',true),
|
||||
'PF_ITN_URL' => env('PF_ITN_URL',null)
|
||||
],
|
||||
'cashfree' => [
|
||||
'test_mode' => env('CASHFREE_TEST_MODE','true'),
|
||||
'app_id' => env('CASHFREE_APP_ID'),
|
||||
'secret_key' => env('CASHFREE_SECRET_KEY'),
|
||||
],
|
||||
'instamojo' => [
|
||||
'client_id' => env('INSTAMOJO_CLIENT_ID'),
|
||||
'client_secret' => env('INSTAMOJO_CLIENT_SECRET'),
|
||||
'test_mode' => env('INSTAMOJO_TEST_MODE',true),
|
||||
],
|
||||
'mercadopago' => [
|
||||
'client_id' => env('MERCADO_PAGO_CLIENT_ID'),
|
||||
'client_secret' => env('MERCADO_PAGO_CLIENT_SECRET'),
|
||||
'test_mode' => env('MERCADO_PAGO_TEST_MODE',true),
|
||||
],
|
||||
'global_currency' => env('SITE_GLOBAL_CURRENCY','USD'),
|
||||
'ngn_exchange_rate' => env('NGN_EXCHANGE_RATE',null),
|
||||
'inr_exchange_rate' => env('INR_EXCHANGE_RATE',null),
|
||||
'usd_exchange_rate' => env('USD_EXCHANGE_RATE',null),
|
||||
'idr_exchange_rate' => env('IDR_EXCHANGE_RATE',null),
|
||||
'zar_exchange_rate' => env('ZAR_EXCHANGE_RATE',null),
|
||||
'brl_exchange_rate' => env('BRL_EXCHANGE_RATE',null)
|
||||
];
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
parameters:
|
||||
level: 5
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="paymentgateway Unit Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"Stripe" : "Stripe Payment"
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,37 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('Cashfree Payment Gateway')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<form class="redirectForm" method="post" action="{{$payment_data['action']}}">
|
||||
<input type="hidden" name="appId" value="{{$payment_data['app_id']}}"/>
|
||||
<input type="hidden" name="orderId" value="{{$payment_data['order_id']}}"/>
|
||||
<input type="hidden" name="orderAmount" value="{{$payment_data['amount']}}"/>
|
||||
<input type="hidden" name="orderCurrency" value="{{$payment_data['currency']}}"/>
|
||||
<input type="hidden" name="orderNote" value="{{$payment_data['order_id']}}"/>
|
||||
<input type="hidden" name="customerName" value="{{$payment_data['name']}}"/>
|
||||
<input type="hidden" name="customerEmail" value="{{$payment_data['email']}}"/>
|
||||
<input type="hidden" name="customerPhone" value="{{$payment_data['phone']}}"/>
|
||||
<input type="hidden" name="returnUrl" value="{{$payment_data['return_url']}}"/>
|
||||
<input type="hidden" name="notifyUrl" value="{{$payment_data['notify_url']}}"/>
|
||||
<input type="hidden" name="signature" value="{{$payment_data['signature']}}"/>
|
||||
|
||||
<button type="submit" id="paymentbutton" class="btn btn-block btn-lg bg-ore continue-payment">Continue to Payment</button>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var submitBtn = document.querySelector('#paymentbutton');
|
||||
submitBtn.innerHTML = "{{__('Redirecting Please Wait...')}}";
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('CinetPay Payment Gateway')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
{!! $payButton !!}
|
||||
<script>
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var submitBtn = document.querySelector('#goCinetPay button.cpButton');
|
||||
submitBtn.innerHTML = "{{__('Redirecting Please Wait...')}}";
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<html>
|
||||
<head>
|
||||
<title> {{__('Pagali Payment Gateway')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="pagali_form" name="pagali_form" method="post" action="https://www.pagali.cv/pagali/index.php?r=pgPaymentInterface/ecommercePayment">
|
||||
<input type="hidden" name="item_name[]" value="{{$pagali_data['title']}}" />
|
||||
<input type="hidden" name="quantity[]" value="1" />
|
||||
<input type="hidden" name="item_number[]" value="1" />
|
||||
<input type="hidden" name="amount[]" value="{{$pagali_data['charge_amount']}}" >
|
||||
<input type="hidden" name="total_item[]" value="1" />
|
||||
<input type="hidden" name="order_id" value="{{$pagali_data['order_id']}}" >
|
||||
<input type="hidden" name="id_ent" value="{{$pagali_data['entity_id']}}">
|
||||
<input type="hidden" name="currency_code" value="1" />
|
||||
<input type="hidden" name="total" value="{{$pagali_data['charge_amount']}}" />
|
||||
<input type="hidden" name="notify" value="{{$pagali_data['ipn_url']}}" />
|
||||
<input type="hidden" name="id_temp" value="{{$pagali_data['page_id']}}" />
|
||||
<input type="hidden" name="return" value="{{$pagali_data['success_url']}}" />
|
||||
<button type="submit" id="payment_submit_btn" form="pagali_form" value="Submit">{{__('Submit')}}</button>
|
||||
<form>
|
||||
|
||||
<script>
|
||||
(function($){
|
||||
"use strict";
|
||||
// Create a Stripe client
|
||||
var submitBtn = document.getElementById('payment_submit_btn');
|
||||
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
|
||||
submitBtn.addEventListener('click', function () {
|
||||
// Create a new Checkout Session using the server-side endpoint you
|
||||
submitBtn.innerText = "{{__('Do Not Close This page..')}}"
|
||||
// submitBtn.disabled = true;
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
});
|
||||
|
||||
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('Payfast Payment Gateway')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
{!! $submit_form !!}
|
||||
<script>
|
||||
(function($){
|
||||
"use strict";
|
||||
var submitBtn = document.querySelector('button[type="submit"]');
|
||||
submitBtn.innerHTML = "{{__('Redirecting Please Wait...')}}";
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<title> {{__('Paymob Payment Gateway')}}</title>
|
||||
<style>
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
iframe{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="paymob-payment-wrapper">
|
||||
<div class="paymob-payment-inner-wrapper">
|
||||
<iframe src="{{$payment_url}}" frameborder="0"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('PayStack Payment')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST" action="{{ $paystack_data['route'] }}" accept-charset="UTF-8" class="form-horizontal" role="form">
|
||||
@csrf
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<input type="hidden" name="name" value="{{$paystack_data['name']}}">
|
||||
<input type="hidden" name="email" value="{{$paystack_data['email']}}"> {{-- required --}}
|
||||
<input type="hidden" name="order_id" value="{{$paystack_data['order_id']}}">
|
||||
<input type="hidden" name="orderID" value="{{$paystack_data['order_id']}}">
|
||||
<input type="hidden" name="amount" value="{{$paystack_data['price'] * 100}}"> {{-- required in kobo --}}
|
||||
<input type="hidden" name="quantity" value="1">
|
||||
<input type="hidden" name="currency" value="{{$paystack_data['currency']}}">
|
||||
<input type="hidden" name="merchantEmail" value="{{$paystack_data['merchantEmail']}}">
|
||||
<input type="hidden" name="secretKey" value="{{base64_encode($paystack_data['secretKey'])}}">
|
||||
<input type="hidden" name="publicKey" value="{{$paystack_data['publicKey']}}">
|
||||
<input type="hidden" name="metadata" value="{{ json_encode($array = ['track' => $paystack_data['track'],'type' => $paystack_data['type'],'order_id' => $paystack_data['order_id']]) }}" > {{-- For other necessary things you want to add to your payload. it is optional though --}}
|
||||
<input type="hidden" name="reference" value="{{ md5(uniqid($paystack_data['order_id'], true)) }}"> {{-- required --}}
|
||||
<p>
|
||||
<button id="submit_btn" type="submit" >{{__('Redirecting..')}}</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
"use strict";
|
||||
var submitBtn = document.querySelector('#submit_btn');
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
|
||||
submitBtn.addEventListener('click', function () {
|
||||
// Create a new Checkout Session using the server-side endpoint you
|
||||
submitBtn.value = "{{__('Do Not Close This page..')}}"
|
||||
// submitBtn.disabled = true;
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,50 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('Razorpay')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="stripe-payment-wrapper">
|
||||
<div class="srtipe-payment-inner-wrapper">
|
||||
<form action="{{$razorpay_data['route']}}" method="POST" >
|
||||
<!-- Note that the amount is in paise = 50 INR -->
|
||||
<input type="hidden" name="order_id" value="{{$razorpay_data['order_id']}}" />
|
||||
|
||||
<!--amount need to be in paisa-->
|
||||
<script src="https://checkout.razorpay.com/v1/checkout.js"
|
||||
data-key="{{ $razorpay_data['api_key']}}"
|
||||
data-currency="{{$razorpay_data['currency']}}"
|
||||
data-amount="{{ceil($razorpay_data['price'] * 100)}}"
|
||||
data-buttontext="{{'Pay '.$razorpay_data['price'].' INR'}}"
|
||||
data-name="{{$razorpay_data['title']}}"
|
||||
data-description="{{$razorpay_data['description']}}"
|
||||
data-image=""
|
||||
data-prefill.name=""
|
||||
data-prefill.email=""
|
||||
data-theme.color="#000">
|
||||
</script>
|
||||
<input type="hidden" name="_token" value="{{csrf_token()}}">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
"use strict";
|
||||
var submitBtn = document.querySelector('input[type="submit"]');
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
|
||||
submitBtn.addEventListener('click', function () {
|
||||
// Create a new Checkout Session using the server-side endpoint you
|
||||
submitBtn.value = "{{__('Do Not Close This page..')}}"
|
||||
// submitBtn.disabled = true;
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<html>
|
||||
<head>
|
||||
<title> {{__('Salt Payment Gateway')}}</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.autorize-payment-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.autorize-payment-inner-wrapper {
|
||||
max-width: 600px;
|
||||
box-shadow: 0 0 40px 0 rgba(0, 0, 0, 0.05);
|
||||
border-radius: 10px;
|
||||
padding: 30px 40px 30px;
|
||||
}
|
||||
|
||||
.autorize-payment-inner-wrapper .logo-wrapper img {
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.autorize-payment-inner-wrapper .logo-wrapper {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div#cc-form {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
height: 30px;
|
||||
border: 1px solid #f2f2f2;
|
||||
border-radius: 5px;
|
||||
padding: 5px 10px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cardinfo_wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.btn-wrapper {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn-wrapper button {
|
||||
border: none;
|
||||
padding: 15px 25px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
margin-top: 30px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
transition: all 300ms;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-wrapper button:hover {
|
||||
opacity: .8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<form action="{{$saltpay_data['action_url']}}" method="post" id="borgun_payment_form">
|
||||
<input type="hidden" name="merchantid" value="{{$saltpay_data['merchantid']}}">
|
||||
<input type="hidden" name="paymentgatewayid" value="{{$saltpay_data['gateway_id']}}">
|
||||
<input type="hidden" name="checkhash" value="{{$saltpay_data['checkhash']}}">
|
||||
<input type="hidden" name="orderid" value="{{$saltpay_data['order_id']}}">
|
||||
<input type="hidden" name="reference" value="{{$saltpay_data['reference']}}">
|
||||
<input type="hidden" name="currency" value="{{$saltpay_data['currency']}}">
|
||||
<input type="hidden" name="language" value="{{$saltpay_data['language']}}">
|
||||
<input type="hidden" name="buyeremail" value="{{$saltpay_data['email']}}">
|
||||
<input type="hidden" name="returnurlsuccess" value="{{ $saltpay_data['ipn_url']}}">
|
||||
<input type="hidden" name="returnurlsuccessserver" value="{{ $saltpay_data['ipn_url']}}">
|
||||
<input type="hidden" name="returnurlcancel" value="{{$saltpay_data['cancel_url']}}">
|
||||
<input type="hidden" name="returnurlerror" value="{{$saltpay_data['cancel_url']}}">
|
||||
<input type="hidden" name="amount" value="{{$saltpay_data['charge_amount']}}">
|
||||
<input type="hidden" name="pagetype" value="0">
|
||||
<input type="hidden" name="skipreceiptpage" value="1">
|
||||
|
||||
<input type="hidden" name="itemdescription_0" value="{{\Illuminate\Support\Str::limit($saltpay_data['title'],78)}}">
|
||||
<input type="hidden" name="itemcount_0" value="1">
|
||||
<input type="hidden" name="itemunitamount_0" value="{{$saltpay_data['charge_amount']}}">
|
||||
<input type="hidden" name="itemamount_0" value="{{$saltpay_data['charge_amount']}}">
|
||||
<input type="submit" class="button" id="payment_submit_btn" value="{{__('Pay via SaltPay')}}">
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
(function($){
|
||||
"use strict";
|
||||
// Create a Stripe client
|
||||
var submitBtn = document.getElementById('payment_submit_btn');
|
||||
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
|
||||
submitBtn.addEventListener('click', function () {
|
||||
// Create a new Checkout Session using the server-side endpoint you
|
||||
submitBtn.value = "{{__('Redirecting....')}}"
|
||||
// submitBtn.disabled = true;
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
});
|
||||
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<html>
|
||||
<head>
|
||||
<title> {{__('Stripe Payment Gateway')}}</title>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="stripe-payment-wrapper">
|
||||
<div class="srtipe-payment-inner-wrapper">
|
||||
<input type="hidden" name="order_id" id="order_id_input" value="{{$stripe_data['order_id']}}"/>
|
||||
<form id="stripe_form">
|
||||
@foreach($stripe_data as $field_name => $value)
|
||||
<input type="hidden" name="{{$field_name}}" value="{{$value}}"/>
|
||||
@endforeach
|
||||
</form>
|
||||
<div class="btn-wrapper">
|
||||
<button id="payment_submit_btn"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function($){
|
||||
"use strict";
|
||||
// Create a Stripe client
|
||||
var stripe = Stripe("{{$stripe_data['public_key']}}");
|
||||
var orderID = document.getElementById('order_id_input').value;
|
||||
var submitBtn = document.getElementById('payment_submit_btn');
|
||||
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new Event('click'));
|
||||
},false);
|
||||
|
||||
|
||||
submitBtn.addEventListener('click', function () {
|
||||
// Create a new Checkout Session using the server-side endpoint you
|
||||
submitBtn.innerText = "{{__('Redirecting..')}}"
|
||||
submitBtn.disabled = true;
|
||||
var form = document.getElementById('stripe_form');
|
||||
var formData = new FormData(form);
|
||||
// created in step 3.
|
||||
fetch("{{route('xg.payment.gateway.stripe')}}", {
|
||||
headers: {
|
||||
"X-CSRF-TOKEN" : "{{csrf_token()}}",
|
||||
},
|
||||
method: 'POST',
|
||||
processData:false,
|
||||
contentType: false,
|
||||
body: formData
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (session) {
|
||||
if(session.hasOwnProperty('msg')){
|
||||
alert(session.msg);
|
||||
//redirect to cancel page ==
|
||||
window.location = document.querySelector('input[name="cancel_url"]').value;
|
||||
}
|
||||
return stripe.redirectToCheckout({sessionId: session.id});
|
||||
})
|
||||
.then(function (result) {
|
||||
// If `redirectToCheckout` fails due to a browser or network
|
||||
// error, you should display the localized error message to your
|
||||
// customer using `error.message`.
|
||||
if (result.error) {
|
||||
alert(result.error.message);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{{__('Zitopay Payment Gateway')}}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{--@dd($args)--}}
|
||||
<form class="redirectForm" method="post" action="https://zitopay.africa/sci">
|
||||
<input type='hidden' name='amount' value='{{$args['amount']}}' />
|
||||
<input type='hidden' name='currency' value='{{$args['currency']}}' />
|
||||
<input type='hidden' name='receiver' value='{{$args['username']}}' />
|
||||
<input type='hidden' name='ref' value='{{$args['payment_type']."_#".$args['order_id']}}' />
|
||||
<input type='hidden' name='success_url' value='{{$args['success_url']}}' />
|
||||
<input type='hidden' name='cancel_url' value='{{$args['cancel_url']}}' />
|
||||
<input type='hidden' name='memo' value='{{$args['description']}}' />
|
||||
{{-- payment description is called as memo--}}
|
||||
<input type='hidden' name='notification_url' value='{{$args['ipn_url']}}' />
|
||||
{{-- When a transaction has been completed, the transaction reference (under an HTTP POST key 'ref') will be posted to this url (even before the payer gets redirected to the success_url or cancel_url).--}}
|
||||
{{-- It is then advisable to rather perform all the needed confirmation check & updates on this urlF--}}
|
||||
|
||||
|
||||
<button type="submit" id="paymentbutton" class="btn btn-block btn-lg bg-ore continue-payment">Continue to Payment</button>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
(function(){
|
||||
"use strict";
|
||||
var submitBtn = document.querySelector('#paymentbutton');
|
||||
submitBtn.innerHTML = "{{__('Redirecting Please Wait...')}}";
|
||||
submitBtn.style.color = "#fff";
|
||||
submitBtn.style.backgroundColor = "#c54949";
|
||||
submitBtn.style.border = "none";
|
||||
document.addEventListener('DOMContentLoaded',function (){
|
||||
submitBtn.dispatchEvent(new MouseEvent('click'));
|
||||
},false);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| paymentgateway Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register routes for your package.
|
||||
|
|
||||
*/
|
||||
|
||||
/* ----------------------------------------
|
||||
STRIPE ROUTE
|
||||
---------------------------------------- */
|
||||
Route::group(['middleware' => 'web'],function (){
|
||||
/**
|
||||
* STRIPE PAYMENT ROUTE
|
||||
* */
|
||||
Route::post('xgpayment-gateway/powertransz',[\Xgenious\Paymentgateway\Http\Controllers\PowertranszPaymentController::class,'charge_customer'])
|
||||
->name('xg.payment.gateway.powertransz');
|
||||
Route::post('xgpayment-gateway/authorizenet',[\Xgenious\Paymentgateway\Http\Controllers\AuthorizeNetPaymentController::class,'charge_customer'])
|
||||
->name('xg.payment.gateway.authorizenet');
|
||||
Route::post('xgpayment-gateway/stipe',[\Xgenious\Paymentgateway\Http\Controllers\StripePaymentController::class,'charge_customer'])
|
||||
->name('xg.payment.gateway.stripe');
|
||||
Route::post('xgpayment-gateway/paystack',[\Xgenious\Paymentgateway\Http\Controllers\PaystackPaymentController::class,'redirect_to_gateway'])
|
||||
->name('xg.payment.gateway.paystack');
|
||||
Route::get('xgpayment-gateway/paystack-callback',[\Xgenious\Paymentgateway\Http\Controllers\PaystackPaymentController::class,'callback'])
|
||||
->name('xg.payment.gateway.paystack.callback');
|
||||
});
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Srmklive\PayPal\Services\PayPal as PayPalClient;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use net\authorize\api\contract\v1 as AnetAPI;
|
||||
use net\authorize\api\controller as AnetController;
|
||||
|
||||
class AuthorizeDotNetPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport,ConvertUsdSupport;
|
||||
protected $merchant_login_id;
|
||||
protected $merchant_transaction_id;
|
||||
|
||||
/* get getMerchantLoginId */
|
||||
private function getMerchantLoginId(){
|
||||
return $this->merchant_login_id;
|
||||
}
|
||||
/* set setMerchantLoginId */
|
||||
public function setMerchantLoginId($merchant_login_id){
|
||||
$this->merchant_login_id = $merchant_login_id;
|
||||
return $this;
|
||||
}
|
||||
/* set setMerchantTransactionId */
|
||||
public function setMerchantTransactionId($merchant_transaction_id){
|
||||
$this->merchant_transaction_id = $merchant_transaction_id;
|
||||
return $this;
|
||||
}
|
||||
/* get getMerchantTransactionId */
|
||||
private function getMerchantTransactionId(){
|
||||
return $this->merchant_transaction_id;
|
||||
}
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for paypal
|
||||
* */
|
||||
|
||||
public function view($args){
|
||||
return view('paymentgateway::authorizenet', ['authorizenet_data' => array_merge($args,[
|
||||
'merchant_login_id' => Crypt::encrypt($this->getMerchantLoginId()),
|
||||
'currency' => $this->getCurrency(),
|
||||
'merchant_transaction_id' => Crypt::encrypt($this->getMerchantTransactionId()),
|
||||
'charge_amount' => $this->charge_amount($args['amount']),
|
||||
'environment' => $this->getEnv(),
|
||||
'order_id' => PaymentGatewayHelpers::wrapped_id($args['order_id'])
|
||||
])]);
|
||||
}
|
||||
public function charge_customer($args)
|
||||
{
|
||||
return $this->view($args);
|
||||
//todo:: format data for send in blade file for get user card details
|
||||
}
|
||||
public function charge_customer_from_controller()
|
||||
{
|
||||
$input = request()->input();
|
||||
|
||||
/* Create a merchantAuthenticationType object with authentication details
|
||||
retrieved from the constants file */
|
||||
$merchant_transaction_id = \Crypt::decrypt(request()->merchant_transaction_id);
|
||||
$merchant_login_id = \Crypt::decrypt(request()->merchant_login_id);
|
||||
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
|
||||
$merchantAuthentication->setName($merchant_login_id);
|
||||
$merchantAuthentication->setTransactionKey($merchant_transaction_id);
|
||||
|
||||
|
||||
|
||||
// Set the transaction's refId
|
||||
$refId = 'ref' . time();
|
||||
$cardNumber = preg_replace('/\s+/', '', $input['number']);
|
||||
//dd($cardNumber,request()->all(),request()->get('expiry'),explode('/',request()->get('expiry')));
|
||||
// Create the payment data for a credit card
|
||||
$creditCard = new AnetAPI\CreditCardType();
|
||||
$creditCard->setCardNumber($cardNumber);
|
||||
$card_date = explode('/',request()->get('expiry'));
|
||||
$expiration_month = trim($card_date[0]); //detect if year value is full number like 2024 get only last two digit¥¥¥¥¥¥¥¥^-09oi87uy68uy6t5rewqsdw34e5
|
||||
$expiration_year = strlen(trim($card_date[1])) == 4 ? trim($card_date[1]) : '20'.trim($card_date[1]);
|
||||
$expiration_date = $expiration_year. "-" .$expiration_month;
|
||||
$creditCard->setExpirationDate($expiration_date);
|
||||
$creditCard->setCardCode($input['cvc']);
|
||||
|
||||
// Add the payment data to a paymentType object
|
||||
$paymentOne = new AnetAPI\PaymentType();
|
||||
$paymentOne->setCreditCard($creditCard);
|
||||
|
||||
// Create a TransactionRequestType object and add the previous objects to it
|
||||
$transactionRequestType = new AnetAPI\TransactionRequestType();
|
||||
$transactionRequestType->setTransactionType("authCaptureTransaction");
|
||||
$transactionRequestType->setAmount($input['charge_amount']);
|
||||
$transactionRequestType->setPayment($paymentOne);
|
||||
$transactionRequestType->setCurrencyCode($input['currency']);
|
||||
|
||||
// Assemble the complete transaction request
|
||||
$requests = new AnetAPI\CreateTransactionRequest();
|
||||
$requests->setMerchantAuthentication($merchantAuthentication);
|
||||
$requests->setRefId($refId);
|
||||
$requests->setTransactionRequest($transactionRequestType);
|
||||
|
||||
// Create the controller and get the response
|
||||
$controller = new AnetController\CreateTransactionController($requests);
|
||||
$Environment = $input['environment'] ? \net\authorize\api\constants\ANetEnvironment::SANDBOX: \net\authorize\api\constants\ANetEnvironment::PRODUCTION;
|
||||
$response = $controller->executeWithApiResponse($Environment);
|
||||
if ($response != null) {
|
||||
// Check to see if the API request was successfully received and acted upon
|
||||
if ($response->getMessages()->getResultCode() == "Ok") {
|
||||
// Since the API request was successful, look for a transaction response
|
||||
// and parse it to display the results of authorizing the card
|
||||
$tresponse = $response->getTransactionResponse();
|
||||
|
||||
if ($tresponse != null && $tresponse->getMessages() != null) {
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $tresponse->getTransId(),
|
||||
'status' => 'complete',
|
||||
'order_id' => $input['order_id']
|
||||
]);
|
||||
|
||||
} else {
|
||||
$message = __('There were some issue with the payment. Please try again later.');
|
||||
if ($tresponse->getErrors() != null) {
|
||||
$message = $tresponse->getErrors()[0]->getErrorText();
|
||||
}
|
||||
abort(500,$message);
|
||||
}
|
||||
// Or, print errors if the API request wasn't successful
|
||||
} else {
|
||||
$message_text = 'There were some issue with the payment. Please try again later.';
|
||||
$msg_type = "error_msg";
|
||||
|
||||
$tresponse = $response->getTransactionResponse();
|
||||
|
||||
if ($tresponse != null && $tresponse->getErrors() != null) {
|
||||
$message_text = $tresponse->getErrors()[0]->getErrorText();
|
||||
} else {
|
||||
$message_text = $response->getMessages()->getMessage()[0]->getText();
|
||||
}
|
||||
abort(500,$message_text);
|
||||
}
|
||||
}
|
||||
return $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id(request()->get('order_id'))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
$transaction_id = request()->transaction_id;
|
||||
/* Create a merchantAuthenticationType object with authentication details
|
||||
retrieved from the constants file */
|
||||
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
|
||||
$merchantAuthentication->setName($this->getMerchantLoginId());
|
||||
$merchantAuthentication->setTransactionKey($this->getMerchantTransactionId());
|
||||
|
||||
// Set the transaction's refId
|
||||
// The refId is a Merchant-assigned reference ID for the request.
|
||||
// If included in the request, this value is included in the response.
|
||||
// This feature might be especially useful for multi-threaded applications.
|
||||
$refId = 'ref' . time();
|
||||
|
||||
$request = new AnetAPI\GetTransactionDetailsRequest();
|
||||
$request->setMerchantAuthentication($merchantAuthentication);
|
||||
$request->setTransId($transaction_id);
|
||||
|
||||
$controller = new AnetController\GetTransactionDetailsController($request);
|
||||
$Environment = $this->getEnv() ? \net\authorize\api\constants\ANetEnvironment::SANDBOX: \net\authorize\api\constants\ANetEnvironment::PRODUCTION;
|
||||
$response = $controller->executeWithApiResponse( $Environment);
|
||||
|
||||
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok"))
|
||||
{
|
||||
// echo "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n";
|
||||
// echo " Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n";
|
||||
// echo " Trans ID:" . $response->getTransaction()->getTransId() . "\n";
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $response->getTransaction()->getTransId() ,
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id(request()->get('order_id')),
|
||||
'order_type' => request()->get('order_type')
|
||||
]);
|
||||
}
|
||||
return $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id(request()->get('order_id')),
|
||||
'order_type' => request()->get('payment_type')
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'authorizenet';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return ['AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'SEK', 'USD', 'ZAR'];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Billplz\Laravel\Billplz;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\MyanmarCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Billplz\Signature;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BillPlzPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,MyanmarCurrencySupport,PaymentEnvironment;
|
||||
public $key;
|
||||
public $version;
|
||||
public $x_signature;
|
||||
public $collection_name;
|
||||
|
||||
|
||||
public function getCollectionName(){
|
||||
return $this->collection_name;
|
||||
}
|
||||
public function setCollectionName($collection_name){
|
||||
$this->collection_name = $collection_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKey(){
|
||||
return $this->key;
|
||||
}
|
||||
public function setKey($key){
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVersion(){
|
||||
return $this->version;
|
||||
}
|
||||
public function setVersion($version){
|
||||
$this->version = $version;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getXsignature(){
|
||||
return $this->x_signature;
|
||||
}
|
||||
public function setXsignature($x_signature){
|
||||
$this->x_signature = $x_signature;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount * 100;
|
||||
}
|
||||
return $this->get_amount_in_myr($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$signature = new Signature($this->getXsignature(), Signature::WEBHOOK_PARAMETERS);
|
||||
$x_signature = $signature->create(request()->all());
|
||||
|
||||
$oder_id = Str::after(request()->get('name'),'ID#');
|
||||
if (hash_equals($x_signature,request()->get('x_signature')) && request()->get('paid') === 'true'){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => request()->id,
|
||||
'order_id' => substr( $oder_id,5,-5) ,
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed','order_id' => substr( $oder_id,5,-5) ];
|
||||
}
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$this->setConfigration();
|
||||
try {
|
||||
$bill = Billplz::bill()->create(
|
||||
$this->getCollectionName(),
|
||||
$args['email'],
|
||||
$args['phone'] ?? '',
|
||||
$args['name'].' id#'.PaymentGatewayHelpers::wrapped_id($args['order_id']),
|
||||
$this->charge_amount($args['amount']),
|
||||
$args['ipn_url'],
|
||||
$args['description'],
|
||||
[
|
||||
'redirect_url' => $args['success_url'],
|
||||
]
|
||||
);
|
||||
$arry = $bill->toArray();
|
||||
Session::put('billplz_order_id',PaymentGatewayHelpers::wrapped_id($args['order_id']));
|
||||
return redirect()->to($arry['url']);
|
||||
}catch (\Exception $e){
|
||||
abort(501,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['MYR'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
return 'MYR';
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'billplz';
|
||||
}
|
||||
|
||||
protected function setConfigration() : void
|
||||
{
|
||||
Config::set([
|
||||
'services.billplz.key' => $this->getKey(),
|
||||
'services.billplz.version' => $this->getVersion(),
|
||||
'services.billplz.x-signature' => $this->getXsignature(),
|
||||
'services.billplz.sandbox' => $this->getEnv(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
|
||||
class CashFreePay extends PaymentGatewayBase
|
||||
{
|
||||
use IndianCurrencySupport,CurrencySupport,PaymentEnvironment;
|
||||
|
||||
protected $app_id;
|
||||
protected $secret_key;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_inr($amount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$config_data = $this->setConfig();
|
||||
$secretKey = $config_data['secret_key'];
|
||||
$orderId = request()->get('orderId');
|
||||
$orderAmount = request()->get('orderAmount');
|
||||
$referenceId = request()->get('referenceId');
|
||||
$txStatus = request()->get('txStatus');
|
||||
$paymentMode = request()->get('paymentMode');
|
||||
$txMsg = request()->get('txMsg');
|
||||
$txTime = request()->get('txTime');
|
||||
$signature = request()->get('signature');
|
||||
|
||||
$data = $orderId . $orderAmount . $referenceId . $txStatus . $paymentMode . $txMsg . $txTime;
|
||||
$hash_hmac = hash_hmac('sha256', $data, $secretKey, true);
|
||||
$computedSignature = base64_encode($hash_hmac);
|
||||
|
||||
if ($computedSignature === $signature && request()->txStatus === 'SUCCESS'){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => request()->referenceId,
|
||||
'order_id' => substr( request()->get('orderId'),5,-5) ,
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$config_data = $this->setConfig();
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
$postData = array(
|
||||
"appId" => $config_data['app_id'],
|
||||
"orderId" => $order_id,
|
||||
"orderAmount" => round((float)$this->charge_amount($args['amount']),2),
|
||||
"orderCurrency" => "INR",
|
||||
"orderNote" => $order_id,
|
||||
"customerName" => $args['name'],
|
||||
"customerPhone" => random_int(9999999999999,9999999999999),
|
||||
"customerEmail" => $args['email'],
|
||||
"returnUrl" => $args['ipn_url'],
|
||||
"notifyUrl" => null,
|
||||
);
|
||||
|
||||
ksort($postData);
|
||||
|
||||
$signatureData = "";
|
||||
foreach ( $postData as $key => $value) {
|
||||
$signatureData .= $key . $value;
|
||||
}
|
||||
$signature = hash_hmac('sha256', $signatureData, $config_data['secret_key'], true);
|
||||
$signature = base64_encode($signature);
|
||||
$data = [
|
||||
'action' => $config_data['action'],
|
||||
'app_id' => $config_data['app_id'],
|
||||
'order_id' => $order_id,
|
||||
'amount' => round((float)$this->charge_amount($args['amount']),2),
|
||||
'currency' => "INR",
|
||||
'name' => $args['name'],
|
||||
'email' => $args['email'],
|
||||
'phone' => random_int(9999999999999,9999999999999),
|
||||
'signature' => $signature,
|
||||
"return_url" => $args['ipn_url'],
|
||||
"notify_url" => null,
|
||||
];
|
||||
return view('paymentgateway::cashfree',['payment_data' => $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['INR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "INR";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'cashfree';
|
||||
}
|
||||
|
||||
/* set app id */
|
||||
public function setAppId($app_id){
|
||||
$this->app_id = $app_id;
|
||||
return $this;
|
||||
}
|
||||
/* set app secret */
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
/* get app id */
|
||||
private function getAppId(){
|
||||
return $this->app_id;
|
||||
}
|
||||
/* get secret key */
|
||||
private function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
|
||||
protected function setConfig() : array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->getAppId(),
|
||||
'secret_key' => $this->getSecretKey(),
|
||||
'order_currency' => 'INR',
|
||||
'action' => $this->get_api_url()
|
||||
];
|
||||
}
|
||||
|
||||
public function get_api_url(){
|
||||
return $this->getEnv() ?
|
||||
'https://test.cashfree.com/billpay/checkout/post/submit' :
|
||||
'https://www.cashfree.com/checkout/post/submit';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use CinetPay\CinetPay as CinetPayment;
|
||||
|
||||
class CinetPay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
use CurrencySupport,PaymentEnvironment,ConvertUsdSupport;
|
||||
|
||||
protected $app_key;
|
||||
protected $site_id;
|
||||
|
||||
public function setAppKey($app_key){
|
||||
$this->app_key = $app_key;
|
||||
return $this;
|
||||
}
|
||||
public function getAppKey(){
|
||||
return $this->app_key;
|
||||
}
|
||||
public function setSiteId($site_id){
|
||||
$this->site_id = $site_id;
|
||||
return $this;
|
||||
}
|
||||
public function getSiteId(){
|
||||
return $this->site_id;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$id_transaction = request()->cpm_trans_id;
|
||||
if (!empty($id_transaction)) {
|
||||
try {
|
||||
$cp = $this->setConfig();
|
||||
|
||||
// Reprise exacte des bonnes données chez CinetPay
|
||||
$payment_status = $cp->setTransId($id_transaction)->getPayStatus();
|
||||
$paymentData = [
|
||||
"cpm_site_id" => $cp->_cpm_site_id,
|
||||
"signature" => $cp->_signature,
|
||||
"cpm_amount" => $cp->_cpm_amount,
|
||||
"cpm_trans_id" => $cp->_cpm_trans_id,
|
||||
"cpm_custom" => $cp->_cpm_custom,
|
||||
"cpm_currency" => $cp->_cpm_currency,
|
||||
"cpm_payid" => $cp->_cpm_payid,
|
||||
"cpm_payment_date" => $cp->_cpm_payment_date,
|
||||
"cpm_payment_time" => $cp->_cpm_payment_time,
|
||||
"cpm_error_message" => $cp->_cpm_error_message,
|
||||
"payment_method" => $cp->_payment_method,
|
||||
"cpm_phone_prefixe" => $cp->_cpm_phone_prefixe,
|
||||
"cel_phone_num" => $cp->_cel_phone_num,
|
||||
"cpm_ipn_ack" => $cp->_cpm_ipn_ack,
|
||||
"created_at" => $cp->_created_at,
|
||||
"updated_at" => $cp->_updated_at,
|
||||
"cpm_result" => $cp->_cpm_result,
|
||||
"cpm_trans_status" => $cp->_cpm_trans_status,
|
||||
"cpm_designation" => $cp->_cpm_designation,
|
||||
"buyer_name" => $cp->_buyer_name,
|
||||
];
|
||||
if ($cp->isValidPayment()) {
|
||||
if (isset($paymentData['cpm_trans_status']) && $paymentData['cpm_trans_status'] === 'ACCEPTED') {
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $paymentData['cpm_payid'],
|
||||
'order_id' => substr($paymentData['cpm_custom'],5,-5)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Une erreur s'est produite
|
||||
return "Erreur :" . $e->getMessage();
|
||||
}
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
if($this->charge_amount($args['amount']) < 100 && !in_array("USD",[$this->getCurrency()])){
|
||||
abort(402,__('amount must be getter than 100'));
|
||||
}
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
|
||||
$id_transaction = CinetPayment::generateTransId(); // Identifiant du Paiement
|
||||
$description_du_paiement = $args['description']; // Description du Payment
|
||||
$date_transaction = date("Y-m-d H:i:s"); // Date Paiement dans votre système
|
||||
$montant_a_payer = $this->charge_amount($args['amount']); // Montant à Payer : minimun est de 100 francs sur CinetPay
|
||||
$devise = $this->getCurrency();//'XOF'; // Montant à Payer : minimun est de 100 francs sur CinetPay
|
||||
$identifiant_du_payeur = $order_id; // Mettez ici une information qui vous permettra d'identifier de façon unique le payeur
|
||||
$formName = "goCinetPay"; // nom du formulaire CinetPay
|
||||
$notify_url = $args['ipn_url']; // notification CallBack CinetPay (IPN Link)
|
||||
$return_url = $args['ipn_url'];//cinetpay redirect this url after successfully payment
|
||||
$cancel_url = $args['cancel_url']; // cancel url, where cinet pay will redirect after cancel payment
|
||||
|
||||
$btnType = 2;//1-5xwxxw
|
||||
$btnSize = 'large'; // 'small' pour reduire la taille du bouton, 'large' pour une taille moyenne ou 'larger' pour une taille plus grande
|
||||
|
||||
try{
|
||||
$cp = $this->setConfig();
|
||||
}catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
try {
|
||||
$cp->setTransId($id_transaction)
|
||||
->setDesignation($description_du_paiement)
|
||||
->setTransDate($date_transaction)
|
||||
->setAmount($montant_a_payer)
|
||||
->setCurrency($devise)
|
||||
->setDebug($this->getEnv())// Valorisé à true, si vous voulez activer le mode debug sur cinetpay afin d'afficher toutes les variables envoyées chez CinetPay
|
||||
->setCustom($identifiant_du_payeur)// optional
|
||||
->setNotifyUrl($notify_url)// optional
|
||||
->setReturnUrl($return_url)// optional
|
||||
->setCancelUrl($cancel_url);// optional
|
||||
return view('paymentgateway::cinetpay',[
|
||||
'payButton' => $cp->getPayButton($formName, $btnType, $btnSize)
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private function setConfig(){
|
||||
return new CinetPayment($this->getSiteId(), $this->getAppKey());
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['XOF', 'XAF', 'CDF', 'GNF', 'USD'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'cinetpay';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class FlutterwavePay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
protected $public_key;
|
||||
protected $secret_key;
|
||||
|
||||
use PaymentEnvironment,CurrencySupport,ConvertUsdSupport;
|
||||
|
||||
public function setPublicKey($public_key){
|
||||
$this->public_key = $public_key;
|
||||
return $this;
|
||||
}
|
||||
public function getPublicKey(){
|
||||
return $this->public_key;
|
||||
}
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
public function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* /**
|
||||
* this payment gateway will not work without this package
|
||||
* @ https://github.com/kingflamez/laravelrave
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param ['status','transaction_id','order_id' ]
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$response = Http::withToken($this->getSecretKey())->get($this->getBaseUri() . "/transactions/" . request()->transaction_id . '/verify')->json();
|
||||
|
||||
$status = $response['status'] ?? '';
|
||||
|
||||
if ( $status === 'success'){
|
||||
$txRef = $response['data']['tx_ref'];
|
||||
$order_id = $response['data']['meta']['metavalue'];
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $txRef,
|
||||
'order_id' => substr( $order_id,5,-5) ,
|
||||
]);
|
||||
}
|
||||
|
||||
return ['status' => 'failed' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param ['amount','title','description' ,'ipn_url','order_id','track','cancel_url', 'success_url' ,'email','name','payment_type']
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
if(!in_array($this->getCurrency(),["NGN","XAF"]) && $this->charge_amount($args['amount']) > 1000){
|
||||
abort(405,__('We could not process your request due to your amount is higher than the maximum.'));
|
||||
}
|
||||
|
||||
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
// Enter the details of the payment
|
||||
$data = [
|
||||
'payment_options' => 'card,banktransfer',
|
||||
'amount' =>$this->charge_amount($args['amount']),
|
||||
'email' => $args['email'],
|
||||
'tx_ref' => $this->getTxRef(), // a unique number with uuid as a transaction reference
|
||||
'currency' => $this->charge_currency(),
|
||||
'redirect_url' => $args['ipn_url'],
|
||||
'customer' => [
|
||||
'email' => $args['email'],
|
||||
"name" => $args['name']
|
||||
],
|
||||
"customizations" => [
|
||||
"title" => null,
|
||||
"description" => $args['description']
|
||||
],
|
||||
'meta' => [
|
||||
'metaname' => 'order_id', 'metavalue' => $order_id,
|
||||
]
|
||||
];
|
||||
try {
|
||||
$payment = Http::withToken($this->getSecretKey())->post(
|
||||
$this->getBaseUri() . '/payments',
|
||||
$data
|
||||
)->json();
|
||||
}catch (\Exception $e){
|
||||
abort(500,$e->getMessage());
|
||||
}
|
||||
|
||||
return redirect($payment['data']['link']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['BIF', 'CAD', 'CDF', 'CVE', 'EUR', 'GBP', 'GHS', 'GMD', 'GNF', 'KES', 'LRD', 'MWK', 'MZN', 'NGN', 'RWF', 'SLL', 'STD', 'TZS', 'UGX', 'USD', 'XAF', 'XOF', 'ZMK', 'ZMW', 'ZWD'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'flutterwaverave';
|
||||
}
|
||||
|
||||
|
||||
private function getBaseUri(){
|
||||
return 'https://api.flutterwave.com/v3';
|
||||
}
|
||||
private function getTxRef(){
|
||||
return 'flw_' . uniqid(time());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Instamojo\Instamojo;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class InstamojoPay extends PaymentGatewayBase
|
||||
{
|
||||
use IndianCurrencySupport,CurrencySupport,PaymentEnvironment;
|
||||
|
||||
protected $client_id;
|
||||
protected $secret_key;
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_inr($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$payment_id = request()->get('payment_id');
|
||||
$payment_request_id = request()->get('payment_request_id');
|
||||
$api_token = $this->setConfig();
|
||||
$result = Http::asForm()
|
||||
->withToken($api_token)
|
||||
->acceptJson()
|
||||
->get($this->base_url() . 'v2/payment_requests/' . $payment_request_id);
|
||||
$response = $result->object();
|
||||
|
||||
if ($result->ok() && property_exists($response, 'status') && $response->status === 'Completed') {
|
||||
$order_id = Str::of($response->purpose)->after('_ID_')->trim()->__toString();
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $payment_id,
|
||||
'order_id' => substr($order_id,5,-5)
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$api_token = $this->setConfig();
|
||||
$charge_amount = $this->charge_amount($args['amount']);
|
||||
$order_id = random_int(01234, 99999) . $args['order_id'] . random_int(01234, 99999); // not required to mask order for this payment gateway
|
||||
$response = Http::asForm()
|
||||
->acceptJson()
|
||||
->withToken($api_token)
|
||||
->post($this->base_url() . 'v2/payment_requests/', [
|
||||
'purpose' => $args['payment_type'] . '_ID_' . $order_id,
|
||||
'amount' => $charge_amount,
|
||||
'buyer_name' => $args['name'],
|
||||
'email' => $args['email'],
|
||||
// 'phone' => $args['phone'] ?? random_int(123456789,999999999), //mobile number support will be available in future
|
||||
'redirect_url' => $args['ipn_url'],
|
||||
'send_email' => 'True',
|
||||
'send_sms' => 'False', //mobile number support will be available in future
|
||||
// 'webhook' => '', //webhook option will be avilable in future
|
||||
'allow_repeated_payments' => 'False',
|
||||
]);
|
||||
$res_body = $response->object();
|
||||
if (property_exists($res_body, 'longurl')) {
|
||||
return redirect()->away($response->object()->longurl);
|
||||
} else {
|
||||
abort(405, 'something went wrong! , check your instamojo credentials were correct or not.');
|
||||
}
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['INR'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "INR";
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'instamojo';
|
||||
}
|
||||
|
||||
protected function base_url()
|
||||
{
|
||||
$prefix = $this->getEnv() ? 'test' : 'api';
|
||||
return 'https://' . $prefix . '.instamojo.com/';
|
||||
}
|
||||
|
||||
/* set app id */
|
||||
public function setClientId($client_id){
|
||||
$this->client_id = $client_id;
|
||||
return $this;
|
||||
}
|
||||
/* set app secret */
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
/* get app id */
|
||||
private function getClientId(){
|
||||
return $this->client_id;
|
||||
}
|
||||
/* get secret key */
|
||||
private function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
|
||||
protected function setConfig()
|
||||
{
|
||||
|
||||
$response = Http::asForm()
|
||||
->withBasicAuth($this->getClientId(), $this->getSecretKey())
|
||||
->post($this->base_url() . 'oauth2/token/', [
|
||||
'grant_type' => 'client_credentials',
|
||||
]);
|
||||
if ($response->ok()) {
|
||||
return $response->object()->access_token;
|
||||
}
|
||||
$response->throw();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
use Iyzipay\Options;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\LocationSupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class Iyzipay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment, CurrencySupport, ConvertUsdSupport,LocationSupport;
|
||||
|
||||
private $apiKey;
|
||||
private $secretKay;
|
||||
|
||||
|
||||
|
||||
public function setSecretKey($secretKay)
|
||||
{
|
||||
$this->secretKay = $secretKay;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecretKey()
|
||||
{
|
||||
return $this->secretKay;
|
||||
}
|
||||
|
||||
public function setApiKey($apiKey)
|
||||
{
|
||||
$this->apiKey = $apiKey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApiKey()
|
||||
{
|
||||
return $this->apiKey;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return number_format($amount,2);
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$locationDetails = $this->getLocationDetails(request()->ip());
|
||||
$options = new Options();
|
||||
$options->setApiKey($this->getApiKey());
|
||||
$options->setSecretKey($this->getSecretKey());
|
||||
$options->setBaseUrl($this->baseApiUrl());
|
||||
|
||||
# create request class
|
||||
$request = new \Iyzipay\Request\CreatePayWithIyzicoInitializeRequest();
|
||||
$request->setLocale(\Iyzipay\Model\Locale::EN);
|
||||
$request->setConversationId(PaymentGatewayHelpers::wrapped_id($args['order_id'])); //order id
|
||||
$request->setPrice($this->charge_amount($args['amount'])); //price
|
||||
$request->setPaidPrice($this->charge_amount($args['amount'])); //price
|
||||
$request->setCurrency($this->getCurrency());
|
||||
$request->setBasketId($args['payment_type']."__".PaymentGatewayHelpers::wrapped_id($args['order_id'])); //order id with payment type
|
||||
$request->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
|
||||
$request->setCallbackUrl($args['ipn_url']); //set a get callback
|
||||
|
||||
$buyer = new \Iyzipay\Model\Buyer();
|
||||
$buyer->setId("___".($args['payment_type'] ?? 'Unknown'));
|
||||
$buyer->setName($args['name']);
|
||||
$buyer->setSurname(".");
|
||||
// $buyer->setGsmNumber("+905350000000");
|
||||
$buyer->setEmail($args['email']);
|
||||
$buyer->setIdentityNumber("11111111111");//dummy number
|
||||
$buyer->setLastLoginDate("2018-07-06 11:11:11");//dummy date
|
||||
$buyer->setRegistrationDate("2018-07-06 11:11:11"); //dummy date
|
||||
$buyer->setRegistrationAddress("unknown");
|
||||
$buyer->setIp(request()->ip());
|
||||
$buyer->setCity($locationDetails['city']);
|
||||
$buyer->setCountry($locationDetails['country']);
|
||||
// $buyer->setZipCode("34732");
|
||||
$request->setBuyer($buyer);
|
||||
|
||||
$billingAddress = new \Iyzipay\Model\Address();
|
||||
$billingAddress->setContactName($args['name']);
|
||||
$billingAddress->setCity($locationDetails['city']);
|
||||
$billingAddress->setCountry($locationDetails['country']);
|
||||
$billingAddress->setAddress("Unknown");
|
||||
// $billingAddress->setZipCode("34742");
|
||||
$request->setBillingAddress($billingAddress);
|
||||
|
||||
$basketItems = array();
|
||||
$firstBasketItem = new \Iyzipay\Model\BasketItem();
|
||||
$firstBasketItem->setId($args['payment_type']."__".PaymentGatewayHelpers::wrapped_id($args['order_id']));
|
||||
$firstBasketItem->setName($args['title']);
|
||||
$firstBasketItem->setCategory1(($args['payment_type'] ?? 'Unknown'));
|
||||
$firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::VIRTUAL);
|
||||
$firstBasketItem->setPrice($this->charge_amount($args['amount']));
|
||||
$basketItems[0] = $firstBasketItem;
|
||||
$request->setBasketItems($basketItems);
|
||||
|
||||
# make request
|
||||
$payWithIyzicoInitialize = \Iyzipay\Model\PayWithIyzicoInitialize::create($request, $options);
|
||||
if ($payWithIyzicoInitialize->getStatus() === 'success'){
|
||||
return redirect()->away($payWithIyzicoInitialize->getPayWithIyzicoPageUrl());
|
||||
}
|
||||
return redirect()->to($args['cancel_url']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = [])
|
||||
{
|
||||
|
||||
|
||||
|
||||
$options = new Options();
|
||||
$options->setApiKey($this->getApiKey());
|
||||
$options->setSecretKey($this->getSecretKey());
|
||||
$options->setBaseUrl($this->baseApiUrl());
|
||||
|
||||
# create request class
|
||||
$token = request()->get('token');
|
||||
$request = new \Iyzipay\Request\RetrievePayWithIyzicoRequest();
|
||||
$request->setLocale(\Iyzipay\Model\Locale::EN);
|
||||
$request->setToken($token);
|
||||
# make request
|
||||
$payWithIyzico = \Iyzipay\Model\PayWithIyzico::retrieve($request,$options);
|
||||
|
||||
if ($payWithIyzico->getStatus() === 'success'){
|
||||
$order_id = is_array($payWithIyzico->getPaymentItems()) && count($payWithIyzico->getPaymentItems()) > 0 ? Str::of(current($payWithIyzico->getPaymentItems())?->getItemId())->after('__')->toString() : 'unknown';
|
||||
$order_type = is_array($payWithIyzico->getPaymentItems()) && count($payWithIyzico->getPaymentItems()) > 0 ? Str::of(current($payWithIyzico->getPaymentItems())?->getItemId())->before('__')->toString() : 'unknown';
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $payWithIyzico->getPaymentId(),
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id), //get order id
|
||||
'payment_type' => $order_type //todo:: return reference
|
||||
]);
|
||||
}
|
||||
return $this->verified_data([
|
||||
'status' => 'failed'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'iyzipay';
|
||||
}
|
||||
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "TRY";
|
||||
}
|
||||
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will return all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['TRY', 'USD', 'EUR', 'GBP','IRR','NOK','RUB','CHF'];
|
||||
}
|
||||
|
||||
private function baseApiUrl()
|
||||
{
|
||||
$prefix = $this->getEnv() ? 'sandbox-' : '';
|
||||
return "https://".$prefix."api.iyzipay.com";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\MyanmarCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
|
||||
class KineticPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,PaymentEnvironment,MyanmarCurrencySupport;
|
||||
protected $bank;
|
||||
protected $merchant_key;
|
||||
|
||||
public function setMerchantKey($merchant_key){
|
||||
$this->merchant_key = $merchant_key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMerchantKey(){
|
||||
return $this->merchant_key;
|
||||
}
|
||||
|
||||
public function setBank($bank){
|
||||
$this->bank = $bank;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBank(){
|
||||
return $this->bank;
|
||||
}
|
||||
|
||||
/**
|
||||
* to work this payment gateway you must have this laravel package
|
||||
* */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_myr($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* return array('status','transaction_id','order_id');
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
|
||||
$encoded_transaction_data = json_decode(request()['encoded_transaction_data']);
|
||||
$order_id = $encoded_transaction_data?->record?->order_number;
|
||||
if (empty($order_id)){
|
||||
abort(501, __("order id not found"));
|
||||
}
|
||||
|
||||
$url = "https://manage.kineticpay.my/payment/status";
|
||||
|
||||
|
||||
$res = Http::acceptJson()->get($url . '?merchant_key=' . $this->getMerchantKey() . '&invoice=' . (string) $order_id);
|
||||
|
||||
if ($res->ok()){
|
||||
|
||||
$result = $res->object();
|
||||
$order_id = $result->invoice ?? "";
|
||||
$transaction_id = $result->id ?? '';
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $transaction_id ,
|
||||
'order_id' => XgPaymentGateway::unwrapped_id($order_id ?? ""),
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
private function getBaseURL(){
|
||||
return 'https://manage.kineticpay.my/payment/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* return array()
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
|
||||
$charge_amount = round($this->charge_amount($args['amount']), 2);
|
||||
$order_id = XgPaymentGateway::wrapped_id($args['order_id']);
|
||||
|
||||
if (empty($this->getBank())){
|
||||
abort(501,__("you must have to select a bank for pay with kineticpay"));
|
||||
}
|
||||
if (empty($this->getMerchantKey())){
|
||||
abort(501,__("merchant key not provided"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'merchant_key' => $this->getMerchantKey(),
|
||||
'invoice' => $order_id,
|
||||
'amount' => $charge_amount,
|
||||
'description' => $args['description'],
|
||||
'bank' => $this->getBank(),
|
||||
'callback_success' => $args['ipn_url'], //POST URL
|
||||
'callback_error' => $args['cancel_url'],
|
||||
'callback_status' => $args['ipn_url']."?orderid=" . $order_id
|
||||
];
|
||||
|
||||
// API Endpoint URL
|
||||
$url = "https://manage.kineticpay.my/payment/create";
|
||||
$res = Http::acceptJson()->post($url,$data);
|
||||
$result = $res->object();
|
||||
if (is_object($result) && property_exists($result,"html")){
|
||||
return $result?->html;
|
||||
}
|
||||
|
||||
abort(501,__("failed to connect kineticpay server."));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['MYR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "MYR";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'kineticpay';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Parent_;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class MercadoPagoPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport;
|
||||
|
||||
protected $client_id;
|
||||
protected $client_secret;
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list(), true)){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_brl($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* get_amount_in_brl()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversation rate
|
||||
* */
|
||||
protected function get_amount_in_brl($amount){
|
||||
if ($this->getCurrency() === 'BRL'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_brl($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert amount to brl currency base on conversation given by admin
|
||||
* */
|
||||
protected function make_amount_in_brl($amount,$currency){
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'BRL') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = !empty($this->getExchangeRate()) ? $this->getExchangeRate() : config('paymentgateway.brl_exchange_rate');
|
||||
$output = $amount * $exchange_rate ;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$this->setAccessToken();
|
||||
$request = request();
|
||||
$return_status = $request->status;
|
||||
$return_merchant_order_id = $request->merchant_order_id;
|
||||
$return_payment_id = $request->payment_id;
|
||||
$payment_details = \MercadoPago\Payment::find_by_id($return_payment_id);
|
||||
$order_id = $payment_details->order->id;
|
||||
$payment_status = $payment_details->status;
|
||||
$payment_metadata =$payment_details->metadata;
|
||||
$payment_metadata_order_id =$payment_details->metadata->order_id;
|
||||
|
||||
if ($return_status === $payment_status && $return_merchant_order_id === $order_id){
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $return_payment_id,
|
||||
'order_id' => substr($payment_metadata_order_id,5,-5)
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
|
||||
$charge_amount = $this->charge_amount($args['amount']);
|
||||
$order_id = random_int(01234,99999).$args['order_id'].random_int(01234,99999);
|
||||
$this->setAccessToken();
|
||||
$preference = new \MercadoPago\Preference();
|
||||
# Building an item
|
||||
$item = new \MercadoPago\Item();
|
||||
$item->id = $order_id;
|
||||
$item->title = $args['title'];
|
||||
$item->quantity = 1;
|
||||
$item->unit_price = $charge_amount;
|
||||
|
||||
$preference->items = array($item);
|
||||
|
||||
$preference->back_urls = array(
|
||||
"success" => $args['ipn_url'],
|
||||
"failure" => $args['cancel_url'],
|
||||
"pending" => $args['cancel_url']
|
||||
);
|
||||
$preference->auto_return = "approved";
|
||||
$preference->metadata = array(
|
||||
"order_id" => $order_id,
|
||||
);
|
||||
$preference->save(); # Save the preference and send the HTTP Request to create
|
||||
|
||||
return redirect()->away($preference->init_point);
|
||||
|
||||
}
|
||||
protected function setAccessToken(){
|
||||
return \MercadoPago\SDK::setAccessToken($this->getClientSecret());
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['BRL','ARS','BOB','CLF','CLP','COP','CRC','CUC','CUP','DOP','EUR','GTQ','HNL','MXN','NIO','PAB','PEN','PYG','USD','UYU','VEF','VES'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "BRL";
|
||||
}
|
||||
|
||||
/* set app secret */
|
||||
public function setClientSecret($client_secret){
|
||||
$this->client_secret = $client_secret;
|
||||
return $this;
|
||||
}
|
||||
/* get app id */
|
||||
private function getClientSecret(){
|
||||
return $this->client_secret;
|
||||
}
|
||||
/* get app id */
|
||||
private function getClientId(){
|
||||
return $this->client_id ;
|
||||
}
|
||||
/* set app id */
|
||||
public function setClientId($client_id){
|
||||
$this->client_id = $client_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'mercadopago';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class MidtransPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport;
|
||||
|
||||
protected $server_key;
|
||||
protected $client_key;
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_idr($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert amount to idr currency base on conversation given by admin
|
||||
* */
|
||||
private function make_amount_in_idr($amount, $currency)
|
||||
{
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur == 'IDR') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* get_amount_in_idr()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversation rate
|
||||
* */
|
||||
protected function get_amount_in_idr($amount){
|
||||
if ($this->getCurrency() === 'IDR'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_idr($amount, $this->getCurrency() );
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for paypal
|
||||
* */
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
$this->setConfig([
|
||||
'order_id' => $order_id,
|
||||
'ipn_url' => $args['ipn_url']
|
||||
]);
|
||||
$params = array(
|
||||
'transaction_details' => array(
|
||||
'order_id' => $order_id,
|
||||
'gross_amount' => ceil($this->charge_amount($args['amount'])),
|
||||
),
|
||||
"callbacks" => [
|
||||
"finish" => $args['ipn_url']
|
||||
]
|
||||
);
|
||||
|
||||
session()->put('midtrans_last_order_id',$order_id);
|
||||
try {
|
||||
$paymentUrl = \Midtrans\Snap::createTransaction($params)->redirect_url;
|
||||
return redirect()->away($paymentUrl);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
$midtrans_last_order_id = session()->get('midtrans_last_order_id');
|
||||
session()->forget('midtrans_last_order_id');
|
||||
if (empty($midtrans_last_order_id)){
|
||||
abort(405,'midtrans order missing');
|
||||
}
|
||||
if ($midtrans_last_order_id !== request()->get('order_id')){
|
||||
abort(403);
|
||||
}
|
||||
$this->setConfig([
|
||||
'order_id' => $midtrans_last_order_id,
|
||||
'ipn_url' => $args['ipn_url'] ?? ''
|
||||
]);
|
||||
|
||||
$status = \Midtrans\Transaction::status($midtrans_last_order_id);
|
||||
$status_message = Str::contains($status->status_message,['Success']);
|
||||
if (in_array($status->transaction_status, ['settlement','capture']) && $status->fraud_status === 'accept' && $status_message ){
|
||||
return $this->verified_data(['transaction_id' => $status->transaction_id,'order_id' => substr($midtrans_last_order_id,5,-5)]);
|
||||
}
|
||||
|
||||
abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'midtrans';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "IDR";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return ['IDR'];
|
||||
}
|
||||
|
||||
/* set app id */
|
||||
public function setClientKey($client_key){
|
||||
$this->client_key = $client_key;
|
||||
return $this;
|
||||
}
|
||||
/* set app secret */
|
||||
public function setServerKey($server_key){
|
||||
$this->server_key = $server_key;
|
||||
return $this;
|
||||
}
|
||||
/* get app id */
|
||||
private function getClientKey(){
|
||||
return $this->client_key;
|
||||
}
|
||||
/* get secret key */
|
||||
private function getServerKey(){
|
||||
return $this->server_key;
|
||||
}
|
||||
|
||||
|
||||
private function setConfig(array $args = [])
|
||||
{
|
||||
// Set your Merchant Server Key
|
||||
\Midtrans\Config::$serverKey = $this->getServerKey();
|
||||
// Set to Development/Sandbox Environment (default). Set to true for Production Environment (accept real transaction).
|
||||
\Midtrans\Config::$isProduction = !$this->getEnv();
|
||||
// Set sanitization on (default)
|
||||
\Midtrans\Config::$isSanitized = true;
|
||||
// Set 3DS transaction for credit card to true
|
||||
\Midtrans\Config::$is3ds = true;
|
||||
\Midtrans\Config::$overrideNotifUrl = $args['ipn_url'];
|
||||
\Midtrans\Config::$paymentIdempotencyKey = $args['order_id'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Mollie\Laravel\Facades\Mollie;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class MolliePay extends PaymentGatewayBase
|
||||
{
|
||||
protected $api_key;
|
||||
|
||||
|
||||
public function setApiKey($key){
|
||||
$this->api_key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApiKey(){
|
||||
return $this->api_key;
|
||||
}
|
||||
|
||||
use PaymentEnvironment,CurrencySupport,ConvertUsdSupport;
|
||||
/**
|
||||
* to work this payment gateway you must have this laravel package
|
||||
* https://github.com/mollie/laravel-mollie
|
||||
* */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* return array('status','transaction_id','order_id');
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$this->setConfig();
|
||||
$payment_id = session()->get('mollie_payment_id');
|
||||
$payment = Mollie::api()->payments->get($payment_id);
|
||||
session()->forget('mollie_payment_id');
|
||||
|
||||
if ($payment->isPaid()) {
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $payment->id,
|
||||
'order_id' => substr($payment->metadata->order_id,5,-5)
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* return array()
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$this->setConfig();
|
||||
$charge_amount = round($this->charge_amount($args['amount']), 2);
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
try{
|
||||
$payment = Mollie::api()->payments->create([
|
||||
"amount" => [
|
||||
"currency" => $this->charge_currency(),
|
||||
"value" => number_format( $charge_amount, 2, '.', ''),//"10.00" // You must send the correct number of decimals, thus we enforce the use of strings
|
||||
],
|
||||
"description" => $args['description'],
|
||||
"redirectUrl" => $args['ipn_url'],
|
||||
"metadata" => [
|
||||
"order_id" => $order_id,
|
||||
"track" => $args['track'],
|
||||
],
|
||||
]);
|
||||
|
||||
}catch(\Exception $e){
|
||||
$msg = '';
|
||||
switch($e->getCode()){
|
||||
case(400):
|
||||
$msg = __('Bad Request – The Mollie API was unable to understand your request. There might be an error in your syntax.');
|
||||
break;
|
||||
case(401):
|
||||
$msg = __('Unauthorized – Your request was not executed due to failed authentication. Check your API key.');
|
||||
break;
|
||||
case(403):
|
||||
$msg = __('Forbidden – You do not have access to the requested resource.');
|
||||
break;
|
||||
case(404):
|
||||
$msg = __('Not Found – The object referenced by your URL does not exist.');
|
||||
break;
|
||||
case(405):
|
||||
$msg = __('Method Not Allowed – You are trying to use an HTTP method that is not applicable on this URL or resource. Refer to the Allow header to see which methods the endpoint supports.');
|
||||
break;
|
||||
case(409):
|
||||
$msg = __('Conflict – You are making a duplicate API call that was probably a mistake (only in v2).');
|
||||
break;
|
||||
case(410):
|
||||
$msg = __('Gone – You are trying to access an object, which has previously been deleted (only in v2).');
|
||||
break;
|
||||
case(415):
|
||||
$msg = __('Unsupported Media Type – Your request’s encoding is not supported or is incorrectly understood. Please always use JSON.');
|
||||
break;
|
||||
case(422):
|
||||
$msg = $e->getMessage();
|
||||
break;
|
||||
case(429):
|
||||
$msg = __('Too Many Requests – Your request has hit a rate limit. Please wait for a bit and retry.');
|
||||
break;
|
||||
case(500):
|
||||
$msg = __('Internal Server Error – An internal server error occurred while processing your request. Our developers are notified automatically, but if you have any information on how you triggered the problem, please contact us.');
|
||||
break;
|
||||
case(502):
|
||||
$msg = __('Bad Gateway – The service is temporarily unavailable, either due to calamity or (planned) maintenance. Please retry the request at a later time.');
|
||||
break;
|
||||
case(503):
|
||||
$msg = __('Service Unavailable – The service is temporarily unavailable, either due to calamity or (planned) maintenance. Please retry the request at a later time.');
|
||||
break;
|
||||
case(504):
|
||||
$msg = __('Gateway Timeout – Your request is causing an unusually long process time.');
|
||||
break;
|
||||
default:
|
||||
$msg = $charge_amount.' '.config('paymentgateway.global_currency').' '. __('This amount is higher than the maximum.');
|
||||
break;
|
||||
}
|
||||
abort(405,$msg);
|
||||
}
|
||||
|
||||
$payment = Mollie::api()->payments->get($payment->id);
|
||||
|
||||
session()->put('mollie_payment_id', $payment->id);
|
||||
return redirect($payment->getCheckoutUrl(), 303);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['AED', 'AUD', 'BGN', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HRK', 'HUF', 'ILS', 'ISK', 'JPY', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RON', 'RUB', 'SEK', 'SGD', 'THB', 'TWD', 'USD', 'ZAR'];
|
||||
}
|
||||
private function setConfig(){
|
||||
Config::set([
|
||||
'mollie.key' => $this->getApiKey()
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'mollie';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Billplz\Laravel\Billplz;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\MyanmarCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Billplz\Signature;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PagaliPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,ConvertUsdSupport,PaymentEnvironment;
|
||||
public $pageId;
|
||||
public $entityId;
|
||||
|
||||
|
||||
public function getPageId(){
|
||||
return $this->pageId;
|
||||
}
|
||||
public function setPageId($pageId){
|
||||
$this->pageId = $pageId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEntityId(){
|
||||
return $this->entityId;
|
||||
}
|
||||
public function setEntityId($entityId){
|
||||
$this->entityId = $entityId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
//todo:: write code for verify payment
|
||||
$payment_status = request()->payment_status;
|
||||
$order_id = request()->order_id;
|
||||
$get_host = parse_url(request()->headers->get('referer'), PHP_URL_HOST);
|
||||
if ($payment_status === 'Completed'){
|
||||
request()->getUri();
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'order_id' => substr( request()->order_id,5,-5)
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed','order_id' => substr( request()->order_id,5,-5)];
|
||||
}
|
||||
|
||||
public function pagali_view($args){
|
||||
return view('paymentgateway::pagali', ['pagali_data' => array_merge($args,[
|
||||
'order_id' => PaymentGatewayHelpers::wrapped_id($args['order_id']),
|
||||
'page_id' => $this->getPageId(),
|
||||
'currency' => $this->getCurrency(),
|
||||
'entity_id' => $this->getEntityId(),
|
||||
'charge_amount' => $this->charge_amount($args['amount']),
|
||||
])]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$order_id = PaymentGatewayHelpers::wrapped_id($args['order_id']);
|
||||
//build the argument for pagali blade file
|
||||
return $this->pagali_view($args);
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['MYR','USD','EUR','CVE'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
return 'USD';
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'pagali';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Xgenious\Paymentgateway\Traits\ZarCurrencySupport;
|
||||
|
||||
|
||||
class PayFastPay extends PaymentGatewayBase
|
||||
{
|
||||
protected $merchant_id;
|
||||
protected $merchant_key;
|
||||
protected $passphrase;
|
||||
|
||||
use PaymentEnvironment,CurrencySupport,ZarCurrencySupport;
|
||||
|
||||
public function setMerchantId($merchant_id){
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantId(){
|
||||
return $this->merchant_id;
|
||||
}
|
||||
public function setMerchantKey($merchant_key){
|
||||
$this->merchant_key = $merchant_key;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantKey(){
|
||||
return $this->merchant_key;
|
||||
}
|
||||
public function setPassphrase($passphrase){
|
||||
$this->passphrase = $passphrase;
|
||||
return $this;
|
||||
}
|
||||
public function getPassphrase(){
|
||||
return $this->passphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* this payment gateway will not work without this package
|
||||
* @ https://github.com/kingflamez/laravelrave
|
||||
*
|
||||
*/
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->is_decimal($amount) ? $amount : number_format((float)$amount,2,'.','');
|
||||
}
|
||||
return $this->is_decimal( $this->get_amount_in_zar($amount)) ? $this->get_amount_in_zar($amount) :number_format((float) $this->get_amount_in_zar($amount),2,'.','');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* * @param array $args
|
||||
* @required param list
|
||||
* request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$this->setConfig();
|
||||
$payfast = new \Billow\Payfast();
|
||||
$payfast->setMerchant([
|
||||
'merchant_id' => $this->getMerchantId(), // TEST Credentials. Replace with your merchant ID from Payfast.
|
||||
'merchant_key' => $this->getMerchantKey(), // TEST Credentials. Replace with your merchant key from Payfast.
|
||||
]);
|
||||
$payfast->setPassphrase($this->getPassphrase());
|
||||
$status = $payfast->verify( request(), request()->amount_gross, request()->m_payment_id)->status();
|
||||
$return_val = ['status' => 'failed'];
|
||||
// Handle the result of the transaction.
|
||||
switch( $status )
|
||||
{
|
||||
case 'COMPLETE': // Things went as planned, update your order status and notify the customer/admins.
|
||||
$return_val = $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'order_id' => substr( request()->m_payment_id,5,-5) ,
|
||||
'transaction_id' => request()->pf_payment_id,
|
||||
]);
|
||||
break;
|
||||
case 'FAILED': // We've got problems, notify admin and contact Payfast Support.
|
||||
$return_val = $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => substr( request()->m_payment_id,5,-5)
|
||||
]);
|
||||
break;
|
||||
case 'PENDING': // We've got problems, notify admin and contact Payfast Support.
|
||||
break;
|
||||
default: // We've got problems, notify admin to check logs.
|
||||
break;
|
||||
}
|
||||
|
||||
return $return_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
if($this->charge_amount($args['amount']) > 500000){
|
||||
return back()->with(['msg' => __('We could not process your request due to your amount is higher than the maximum.'),'type' => 'danger']);
|
||||
}
|
||||
$this->setConfig();
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
$payfast = new \Billow\Payfast();
|
||||
$payfast->setMerchant([
|
||||
'merchant_id' => $this->getMerchantId(), // TEST Credentials. Replace with your merchant ID from Payfast.
|
||||
'merchant_key' => $this->getMerchantKey(), // TEST Credentials. Replace with your merchant key from Payfast.
|
||||
'return_url' => $args['success_url'], // Redirect URL on Success.
|
||||
'cancel_url' => $args['cancel_url'], // Redirect URL on Cancellation.
|
||||
'notify_url' => $args['ipn_url'], // ITN URL.
|
||||
]);
|
||||
$payfast->setPassphrase($this->getPassphrase());
|
||||
$payfast->setBuyer( $args['name'], null, $args['email']);
|
||||
$payfast->setAmount($this->charge_amount($args['amount']));
|
||||
$payfast->setItem( $args['description'] , null);
|
||||
$payfast->setMerchantReference($order_id);
|
||||
$payfast->setCancelUrl($args['cancel_url']);
|
||||
$payfast->setReturnUrl($args['success_url']);
|
||||
$payfast->setNotifyUrl($args['ipn_url']);
|
||||
$submit_form = $payfast->paymentForm(__('Pay Now'));
|
||||
|
||||
return view('paymentgateway::payfast',compact('submit_form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['ZAR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "ZAR";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'payfast';
|
||||
}
|
||||
|
||||
protected function setConfig(){
|
||||
Config::set([
|
||||
'payfast.testing' => $this->getEnv(), // Set to false when in production.
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Paytabscom\Laravel_paytabs\PaytabsEnum;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Paytabscom\Laravel_paytabs\Facades\paypage;
|
||||
|
||||
class PayTabsPay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
use CurrencySupport,PaymentEnvironment,ConvertUsdSupport;
|
||||
|
||||
protected $profile_id;
|
||||
protected $region;
|
||||
protected $server_key;
|
||||
|
||||
|
||||
public function setProfileId(string $profile_id) : PayTabsPay
|
||||
{
|
||||
$this->profile_id = $profile_id;
|
||||
return $this;
|
||||
}
|
||||
public function getProfileId(){
|
||||
return $this->profile_id;
|
||||
}
|
||||
|
||||
public function setRegion(string $region = 'GLOBAL'): PayTabsPay
|
||||
{
|
||||
$this->region = $region;
|
||||
return $this;
|
||||
}
|
||||
public function getRegion(){
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
public function setServerKey($server_key): PayTabsPay
|
||||
{
|
||||
$this->server_key = $server_key;
|
||||
return $this;
|
||||
}
|
||||
public function getServerKey(){
|
||||
return $this->server_key;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$transaction_id = request()->tranRef;
|
||||
if (!empty($transaction_id)) {
|
||||
try {
|
||||
$this->setConfig();
|
||||
$transaction = Paypage::queryTransaction($transaction_id);
|
||||
if ($transaction->success){
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $transaction->transaction_id,
|
||||
'order_id' => substr($transaction->cart_id,5,-5)
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Une erreur s'est produite
|
||||
return "Erreur :" . $e->getMessage();
|
||||
}
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
|
||||
$this->setConfig();
|
||||
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
|
||||
try {
|
||||
$pay= paypage::sendPaymentCode('all')
|
||||
->sendTransaction('sale',PaytabsEnum::TRAN_CLASS_ECOM)
|
||||
// ->sendTransaction('sale')
|
||||
->sendCart($order_id,$this->charge_amount($args['amount']), $args['description']) //1st param cart id or oorder id, 2nd param charge amount , 3rd param card description
|
||||
// ->sendCustomerDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10') // 1st param name, 2nd param email, 3rd param phone,
|
||||
// ->sendShippingDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10')
|
||||
->sendURLs( $args['ipn_url'],$args[ 'success_url']) //first param is callback_url, 2nd param is return url
|
||||
->sendLanguage('en')
|
||||
->sendHideShipping(true)
|
||||
// ->sendFramed(true)
|
||||
->create_pay_page();
|
||||
return $pay;
|
||||
|
||||
}catch (\Exception $e){
|
||||
abort(401,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function setConfig(){
|
||||
\Config::set([
|
||||
'paytabs.currency' => $this->getCurrency(), //['AED','EGP','SAR','OMR','JOD','USD']
|
||||
'paytabs.profile_id' => $this->getProfileId(),
|
||||
'paytabs.region' => $this->getRegion(), // ['ARE','EGY','SAU','OMN','JOR','GLOBAL']
|
||||
'paytabs.server_key' => $this->getServerKey()
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function supported_currency_list() : array
|
||||
{
|
||||
return ['AED','EGP','SAR','OMR','JOD','USD'];
|
||||
}
|
||||
|
||||
public function charge_currency() : string
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
public function gateway_name() : string
|
||||
{
|
||||
return 'paytabs';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Tzsk\Payu\Concerns\Attributes;
|
||||
use Tzsk\Payu\Concerns\Customer;
|
||||
use Tzsk\Payu\Concerns\Transaction;
|
||||
use Tzsk\Payu\Facades\Payu;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
|
||||
class PayUmoneyPay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
// TODO: Implement charge_amount() method.
|
||||
}
|
||||
|
||||
public function ipn_response(array $args)
|
||||
{
|
||||
// TODO: Implement ipn_response() method.
|
||||
}
|
||||
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$url = "https://test.payu.in/_payment";
|
||||
|
||||
$req = curl_init($url);
|
||||
curl_setopt($req, CURLOPT_URL, $url);
|
||||
curl_setopt($req, CURLOPT_POST, true);
|
||||
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$headers = array( "Content-Type: application/x-www-form-urlencoded", );
|
||||
curl_setopt($req, CURLOPT_HTTPHEADER, $headers);
|
||||
$required_data = [
|
||||
'key' => 'JP***g',
|
||||
'txnid' => 'xVoehYja6N6UXo',
|
||||
'amount'=>'10.00',
|
||||
'firstname'=> "PayU User",
|
||||
'email' => 'test@gmail.com',
|
||||
'phone' => '9876543210',
|
||||
'productinfo'=>'iPhone',
|
||||
'bankcode' => '', // nor required
|
||||
'surl'=>'https://apiplayground-response.herokuapp.com/', // success url
|
||||
'furl' => 'https://apiplayground-response.herokuapp.com/', //failed url,
|
||||
// 'hash'=> '33e5d638040036ba195049cb0d75cbc37cf8345a52a5478503462bb75f79d2d8b9d18c444438a725f5e514e54d566be9a6b201b371da9119fa9a0f9b5e956309'
|
||||
'hash'=> $this->createHash($args)
|
||||
];
|
||||
$data = "key=JP***g&txnid=xVoehYja6N6UXo&amount=10.00&firstname=PayU User&email=test@gmail.com&phone=9876543210&productinfo=iPhone&pg=&bankcode=&surl=https://apiplayground-response.herokuapp.com/&furl=https://apiplayground-response.herokuapp.com/&ccnum=&ccexpmon=&ccexpyr=&ccvv=&ccname=&txn_s2s_flow=&hash=33e5d638040036ba195049cb0d75cbc37cf8345a52a5478503462bb75f79d2d8b9d18c444438a725f5e514e54d566be9a6b201b371da9119fa9a0f9b5e956309";
|
||||
|
||||
curl_setopt($req, CURLOPT_POSTFIELDS, $data);
|
||||
$resp = curl_exec($req);
|
||||
curl_close($req);
|
||||
var_dump($resp);
|
||||
|
||||
// TODO: Implement charge_customer() method.
|
||||
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
|
||||
// $ch = curl_init();
|
||||
//
|
||||
// curl_setopt($ch, CURLOPT_URL, 'https://test.payu.in/_payment-H');
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||
//
|
||||
// // generate hash
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, "key=mji6olvE&txnid=SU0CsnMBP2AYQt&amount=10.00&firstname=PayU User&email=test@gmail.com&phone=9876543210&productinfo=iPhone&surl=https://apiplayground-response.herokuapp.com/&furl=https://apiplayground-response.herokuapp.com/&hash=3fe4bb610aaa84ed23ff1f3605e0e58d8613895cdf68ffd890d9954b41ecaa788f635851db20c9a8735b53d220676847328b9e7836920c75d51a1c17122cc651");
|
||||
//
|
||||
// $headers = array();
|
||||
// $headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
||||
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
//
|
||||
// $result = curl_exec($ch);
|
||||
// if (curl_errno($ch)) {
|
||||
// echo 'Error:' . curl_error($ch);
|
||||
// }
|
||||
// curl_close($ch);
|
||||
// return $result;
|
||||
// dd($result);
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
// TODO: Implement supported_currency_list() method.
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
// TODO: Implement charge_currency() method.
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
// TODO: Implement gateway_name() method.
|
||||
}
|
||||
|
||||
protected function createHash($args){
|
||||
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
|
||||
|
||||
//$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
|
||||
$hashVarsSeq = explode('|', $hashSequence);
|
||||
$hash_string = '';
|
||||
foreach($hashVarsSeq as $hash_var) {
|
||||
$hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
|
||||
$hash_string .= '|';
|
||||
}
|
||||
|
||||
$hash_string .= $SALT;
|
||||
|
||||
|
||||
$hash = strtolower(hash('sha512', $hash_string));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,624 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class PaymobPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment, CurrencySupport, ConvertUsdSupport;
|
||||
|
||||
private $apiKey;
|
||||
private $hmacSecret;
|
||||
private $integrationId;
|
||||
private $gatewayType;
|
||||
private $iframeId;
|
||||
private $secretKay;
|
||||
private $publicKey;
|
||||
private $walletMobileNumber;
|
||||
|
||||
/**
|
||||
Available Gateway Type
|
||||
*
|
||||
"accept-online" //card payment
|
||||
"accept-kiosk"
|
||||
"accept-wallet"
|
||||
"accept-valu"
|
||||
"accept-installments"
|
||||
"accept-sympl"
|
||||
"accept-premium"
|
||||
"accept-souhoola"
|
||||
"accept-shahry"
|
||||
"accept-get_go"
|
||||
"accept-lucky"
|
||||
"accept-forsa"
|
||||
"accept-tabby"
|
||||
"accept-nowpay"
|
||||
* */
|
||||
|
||||
|
||||
public function setWalletMobileNumber($walletMobileNumber)
|
||||
{
|
||||
$this->walletMobileNumber = $walletMobileNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWalletMobileNumber()
|
||||
{
|
||||
return $this->walletMobileNumber;
|
||||
}
|
||||
|
||||
public function setPublicKey($publicKey)
|
||||
{
|
||||
$this->publicKey = $publicKey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
|
||||
public function setSecretKey($secretKay)
|
||||
{
|
||||
$this->secretKay = $secretKay;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecretKey()
|
||||
{
|
||||
return $this->secretKay;
|
||||
}
|
||||
|
||||
|
||||
public function setIframeId($iframeId)
|
||||
{
|
||||
$this->iframeId = $iframeId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIframeId()
|
||||
{
|
||||
return $this->iframeId;
|
||||
}
|
||||
|
||||
public function setGatewayType($gatewayType)
|
||||
{
|
||||
$this->gatewayType = $gatewayType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGatewayType()
|
||||
{
|
||||
return $this->gatewayType;
|
||||
}
|
||||
|
||||
public function setApiKey($apiKey)
|
||||
{
|
||||
$this->apiKey = $apiKey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApiKey()
|
||||
{
|
||||
return $this->apiKey;
|
||||
}
|
||||
|
||||
public function setHmacSecret($hmacSecret)
|
||||
{
|
||||
$this->hmacSecret = $hmacSecret;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHmacSecret()
|
||||
{
|
||||
return $this->hmacSecret;
|
||||
}
|
||||
|
||||
public function setIntegrationId($integrationId)
|
||||
{
|
||||
$this->integrationId = $integrationId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIntegrationId()
|
||||
{
|
||||
return $this->integrationId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $amount * 100;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount) * 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for
|
||||
* */
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$authorize_token = $this->authentication_request();
|
||||
/* make eCommerce Order */
|
||||
$order_request = $this->order_registration_request($authorize_token,$args);
|
||||
|
||||
/* work on payment key request */
|
||||
$payment_key_request_token = $this->payment_key_request($authorize_token,$args,($order_request['order_id'] ?? ""));
|
||||
|
||||
$payment_url = '';
|
||||
|
||||
|
||||
/**
|
||||
Available Gateway Type
|
||||
*
|
||||
"accept-online" //card payment
|
||||
"accept-kiosk"
|
||||
"accept-wallet"
|
||||
"accept-valu"
|
||||
"accept-installments"
|
||||
"accept-sympl"
|
||||
"accept-premium"
|
||||
"accept-souhoola"
|
||||
"accept-shahry"
|
||||
"accept-get_go"
|
||||
"accept-lucky"
|
||||
"accept-forsa"
|
||||
"accept-tabby"
|
||||
"accept-nowpay"
|
||||
* */
|
||||
|
||||
/* get payment page url based on the payment gateway type */
|
||||
if ($this->getGatewayType() === 'accept-online'){
|
||||
$payment_url = 'https://accept.paymobsolutions.com/api/acceptance/iframes/'.$this->getIframeId().'?payment_token='.$payment_key_request_token;
|
||||
}elseif ($this->getGatewayType() === 'accept-valu'){
|
||||
/* iframe id should be fore valU */
|
||||
$payment_url = 'https://accept.paymobsolutions.com/api/acceptance/iframes/'.$this->getIframeId().'?payment_token='.$payment_key_request_token;
|
||||
}elseif ($this->getGatewayType() === 'accept-kiosk'){
|
||||
// api request for kiosk, need to show bill_reference to the user for pay it from koisok
|
||||
$bill_reference = $this->process_kiosk_payment_request($payment_key_request_token,$authorize_token,$args);
|
||||
return "your kiosk payment bill reference id:". $bill_reference;
|
||||
}elseif ($this->getGatewayType() === 'accept-wallet'){
|
||||
//todo:: call wallet api and redirect them to redirect_url
|
||||
$redirect_url = $this->process_wallet_payment_request($payment_key_request_token,$authorize_token,$args);
|
||||
return redirect()->away($redirect_url);
|
||||
}
|
||||
return view('paymentgateway::paymob',[
|
||||
"payment_url" => $payment_url
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = [])
|
||||
{
|
||||
|
||||
$request = request();
|
||||
|
||||
//todo:: need to check it is is post or get request,
|
||||
//post request mean == transaction process callback
|
||||
//get request mean == transaction response callback
|
||||
|
||||
//todo:: need to verify hmac
|
||||
$request_method = strtolower($request->method());
|
||||
$hmac_type = $request_method === 'get' ? 'TRANSACTION' : 'TRANSACTION';
|
||||
$hash_value = $this->getHasvalue();
|
||||
$order_id = request()->get('merchant_order_id');
|
||||
|
||||
$callback_type = 'TRANSACTION';
|
||||
if (strtolower(request()->method()) === 'post') {
|
||||
$callback_type = request()->type;
|
||||
}
|
||||
|
||||
if(hash_equals($hash_value,$request->hmac)){
|
||||
if ($request_method === 'post'){
|
||||
//handle post request
|
||||
if ($callback_type == 'TRANSACTION') {
|
||||
if (
|
||||
$request->success === true &&
|
||||
$request->is_voided === false &&
|
||||
$request->is_refunded === false &&
|
||||
$request->pending === false &&
|
||||
$request->is_void === false &&
|
||||
$request->is_refund === false &&
|
||||
$request->error_occured === false
|
||||
) {
|
||||
return $this->verified_data([
|
||||
'status' => 'processing',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
} else if (
|
||||
$request->success === true &&
|
||||
$request->is_refunded === true &&
|
||||
$request->is_voided === false &&
|
||||
$request->pending === false &&
|
||||
$request->is_void === false &&
|
||||
$request->is_refund === false
|
||||
) {
|
||||
return $this->verified_data([
|
||||
'status' => 'refunded',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
|
||||
} else if (
|
||||
$request->success === true &&
|
||||
$request->is_voided === true &&
|
||||
$request->is_refunded === false &&
|
||||
$request->pending === false &&
|
||||
$request->is_void === false &&
|
||||
$request->is_refund === false
|
||||
) {
|
||||
return $this->verified_data([
|
||||
'status' => 'cancelled',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
|
||||
} else if (
|
||||
$request->success === false &&
|
||||
$request->is_voided === false &&
|
||||
$request->is_refunded === false &&
|
||||
$request->is_void === false &&
|
||||
$request->is_refund === false
|
||||
) {
|
||||
return $this->verified_data([
|
||||
'status' => 'pending-payment',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
}
|
||||
}else if ($callback_type == 'TOKEN'){
|
||||
//handle if token accept
|
||||
}
|
||||
|
||||
}elseif ($request_method === 'get'){
|
||||
//handle get request
|
||||
|
||||
if (
|
||||
$request->success === "true" &&
|
||||
$request->is_voided === "false" &&
|
||||
$request->is_refunded === "false" &&
|
||||
$request->pending === "false" &&
|
||||
$request->is_void === "false" &&
|
||||
$request->is_refund === "false" &&
|
||||
$request->error_occured === "false"
|
||||
) {
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => request()->get('id'),
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
}
|
||||
elseif($request->data_message ==="Approved" ) {
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => request()->get('id'),
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'order_type' => null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'paymob';
|
||||
}
|
||||
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "EGP";
|
||||
}
|
||||
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list()
|
||||
{
|
||||
$supported_currency = ['EGP'];
|
||||
if ($this->getGatewayType() === "accept-online"){
|
||||
$supported_currency = ['EGP', 'USD', 'EUR', 'GBP'];
|
||||
}
|
||||
return $supported_currency;
|
||||
}
|
||||
|
||||
|
||||
private function base_api_url() {
|
||||
return 'https://accept.paymob.com/api/';
|
||||
}
|
||||
|
||||
private function authentication_request() {
|
||||
$url = $this->base_api_url().'auth/tokens';
|
||||
//todo:: post request
|
||||
$response = Http::post($url,[
|
||||
"api_key" => $this->getApiKey()
|
||||
]);
|
||||
if ($response->status() === 201){
|
||||
$result = $response->object();
|
||||
$authorise_token = $result->token;
|
||||
if(!empty($authorise_token)){
|
||||
return $authorise_token;
|
||||
}
|
||||
abort(500,'authentication request token generate failed');
|
||||
}
|
||||
abort(500,'authentication_request failed');
|
||||
}
|
||||
|
||||
private function order_registration_request($authorize_token,$args) {
|
||||
$response = Http::post($this->base_api_url().'ecommerce/orders',[
|
||||
"auth_token" => $authorize_token,
|
||||
"delivery_needed" => "false",
|
||||
"amount_cents" => $this->charge_amount($args['amount']),
|
||||
"currency" => $this->getCurrency(),
|
||||
"merchant_order_id" => PaymentGatewayHelpers::wrapped_id($args['order_id']),
|
||||
"items" => [
|
||||
[
|
||||
"name" => $args['title'],
|
||||
"amount_cents" => $this->charge_amount($args['amount']),
|
||||
"description" => $args['description'],
|
||||
"quantity" => "1"
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
if($response->status() === 201){
|
||||
return [
|
||||
'order_id' => $response->object()?->id,
|
||||
'token' => $response->object()?->token
|
||||
];
|
||||
}
|
||||
abort(500,'order_registration_request failed');
|
||||
}
|
||||
|
||||
private function payment_key_request($authorize_token, array $args,$order_request_id)
|
||||
{
|
||||
$response = Http::post($this->base_api_url().'acceptance/payment_keys',[
|
||||
"auth_token" => $authorize_token,
|
||||
"amount_cents" => $this->charge_amount($args['amount']),
|
||||
"expiration" => 3600,
|
||||
"order_id" => $order_request_id,
|
||||
"billing_data" => [
|
||||
"first_name" => "Clifford",
|
||||
"last_name" => "Nicolas",
|
||||
"email" => "claudette09@exa.com",
|
||||
"phone_number" => "+86(8)9135210487",
|
||||
"apartment" => "NA",
|
||||
"floor" => "NA",
|
||||
"street" => "NA",
|
||||
"building" => "NA",
|
||||
"shipping_method" => "NA",
|
||||
"postal_code" => "NA",
|
||||
"city" => "NA",
|
||||
"country" => "NA",
|
||||
"state" => "NA"
|
||||
],
|
||||
"currency" => $this->getCurrency(),
|
||||
"integration_id" => $this->getIntegrationId(),
|
||||
"lock_order_when_paid" => "false"
|
||||
]);
|
||||
if($response->status() === 201){
|
||||
return $response->object()?->token;
|
||||
}
|
||||
abort(500,'payment_key_request failed');
|
||||
}
|
||||
|
||||
private function process_kiosk_payment_request($payment_key_request_token,$authorize_token,$args)
|
||||
{
|
||||
//todo api request
|
||||
$response = Http::asJson()->post($this->base_api_url().'acceptance/payment_keys',[
|
||||
"payment_token" => $payment_key_request_token,
|
||||
"auth_token" => $authorize_token,
|
||||
"source" => [
|
||||
"identifier" => "AGGREGATOR",
|
||||
"subtype" => "AGGREGATOR"
|
||||
],
|
||||
'amount_cents' => $this->charge_amount($args['amount']),
|
||||
'currency' => $this->getCurrency()
|
||||
]);
|
||||
if($response->status() === 201){
|
||||
return $response->object()?->data?->bill_reference;
|
||||
}
|
||||
abort(500,'process_kiosk_payment_request bill_reference generate failed');
|
||||
}
|
||||
private function process_wallet_payment_request($payment_key_request_token,$authorize_token,$args)
|
||||
{
|
||||
//todo api request
|
||||
$response = Http::asJson()->post($this->base_api_url().'acceptance/payment_keys',[
|
||||
"payment_token" => $payment_key_request_token,
|
||||
"auth_token" => $authorize_token,
|
||||
"source" => [
|
||||
"identifier" => $this->getWalletMobileNumber(),
|
||||
"subtype" => "WALLET"
|
||||
],
|
||||
'amount_cents' => $this->charge_amount($args['amount']),
|
||||
'currency' => $this->getCurrency()
|
||||
]);
|
||||
|
||||
if($response->status() === 201){
|
||||
return $response->object()->redirect_url;
|
||||
}
|
||||
abort(500,'process_wallet_payment_request redirect_url generate failed');
|
||||
}
|
||||
|
||||
private function getHmacStringArray()
|
||||
{
|
||||
$return_string = request()->all();
|
||||
if (strtolower(request()->method()) === 'post'){
|
||||
$return_string = '';
|
||||
$callback_type = request()->type;
|
||||
$object = request()->obj;
|
||||
$return_string = request()->obj;
|
||||
|
||||
if ($callback_type === 'TRANSACTION'){
|
||||
|
||||
$return_string->order = $object->order?->id;
|
||||
$return_string->order = $object->order?->id;
|
||||
$return_string->is_3d_secure = ($object->is_3d_secure === true) ? 'true' : 'false';
|
||||
$return_string->is_auth = ($object->is_auth === true) ? 'true' : 'false';
|
||||
$return_string->is_capture = ($object->is_capture === true) ? 'true' : 'false';
|
||||
$return_string->is_refunded = ($object->is_refunded === true) ? 'true' : 'false';
|
||||
$return_string->is_standalone_payment = ($object->is_standalone_payment === true) ? 'true' : 'false';
|
||||
$return_string->is_voided = ($object->is_voided === true) ? 'true' : 'false';
|
||||
$return_string->success = ($object->success === true) ? 'true' : 'false';
|
||||
$return_string->error_occured = ($object->error_occured === true) ? 'true' : 'false';
|
||||
$return_string->has_parent_transaction = ($object->has_parent_transaction === true) ? 'true' : 'false';
|
||||
$return_string->pending = ($object->pending === true) ? 'true' : 'false';
|
||||
$return_string->source_data_pan = $object->source_data?->pan;
|
||||
$return_string->source_data_type = $object->source_data?->type;
|
||||
$return_string->source_data_sub_type = $object->source_data?->sub_type;
|
||||
|
||||
/*
|
||||
amount_cents
|
||||
created_at
|
||||
currency
|
||||
error_occured
|
||||
has_parent_transaction
|
||||
id
|
||||
integration_id
|
||||
is_3d_secure
|
||||
is_auth
|
||||
is_capture
|
||||
is_refunded
|
||||
is_standalone_payment
|
||||
is_voided
|
||||
order.id
|
||||
owner
|
||||
pending
|
||||
source_data.pan
|
||||
source_data.sub_type
|
||||
source_data.type
|
||||
success
|
||||
*/
|
||||
|
||||
}elseif ($callback_type === 'DELIVERY_STATUS'){
|
||||
$return_string->order = $object->order?->id;
|
||||
}
|
||||
}elseif(strtolower(request()->method()) === 'get'){
|
||||
//handle if the callback if get request transaction callback.
|
||||
$callback_type = 'TRANSACTION';
|
||||
$return_string = request()->all();
|
||||
}
|
||||
|
||||
return $return_string;
|
||||
}
|
||||
|
||||
private function getHasvalue()
|
||||
{
|
||||
$callback_type = 'TRANSACTION';
|
||||
if (strtolower(request()->method()) === 'post') {
|
||||
$callback_type = request()->type;
|
||||
}
|
||||
|
||||
$hmac_string = $this->getHmacStringArray();
|
||||
$str = '';
|
||||
switch ($callback_type) {
|
||||
|
||||
case 'TRANSACTION':
|
||||
|
||||
$str =
|
||||
$hmac_string['amount_cents'] .
|
||||
$hmac_string['created_at'] .
|
||||
$hmac_string['currency'] .
|
||||
$hmac_string['error_occured'] .
|
||||
$hmac_string['has_parent_transaction'] .
|
||||
$hmac_string['id'] .
|
||||
$hmac_string['integration_id'] .
|
||||
$hmac_string['is_3d_secure'] .
|
||||
$hmac_string['is_auth'] .
|
||||
$hmac_string['is_capture'] .
|
||||
$hmac_string['is_refunded'] .
|
||||
$hmac_string['is_standalone_payment'] .
|
||||
$hmac_string['is_voided'] .
|
||||
$hmac_string['order'] .
|
||||
$hmac_string['owner'] .
|
||||
$hmac_string['pending'] .
|
||||
$hmac_string['source_data_pan'] .
|
||||
$hmac_string['source_data_sub_type'] .
|
||||
$hmac_string['source_data_type'] .
|
||||
$hmac_string['success'];
|
||||
break;
|
||||
case 'TOKEN':
|
||||
$str =
|
||||
$hmac_string['card_subtype'] .
|
||||
$hmac_string['created_at'] .
|
||||
$hmac_string['email'] .
|
||||
$hmac_string['id'] .
|
||||
$hmac_string['masked_pan'] .
|
||||
$hmac_string['merchant_id'] .
|
||||
$hmac_string['order_id'] .
|
||||
$hmac_string['token'];
|
||||
break;
|
||||
case 'DELIVERY_STATUS':
|
||||
$str =
|
||||
$hmac_string['created_at'] .
|
||||
$hmac_string['extra_description'] .
|
||||
$hmac_string['gps_lat'] .
|
||||
$hmac_string['gps_long'] .
|
||||
$hmac_string['id'] .
|
||||
$hmac_string['merchant'] .
|
||||
$hmac_string['order'] .
|
||||
$hmac_string['status'];
|
||||
break;
|
||||
}
|
||||
$hash = hash_hmac('sha512', $str, $this->getHmacSecret());
|
||||
return $hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Srmklive\PayPal\Services\PayPal as PayPalClient;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class PaypalPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport,ConvertUsdSupport;
|
||||
protected $client_id;
|
||||
protected $client_secret;
|
||||
protected $app_id;
|
||||
|
||||
/* get app id */
|
||||
private function getAppId(){
|
||||
return $this->app_id;
|
||||
}
|
||||
/* set app id */
|
||||
public function setAppId($app_id){
|
||||
$this->app_id = $app_id;
|
||||
return $this;
|
||||
}
|
||||
/* set app id */
|
||||
public function setClientId($client_id){
|
||||
$this->client_id = $client_id;
|
||||
return $this;
|
||||
}
|
||||
/* set app secret */
|
||||
public function setClientSecret($client_secret){
|
||||
$this->client_secret = $client_secret;
|
||||
return $this;
|
||||
}
|
||||
/* get app id */
|
||||
private function getClientId(){
|
||||
return $this->client_id;
|
||||
}
|
||||
/* get secret key */
|
||||
private function getClientSecret(){
|
||||
return $this->client_secret;
|
||||
}
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
|
||||
protected function getPaymentProvider($args){
|
||||
Config::set([
|
||||
'paypal.mode' => $this->getEnv() ? 'sandbox' : 'live',
|
||||
'paypal.sandbox' => [
|
||||
'client_id' => $this->getClientId(),
|
||||
'client_secret' => $this->getClientSecret(),
|
||||
'app_id' => $this->getAppId(),
|
||||
],
|
||||
'paypal.live' => [
|
||||
'client_id' => $this->getClientId(),
|
||||
'client_secret' => $this->getClientSecret(),
|
||||
'app_id' => $this->getAppId(),
|
||||
],
|
||||
'paypal.payment_action' => 'Sale',
|
||||
'paypal.currency' => $this->charge_currency(),
|
||||
'paypal.notify_url' => $args['ipn_url'],
|
||||
'paypal.locale' => app()->getLocale(),
|
||||
'paypal.validate_ssl' => true,
|
||||
]);
|
||||
$provider = new PayPalClient;
|
||||
$access_token = $provider->getAccessToken();
|
||||
|
||||
abort_if(isset($access_token['type']) && $access_token['type'] === 'error',405,$access_token['message'] ?? '');
|
||||
$provider->setAccessToken($access_token);
|
||||
return $provider;
|
||||
}
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for paypal
|
||||
* */
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$provider = $this->getPaymentProvider($args);
|
||||
|
||||
if($args['amount'] < 1){
|
||||
abort(500,__('minimum payable amount is 1'));
|
||||
}
|
||||
|
||||
$order = $provider->createOrder([
|
||||
"intent"=> "CAPTURE",
|
||||
"purchase_units"=> [
|
||||
0 => [
|
||||
"amount"=> [
|
||||
"currency_code"=> $this->charge_currency(),
|
||||
"value"=> number_format($this->charge_amount($args['amount']), 2, ".", "")
|
||||
]
|
||||
]
|
||||
],
|
||||
'application_context' => [
|
||||
'cancel_url' => $args['cancel_url'],
|
||||
'return_url' => $args['ipn_url']
|
||||
]
|
||||
]);
|
||||
|
||||
// throw exception
|
||||
if(isset($order['error'])){
|
||||
abort(422, $order['error']['message']);
|
||||
}
|
||||
|
||||
abort_if(isset($order['type']) && $order['type'] === 'error',405,$order['message'] ?? '');
|
||||
$order_id = $order['id'];
|
||||
|
||||
session()->put('paypal_order_id',$order_id);
|
||||
session()->put('paypal_ipn_url',$args['ipn_url']);
|
||||
session()->put('paypal_cancel_url',$args['cancel_url']);
|
||||
session()->put('script_order_id', $args['order_id']);
|
||||
$redirect_url = $order['links'][1]['href'];
|
||||
return redirect($redirect_url)->send();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
/** Get the payment ID before session clear **/
|
||||
$payment_id = session()->get('paypal_order_id');
|
||||
$script_order_id = session()->get('script_order_id');
|
||||
$paypal_ipn_url = session()->get('paypal_ipn_url');
|
||||
$paypal_cancel_url = session()->get('paypal_cancel_url');
|
||||
$request = request();
|
||||
/** clear the session payment ID **/
|
||||
session()->forget(['paypal_order_id','script_order_id','paypal_cancel_url','paypal_ipn_url']);
|
||||
|
||||
if (empty($request->get('PayerID')) || empty($request->get('token'))) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
$provider = $this->getPaymentProvider(['ipn_url' => $paypal_ipn_url]);
|
||||
$order_details = $provider->capturePaymentOrder($payment_id);
|
||||
if (isset($order_details['status']) && $order_details['status'] === 'COMPLETED') {
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $payment_id,
|
||||
'order_id' => $script_order_id
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'pending',
|
||||
'order_id' => $script_order_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'paypal';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return ['AUD', 'BRL', 'CAD', 'CNY', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'INR', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD'];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Unicodeveloper\Paystack\Facades\Paystack;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
|
||||
class PaystackPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport;
|
||||
|
||||
protected $public_key;
|
||||
protected $secret_key;
|
||||
protected $merchant_email;
|
||||
|
||||
public function setPublicKey($public_key){
|
||||
$this->public_key = $public_key;
|
||||
return $this;
|
||||
}
|
||||
public function getPublicKey(){
|
||||
return $this->public_key;
|
||||
}
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
public function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
public function setMerchantEmail($merchant_email){
|
||||
$this->merchant_email = $merchant_email;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantEmail(){
|
||||
return $this->merchant_email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @ https://github.com/unicodeveloper/laravel-paystack
|
||||
* @param int|float $amount
|
||||
*/
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_ngn($amount);
|
||||
}
|
||||
|
||||
protected function get_amount_in_ngn($amount){
|
||||
if ($this->getCurrency() === 'NGN'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_ngn($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('USD amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
/**
|
||||
* convert amount to ngn currency base on conversation given by admin
|
||||
* */
|
||||
private function make_amount_in_ngn($amount, $currency)
|
||||
{
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'NGN') {
|
||||
continue;
|
||||
}
|
||||
if ($cur === $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param array $args;
|
||||
* @return array ['status','type','order_id','transaction_id'];
|
||||
*/
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$this->setConfig();
|
||||
// $paystack_ipn_url = session()->get('paystack_ipn_url');
|
||||
// abort_unless(!empty($paystack_ipn_url),405,__('ipn route not found'));
|
||||
$paymentDetails = Paystack::getPaymentData();
|
||||
if ($paymentDetails['status']) {
|
||||
$meta_data = $paymentDetails['data']['metadata'];
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $paymentDetails['data']['reference'],
|
||||
'type' => $meta_data['type'],
|
||||
'order_id' => substr( $meta_data['order_id'],5,-5),
|
||||
// 'ipn_url' => $paystack_ipn_url,
|
||||
]);
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
// if($args['amount'] > 25000 && $this->charge_currency() !== 'NGN'){
|
||||
// return back()->with(['msg' => __('We could not process your request due to your amount is higher than the maximum.'),'type' => 'danger']);
|
||||
// }
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
$paystack_data['currency'] = $this->charge_currency();
|
||||
$paystack_data['price'] = $this->charge_amount($args['amount']);
|
||||
$paystack_data['package_name'] = $args['title'];
|
||||
$paystack_data['name'] = $args['name'];
|
||||
$paystack_data['email'] = $args['email'];
|
||||
$paystack_data['order_id'] = $order_id;
|
||||
$paystack_data['track'] = $args['track'];
|
||||
$paystack_data['route'] = route('xg.payment.gateway.paystack');
|
||||
$paystack_data['type'] = $args['payment_type'] ?? 'random';
|
||||
$paystack_data['merchantEmail'] = $this->getMerchantEmail();
|
||||
$paystack_data['secretKey'] = $this->getSecretKey();
|
||||
$paystack_data['publicKey'] = $this->getPublicKey();
|
||||
|
||||
return view('paymentgateway::paystack')->with(['paystack_data' => $paystack_data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['GHS','NGN','ZAR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "NGN";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'paystack';
|
||||
}
|
||||
|
||||
public function setConfig($config = []){
|
||||
config(array_merge($config,[
|
||||
'paystack.merchantEmail' => $this->getMerchantEmail(),
|
||||
'paystack.secretKey' => $this->getSecretKey(),
|
||||
'paystack.publicKey' => $this->getPublicKey(),
|
||||
'paystack.paymentUrl' => 'https://api.paystack.co',
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Anand\LaravelPaytmWallet\Facades\PaytmWallet;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class PaytmPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport,IndianCurrencySupport;
|
||||
protected $merchant_id;
|
||||
protected $merchant_key;
|
||||
protected $merchant_website;
|
||||
protected $channel;
|
||||
protected $industry_type;
|
||||
|
||||
public function setMerchantId($merchant_id){
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantId(){
|
||||
return $this->merchant_id;
|
||||
}
|
||||
public function setMerchantKey($merchant_key){
|
||||
$this->merchant_key = $merchant_key;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantKey(){
|
||||
return $this->merchant_key;
|
||||
}
|
||||
public function setMerchantWebsite($merchant_website){
|
||||
$this->merchant_website = $merchant_website;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantWebsite(){
|
||||
return $this->merchant_website;
|
||||
}
|
||||
public function setChannel($channel){
|
||||
$this->channel = $channel;
|
||||
return $this;
|
||||
}
|
||||
public function getChannel(){
|
||||
return $this->channel;
|
||||
}
|
||||
public function setIndustryType($industry_type){
|
||||
$this->industry_type = $industry_type;
|
||||
return $this;
|
||||
}
|
||||
public function getIndustryType(){
|
||||
return $this->industry_type;
|
||||
}
|
||||
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_inr($amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for paypal
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$charge_amount = $this->charge_amount($args['amount']);
|
||||
$order_id = random_int(11111,99999).$args['order_id'].random_int(11111,99999);
|
||||
$payment = $this->createReceiveDriver();
|
||||
$payment->prepare([
|
||||
'order' => $order_id,
|
||||
'user' => Str::slug($args['name']),
|
||||
'mobile_number' => random_int(99999999, 99999999),
|
||||
'email' => $args['email'],
|
||||
'amount' => number_format((float) $charge_amount, 2, '.', ''),
|
||||
'callback_url' => $args['ipn_url']
|
||||
]);
|
||||
return $payment->receive();
|
||||
}
|
||||
protected function createReceiveDriver(){
|
||||
|
||||
return $this->buildProvider(
|
||||
'Anand\LaravelPaytmWallet\Providers\ReceivePaymentProvider',
|
||||
[
|
||||
'env' => $this->getEnv() ? 'local': 'production', //env('PAYTM_ENVIRONMENT','local'), // values : (local | production)
|
||||
'merchant_id' => $this->getMerchantId(),// env('PAYTM_MERCHANT_ID'),
|
||||
'merchant_key' => $this->getMerchantKey(),// env('PAYTM_MERCHANT_KEY'),
|
||||
'merchant_website' => $this->getMerchantWebsite(),// env('PAYTM_MERCHANT_WEBSITE'),
|
||||
'channel' => $this->getChannel(),//env('PAYTM_CHANNEL'),
|
||||
'industry_type' => $this->getIndustryType(),//env('PAYTM_INDUSTRY_TYPE'),
|
||||
]
|
||||
);
|
||||
}
|
||||
public function buildProvider($provider, $config){
|
||||
return new $provider(
|
||||
request(),
|
||||
$config
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
$order_id = request()->get('ORDERID');
|
||||
$transaction = $this->createReceiveDriver();
|
||||
$response = $transaction->response(); // To get raw response as array
|
||||
//Check out response parameters sent by paytm here -> http://paywithpaytm.com/developer/paytm_api_doc?target=interpreting-response-sent-by-paytm
|
||||
if ($transaction->isSuccessful()) {
|
||||
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $response['TXNID'],
|
||||
'order_id' => substr($order_id,5,-5)
|
||||
]);
|
||||
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'paytm';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "INR";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will return all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return ['INR'];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Paytabscom\Laravel_paytabs\PaytabsEnum;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Paytabscom\Laravel_paytabs\Facades\paypage;
|
||||
|
||||
class PowertranzPay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
use CurrencySupport,PaymentEnvironment,ConvertUsdSupport;
|
||||
|
||||
protected $gateway_key;
|
||||
protected $merchant_id;
|
||||
protected $merchant_processing_password;
|
||||
|
||||
|
||||
public function setGatewayKey(string $gateway_key) : PowertranzPay
|
||||
{
|
||||
$this->gateway_key = $gateway_key;
|
||||
return $this;
|
||||
}
|
||||
public function getGatewayKey(){
|
||||
return $this->gateway_key;
|
||||
}
|
||||
|
||||
public function setMerchantId(string $merchant_id) : PowertranzPay
|
||||
{
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantId(){
|
||||
return $this->merchant_id;
|
||||
}
|
||||
|
||||
public function setMerchantProcessingPassword(string $merchant_processing_password) : PowertranzPay
|
||||
{
|
||||
$this->merchant_processing_password = $merchant_processing_password;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantProcessingPassword(){
|
||||
return $this->merchant_processing_password;
|
||||
}
|
||||
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
$SpiToken = request()->get('SpiToken');
|
||||
|
||||
$payment_url = $this->base_url($this->getEnv()).'payment';
|
||||
$response = Http::post($payment_url,$SpiToken);
|
||||
$result = $response->object();
|
||||
$order_id = Str::of($result->OrderIdentifier)->before('__')->toString();
|
||||
$payment_type = Str::of($result->OrderIdentifier)->after('__')->toString();
|
||||
if ($result->Approved && $result->ResponseMessage === "Transaction is approved"){
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $result->TransactionIdentifier,
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),
|
||||
'payment_type' => $payment_type
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'failed',
|
||||
'order_id' => $order_id,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
||||
public function view($args){
|
||||
return view('paymentgateway::powertransz', ['powertransz_data' => array_merge($args,[
|
||||
'merchant_id' => Crypt::encrypt($this->getMerchantId()),
|
||||
'currency' => $this->getCurrency(),
|
||||
'merchant_password' => Crypt::encrypt($this->getMerchantProcessingPassword()),
|
||||
'gateway_key' => Crypt::encrypt($this->getGatewayKey()),
|
||||
'charge_amount' => $this->charge_amount($args['amount']),
|
||||
'environment' => $this->getEnv(),
|
||||
'order_id' => PaymentGatewayHelpers::wrapped_id($args['order_id'])
|
||||
])]);
|
||||
}
|
||||
public function charge_customer($args)
|
||||
{
|
||||
return $this->view($args);
|
||||
//todo:: format data for send in blade file for get user card details
|
||||
}
|
||||
|
||||
public function charge_customer_from_controller(){
|
||||
|
||||
|
||||
$input = request()->input();
|
||||
|
||||
/* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */
|
||||
$merchant_password = \Crypt::decrypt(request()->merchant_password);
|
||||
$merchant_id = \Crypt::decrypt(request()->merchant_id);
|
||||
$gateway_key = \Crypt::decrypt(request()->gateway_key);
|
||||
$currency = request()->currency;
|
||||
|
||||
$payment_url = $this->base_url(request()->environment).'sale';
|
||||
|
||||
$header_data = [
|
||||
'PowerTranz-PowerTranzId'=> $merchant_id,
|
||||
'PowerTranz-PowerTranzPassword' => $merchant_password,
|
||||
'Content-Type' => 'application/json; charset=utf-8'
|
||||
];
|
||||
if (!empty($gateway_key)){
|
||||
$header_data['PowerTranz-GatewayKey '] = $gateway_key;
|
||||
}
|
||||
$cardNumber = preg_replace('/\s+/', '', $input['number']);
|
||||
$card_date = explode('/',request()->get('expiry'));
|
||||
$expiration_month = trim($card_date[0]); //detect if year value is full number like 2024 get only last two digit¥¥¥¥¥¥¥¥^-09oi87uy68uy6t5rewqsdw34e5
|
||||
$expiration_year = strlen(trim($card_date[1])) == 4 ? trim($card_date[1]) : trim($card_date[1]);
|
||||
$expiration_date = $expiration_year .$expiration_month;
|
||||
$response = Http::withHeaders($header_data)
|
||||
->post($payment_url,[
|
||||
'TransactionIdentifier' => Str::uuid()->toString(), // Guid Ex: F388373D-9FD8-7AA0-B64B-0E51FF97227E ( 36 Char Long string )
|
||||
'TotalAmount' => request()->get('charge_amount'), //need in decimal format
|
||||
'CurrencyCode' => $this->getCurrencyNumber($currency),//388,//$currency, // Must use numeric currency code (ISO 4217)
|
||||
'ThreeDSecure' => true,
|
||||
'AddressMatch' => false,
|
||||
'OrderIdentifier' => $input['order_id'].'__'.$input['payment_type'],
|
||||
'Source' => [
|
||||
'CardPan' => $cardNumber, //card number for test 4012000000020071
|
||||
'CardCvv' => $input['cvc'],
|
||||
'CardExpiration' => $expiration_date, //Expiry date in YYMM format
|
||||
'CardholderName' => $input['name']
|
||||
],
|
||||
'BillingAddress' => [
|
||||
'Line2' => 'line 2',
|
||||
'City' => 'city',
|
||||
'PostalCode' => '123456', // Postal or Zip code (required for AVS) Strictly Alphanumeric only - No special characters, no accents, no spaces, no dashes…etc.
|
||||
'CountryCode' => 388,//'USA', //For USA ISO Code
|
||||
'FirstName' => $input['name'],
|
||||
'LastName' => ' ',
|
||||
'Line1' => 'unknown',
|
||||
'EmailAddress' => $input['email'],
|
||||
],
|
||||
|
||||
'ExtendedData' => [
|
||||
"ThreeDSecure" => [
|
||||
"ChallengeWindowSize" => 1, // Merchants preferred sized of challenge window presented to cardholder
|
||||
/*
|
||||
1 – 250 x 400
|
||||
2 – 390x400
|
||||
3 – 500x600
|
||||
4 – 600x400
|
||||
5 – 100%
|
||||
*/
|
||||
|
||||
"ChallengeIndicator" => "01" , // Conditional value – if supported
|
||||
/*
|
||||
01 = No preference
|
||||
02 = No challenge requested
|
||||
03 = Challenge requested: 3DS Requestor Preference
|
||||
04 = Challenge requested: Mandate Default value if not provided is that ACS would interpret as: 01 = No preference.
|
||||
*/
|
||||
],
|
||||
'MerchantResponseURL' => $input['ipn_url']
|
||||
]
|
||||
]);
|
||||
$result = $response->object();
|
||||
if (property_exists($result,'RedirectData')){
|
||||
return $result->RedirectData;
|
||||
}
|
||||
$error_message = 'payment failed';
|
||||
if (property_exists($result,'Errors')){
|
||||
$error = $result->Errors;
|
||||
$error_message = current($error)->Message ?? __("payment credentials failed");
|
||||
}
|
||||
abort(501,$error_message);
|
||||
}
|
||||
|
||||
|
||||
public function supported_currency_list() : array
|
||||
{
|
||||
/*
|
||||
* Supported Currencies
|
||||
*
|
||||
United States (USD)
|
||||
East Caribbean (XCD)
|
||||
Trinidad and Tobago (TTD)
|
||||
Jamaica (JMD)
|
||||
Barbados (BBD)
|
||||
Bahamas (BSD)
|
||||
Belize (BZD)
|
||||
Dominican Republic (DOP)
|
||||
Guyana (GYD)
|
||||
Cayman Islands (KYD)
|
||||
Honduras (HNL)
|
||||
El Salvador (SVC)
|
||||
Costa Rica (CRC)
|
||||
Nicaragua (NIO)
|
||||
Panama (PAB)
|
||||
|
||||
*
|
||||
* */
|
||||
return ['USD','XCD','TTD','JMD','BBD','BSD','BZD','DOP','GYD','KYD','HNL','SVC','CRC','NIO','PAB'];
|
||||
}
|
||||
|
||||
public function charge_currency() : string
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
public function gateway_name() : string
|
||||
{
|
||||
return 'powertranz';
|
||||
}
|
||||
|
||||
private function base_url($environment =false){
|
||||
return $environment ? 'https://staging.ptranz.com/api/spi/' : 'https://TBD.ptranz.com/api/spi/';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Razorpay\Api\Api;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class RazorPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport,IndianCurrencySupport;
|
||||
|
||||
protected $api_key;
|
||||
protected $api_secret;
|
||||
|
||||
public function setApiKey($api_key){
|
||||
$this->api_key = $api_key;
|
||||
return $this;
|
||||
}
|
||||
private function getApiKey(){
|
||||
return $this->api_key;
|
||||
}
|
||||
public function setApiSecret($api_secret){
|
||||
$this->api_secret = $api_secret;
|
||||
return $this;
|
||||
}
|
||||
private function getApiSecret(){
|
||||
return $this->api_secret;
|
||||
}
|
||||
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->is_decimal($amount) ? $amount : $amount;
|
||||
}
|
||||
return $this->is_decimal( $this->get_amount_in_inr($amount)) ? $this->get_amount_in_inr($amount) : $this->get_amount_in_inr($amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* */
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
$order_id = random_int(12345,99999).$args['order_id'].random_int(12345,99999);
|
||||
$razorpay_data['currency'] = $this->charge_currency();
|
||||
$razorpay_data['price'] = $this->charge_amount($args['amount']);
|
||||
$razorpay_data['title'] = $args['title'];
|
||||
$razorpay_data['description'] = $args['description'];
|
||||
$razorpay_data['route'] = $args['ipn_url'];
|
||||
$razorpay_data['order_id'] = $order_id;
|
||||
$razorpay_data['api_key'] = $this->getApiKey();
|
||||
session()->put('razorpay_last_order_id',$order_id);
|
||||
|
||||
abort_if(is_null($this->getApiKey()),405,'razorpay api key is missing');
|
||||
|
||||
return view('paymentgateway::razorpay')->with('razorpay_data', $razorpay_data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
$request = request();
|
||||
$razorpay_payment_id = request()->razorpay_payment_id;
|
||||
|
||||
abort_if(is_null($this->getApiKey()),405,'razorpay api key is missing');
|
||||
abort_if(is_null($this->getApiSecret()),405,'razorpay api secret is missing');
|
||||
//get API Configuration
|
||||
//Fetch payment information by razorpay_payment_id
|
||||
$reponse = Http::withBasicAuth(
|
||||
$this->getApiKey(),
|
||||
$this->getApiSecret()
|
||||
)->get($this->baseApi(). 'payments/'.$razorpay_payment_id);
|
||||
|
||||
if ($reponse->ok()){
|
||||
$res_object = $reponse->object();
|
||||
$amount = $res_object->amount;
|
||||
$currency =$this->getCurrency();
|
||||
|
||||
if (in_array($res_object->status,['paid','authorized'])){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'order_id' => substr( request()->order_id,5,-5),
|
||||
'payment_amount' => $amount,
|
||||
'transaction_id' => $razorpay_payment_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'razorpay';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "INR";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return ['INR'];
|
||||
}
|
||||
|
||||
public function baseApi(){
|
||||
return 'https://api.razorpay.com/v1/';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,302 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Srmklive\PayPal\Services\PayPal as PayPalClient;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use net\authorize\api\contract\v1 as AnetAPI;
|
||||
use net\authorize\api\controller as AnetController;
|
||||
|
||||
class SaltPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment, CurrencySupport, ConvertUsdSupport;
|
||||
|
||||
private $merchantId;
|
||||
private $secretkey;
|
||||
private $langpaymentPage = 'en'; //supported
|
||||
private $paymentGatewayId;
|
||||
|
||||
public function setMerchantId($merchantId)
|
||||
{
|
||||
$this->merchantId = $merchantId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->merchantId;
|
||||
}
|
||||
|
||||
public function setSecretKey($secretkey)
|
||||
{
|
||||
$this->secretkey = $secretkey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecretKey()
|
||||
{
|
||||
return $this->secretkey;
|
||||
}
|
||||
|
||||
public function setLangPaymentPage($langpaymentPage)
|
||||
{
|
||||
$this->langpaymentPage = $langpaymentPage;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLangPaymentPage()
|
||||
{
|
||||
return $this->langpaymentPage;
|
||||
}
|
||||
|
||||
public function setPaymentGatewayId($paymentGatewayId)
|
||||
{
|
||||
$this->paymentGatewayId = $paymentGatewayId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPaymentGatewayId()
|
||||
{
|
||||
return $this->paymentGatewayId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Available Languages
|
||||
|
||||
'is' => Icelandi
|
||||
'en' => English
|
||||
'de' => German
|
||||
'fr' => French
|
||||
'it' => Italian
|
||||
'pt' => Portugese
|
||||
'ru' => Russian
|
||||
'es' => Spanish
|
||||
'se' => Swedish
|
||||
'hu' => Hungarian
|
||||
'si' => Slovene
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return number_format($amount,2);
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for
|
||||
* */
|
||||
|
||||
public function view($args)
|
||||
{
|
||||
$salt_pay_args = array_merge($args, [
|
||||
'gateway_id' => $this->getPaymentGatewayId(),
|
||||
'merchantid' => $this->getMerchantId(),
|
||||
'language' => in_array($this->getLangPaymentPage(), $this->getAvilableLanguage()) ? $this->getLangPaymentPage() : 'en',
|
||||
'currency' => $this->getCurrency(),
|
||||
'charge_amount' => $this->charge_amount($args['amount']),
|
||||
'environment' => $this->getEnv(),
|
||||
'order_id' => PaymentGatewayHelpers::wrapped_id($args['order_id']),
|
||||
'action_url' => $this->getBaseUrl() . 'default.aspx',
|
||||
'reference' => $args['payment_type']
|
||||
]);
|
||||
$salt_pay_args['checkhash'] = $this->generateCheckHash($salt_pay_args);
|
||||
|
||||
return view('paymentgateway::saltpay', ['saltpay_data' => $salt_pay_args]);
|
||||
}
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
//todo:: format data for send in blade file for get user card details
|
||||
return $this->view($args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = [])
|
||||
{
|
||||
|
||||
$request = request();
|
||||
$status = $request->status;
|
||||
$orderid = $request->orderid;
|
||||
$reference_string = $request->reference;
|
||||
$reference = $reference_string;
|
||||
$order_amount = $request->amount;
|
||||
|
||||
$orderhash = $request->orderhash;
|
||||
$step = $request->step;
|
||||
|
||||
$errordescription = $request->errordescription;
|
||||
$errorcode = $request->errorcode;
|
||||
$errordescription = $request->errordescription;
|
||||
|
||||
|
||||
|
||||
$authorizationcode = $request->authorizationcode;
|
||||
$refundid = $request->refundid;
|
||||
|
||||
|
||||
|
||||
if($status === 'OK' && !empty($orderid)){
|
||||
if (hash_equals($orderhash,$this->getCheckoutHash($order_amount,$orderid))){
|
||||
//todo:: hash verified, now make an api call to cross check the payment is actually maid or not
|
||||
if ( strpos( $step, 'Payment' ) !== false ) {
|
||||
$xml = '<PaymentNotification>Accepted</PaymentNotification>';
|
||||
|
||||
//send resopnse to saltpay that we have received the notification
|
||||
try
|
||||
{
|
||||
Http::
|
||||
withHeaders([
|
||||
'Content-Type' => 'text/xml'
|
||||
])
|
||||
->timeout(60)
|
||||
->withoutVerifying()
|
||||
->maxRedirects(5)
|
||||
->post($this->getBaseUrl(). 'default.aspx',[
|
||||
'postdata' => $xml, 'postfield' => 'value'
|
||||
]);
|
||||
|
||||
|
||||
}catch (\Exception $e){
|
||||
// abort(501,'failed to send data to salt pay');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $authorizationcode,
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($orderid),
|
||||
'order_type' => $reference
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id(request()->get('order_id')),
|
||||
'order_type' => $reference
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'saltpay';
|
||||
}
|
||||
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['ISK', 'USD', 'EUR', 'GBP', 'DKK', 'NOK', 'SEK', 'CHF', 'JPY', 'CAD', 'HUF'];
|
||||
}
|
||||
|
||||
|
||||
private function getBaseUrl()
|
||||
{
|
||||
//true=sandbox, false=live
|
||||
return $this->getEnv() ? 'https://test.borgun.is/securepay/' : 'https://securepay.borgun.is/securepay/';
|
||||
}
|
||||
|
||||
private function getAvilableLanguage()
|
||||
{
|
||||
return ['is', 'en', 'de', 'fr', 'it', 'pt', 'ru', 'es', 'se', 'hu', 'si'];
|
||||
}
|
||||
|
||||
private function generateCheckHash($args)
|
||||
{
|
||||
|
||||
//Formual
|
||||
//CheckHashMessage = MerchantId|ReturnUrlSuccess|ReturnUrlSuccessServer|OrderId|Amount|Currency -> this is for payment page
|
||||
//OrderHashMessage = OrderId|Amount|Currency -> this is for payment verify
|
||||
|
||||
$secretKey = $this->getSecretKey();
|
||||
$hashMessagesParams = [
|
||||
$args['merchantid'],
|
||||
$args['ipn_url'],
|
||||
$args['ipn_url'],
|
||||
$args['order_id'],
|
||||
$args['charge_amount'],
|
||||
$args['currency'],
|
||||
];
|
||||
$CheckHashMessage = implode('|', $hashMessagesParams);
|
||||
|
||||
$message = utf8_encode(trim($CheckHashMessage));
|
||||
$checkhash = hash_hmac('sha256', $message, $secretKey);
|
||||
return $checkhash;
|
||||
}
|
||||
|
||||
private function getCheckoutHash(string $order_amount, mixed $orderid)
|
||||
{
|
||||
//formula
|
||||
//orderid|amount|Currency
|
||||
|
||||
$secretKey = $this->getSecretKey();
|
||||
$hashMessagesParams = [
|
||||
$orderid,
|
||||
$order_amount,
|
||||
$this->getCurrency()
|
||||
];
|
||||
$CheckHashMessage = implode('|', $hashMessagesParams);
|
||||
|
||||
$message = utf8_encode(trim($CheckHashMessage));
|
||||
$checkhash = hash_hmac('sha256', $message, $secretKey);
|
||||
return $checkhash;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Base\RecurringSupport;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\IndianCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\MyanmarCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use CinetPay\CinetPay as CinetPayment;
|
||||
|
||||
class Senangpay extends PaymentGatewayBase implements RecurringSupport
|
||||
{
|
||||
|
||||
use CurrencySupport,PaymentEnvironment,MyanmarCurrencySupport;
|
||||
|
||||
protected $merchant_id;
|
||||
protected $secret_key;
|
||||
protected $hash_method = "sha256";
|
||||
private $recurring_id;
|
||||
|
||||
|
||||
public function setMerchantId($merchant_id){
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
public function getMerchantId(){
|
||||
return $this->merchant_id;
|
||||
}
|
||||
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
public function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
|
||||
public function setHashMethod($hash_method){
|
||||
$this->hash_method = $hash_method;
|
||||
return $this;
|
||||
}
|
||||
public function getHashMethod(){
|
||||
return $this->hash_method;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_myr($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
|
||||
|
||||
|
||||
$response = $this->verifyTransaction();
|
||||
// dd($response,request()->all());
|
||||
if ($response->ok()){
|
||||
//write code for verify the transaction
|
||||
$response = $response->object();
|
||||
$data = current($response->data);
|
||||
$transaction_reference = $data->payment_info?->transaction_reference;
|
||||
if ($data->payment_info?->status !== "failed" && !empty($transaction_reference)){
|
||||
$pname = $data->product?->product_name;
|
||||
$payment_type = Str::of($pname)->after("##")->trim()->__toString();
|
||||
return [
|
||||
'status' => 'complete',
|
||||
"order_id" => XgPaymentGateway::unwrapped_id(request()->get('order_id')),
|
||||
"payment_type" => $payment_type,
|
||||
'transaction_id' => $transaction_reference
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => 'failed',"order_id" => XgPaymentGateway::unwrapped_id(request()->get('order_id'))];
|
||||
}
|
||||
|
||||
private function getTransactionStatusCheckApiUrl(){
|
||||
return $this->getEnv() ? 'https://sandbox.senangpay.my/apiv1/query_transaction_status/' : 'https://app.senangpay.my/apiv1/query_transaction_status/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
|
||||
$merchant_id = $this->getMerchantId();
|
||||
$api_url = $this->getApiBaseUrl();
|
||||
|
||||
# Prepare the data to send to senangPay
|
||||
$order_id = XgPaymentGateway::wrapped_id($args['order_id']);
|
||||
$detail = "payment_type_##" . $args["payment_type"]; //here we can append payment_type
|
||||
$amount = $this->charge_amount($args['amount']);
|
||||
|
||||
if($amount < 2){
|
||||
abort(501,__("minimum amount should be getter than 2RM"));
|
||||
}
|
||||
|
||||
$hash_value = $this->getHasKey($detail,$amount,$order_id);;
|
||||
$name = $args['name'];
|
||||
$email = $args['email'];
|
||||
$phone = $args['phone'] ?? " ";
|
||||
|
||||
/* post data */
|
||||
$post_args = array(
|
||||
'detail' => $detail,
|
||||
'amount' => $amount,
|
||||
'order_id' => $order_id,
|
||||
'hash' => $hash_value,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'phone' => $phone
|
||||
);
|
||||
|
||||
# Format it properly using get
|
||||
$senangpay_args = http_build_query($post_args);
|
||||
$url = $api_url . $merchant_id . '?' . $senangpay_args;
|
||||
return redirect($url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ["MYR"];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "MYR";
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'senangpay';
|
||||
}
|
||||
|
||||
private function getApiBaseUrl()
|
||||
{
|
||||
return $this->getEnv() ? 'https://sandbox.senangpay.my/payment/' : 'https://app.senangpay.my/payment/';
|
||||
}
|
||||
|
||||
|
||||
private function getApiBaseUrlRecurring()
|
||||
{
|
||||
return $this->getEnv() ? 'https://api.sandbox.senangpay.my/recurring/payment/' : 'https://api.senangpay.my/recurring/payment/';
|
||||
}
|
||||
|
||||
private function getHasKey(string $detail, mixed $amount, string $order_id)
|
||||
{
|
||||
return match ($this->getHashMethod()) {
|
||||
'md5' => $this->getMd5Hash($detail, $amount, $order_id),
|
||||
default => $this->getSha256Hash($detail, $amount, $order_id)
|
||||
};
|
||||
}
|
||||
|
||||
private function getMd5Hash(string $detail, mixed $amount, string $order_id)
|
||||
{
|
||||
return md5($this->getSecretKey() . $detail . $amount . $order_id);
|
||||
}
|
||||
|
||||
private function getSha256Hash(string $detail, mixed $amount, string $order_id)
|
||||
{
|
||||
return hash_hmac('sha256', $this->getSecretKey() . $detail . $amount . $order_id, $this->getSecretKey());
|
||||
}
|
||||
|
||||
private function hashKeyForTransactionVerify(string $secretkey, string $hash_type, string $merchant_id, mixed $transaction_reference)
|
||||
{
|
||||
return match ($hash_type) {
|
||||
'md5' => $this->getMd5HashForTransactionVerify($secretkey, $merchant_id, $transaction_reference),
|
||||
default => $this->getSha256HashForTransactionVerify($secretkey, $merchant_id, $transaction_reference)
|
||||
};
|
||||
}
|
||||
|
||||
private function getMd5HashForTransactionVerify(string $secretkey, string $merchant_id, mixed $transaction_reference)
|
||||
{
|
||||
return md5($merchant_id . $secretkey . $transaction_reference);
|
||||
}
|
||||
|
||||
private function getSha256HashForTransactionVerify(string $secretkey, string $merchant_id, mixed $transaction_reference)
|
||||
{
|
||||
return hash_hmac('sha256', $merchant_id . $secretkey . $transaction_reference, $secretkey);
|
||||
}
|
||||
|
||||
|
||||
public function charge_customer_recurring(array $args)
|
||||
{
|
||||
$url = $this->getApiBaseUrlRecurring().$this->getMerchantId();
|
||||
|
||||
|
||||
$order_param = 'payment_type_###'.$args['payment_type'].'##'.XgPaymentGateway::wrapped_id($args['order_id']);
|
||||
$amount = $this->charge_amount($args['amount']);
|
||||
|
||||
if($amount < 2){
|
||||
abort(501,__("minimum amount should be getter than 2RM"));
|
||||
}
|
||||
|
||||
$params = http_build_query([
|
||||
'order_id' => $order_param,
|
||||
'recurring_id' => $this->getRecurringId(),
|
||||
'hash' => $this->getHashForRecurringPayment($order_param,$amount),
|
||||
'name' => $args['name'],
|
||||
'email' => $args['email'],
|
||||
'phone' => $args['phone'] ?? " ",
|
||||
'amount' => $amount
|
||||
]);
|
||||
|
||||
// dd($url,$params);
|
||||
$url = $url.'?'.$params;
|
||||
|
||||
return redirect($url);
|
||||
}
|
||||
|
||||
public function ipn_response_recurring(array $args = [])
|
||||
{
|
||||
$response = $this->verifyTransaction();
|
||||
if ($response->ok()){
|
||||
//write code for verify the transaction
|
||||
$response = $response->object();
|
||||
$data = current($response->data);
|
||||
$transaction_reference = $data->payment_info?->transaction_reference;
|
||||
if ($data->payment_info?->status !== "failed" && !empty($transaction_reference)){
|
||||
$payment_type = Str::of(request()->get('order_id'))->after('###')->before('##')->__toString();
|
||||
$order_id = Str::of(request()->get('order_id'))->after('##')->after('##')->__toString();
|
||||
return [
|
||||
'status' => 'complete',
|
||||
"order_id" => XgPaymentGateway::unwrapped_id($order_id),
|
||||
"payment_type" => $payment_type,
|
||||
'transaction_id' => $transaction_reference
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => 'failed',"order_id" => XgPaymentGateway::unwrapped_id(request()->get('order_id'))];
|
||||
}
|
||||
|
||||
private function getHashForRecurringPayment(mixed $order_id,$amount)
|
||||
{
|
||||
return match ($this->getHashMethod()) {
|
||||
'md5' => $this->getMd5HashForRecurringPayment($order_id,$amount),
|
||||
default => $this->getSha256HashForRecurringPayment($order_id,$amount)
|
||||
};
|
||||
}
|
||||
|
||||
private function getMd5HashForRecurringPayment(mixed $order_id,float|string|int $amount)
|
||||
{
|
||||
return md5($this->getSecretKey() . $this->getRecurringId() . $order_id.$amount);
|
||||
}
|
||||
|
||||
private function getSha256HashForRecurringPayment(mixed $order_id,float|string|int $amount)
|
||||
{
|
||||
return hash('sha256', $this->getSecretKey() . $this->getRecurringId() . $order_id.$amount);
|
||||
}
|
||||
|
||||
public function setRecurringId($recurring_id)
|
||||
{
|
||||
$this->recurring_id = $recurring_id;
|
||||
return $this;
|
||||
}
|
||||
public function getRecurringId(){
|
||||
return $this->recurring_id;
|
||||
}
|
||||
|
||||
private function verifyTransaction()
|
||||
{
|
||||
$secretkey = $this->getSecretKey();
|
||||
$hash_type = $this->getHashMethod();
|
||||
$merchant_id = $this->getMerchantId();
|
||||
$transaction_reference = request()->get('transaction_id');
|
||||
|
||||
$hash = $this->hashKeyForTransactionVerify($secretkey,$hash_type,$merchant_id,$transaction_reference);
|
||||
$url = $this->getTransactionStatusCheckApiUrl().$transaction_reference;
|
||||
|
||||
$response = Http::withBasicAuth($this->getMerchantId(),'')->get($url,[
|
||||
'merchant_id' => $this->getMerchantId(),
|
||||
'transaction_reference' => $transaction_reference,
|
||||
'hash' => $hash
|
||||
]);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class SitesWayPay extends PaymentGatewayBase
|
||||
{
|
||||
use PaymentEnvironment,CurrencySupport,ConvertUsdSupport;
|
||||
protected $brand_id;
|
||||
protected $api_key;
|
||||
protected $endpoint = 'https://gate.sitesway.sa/api/v1/';
|
||||
|
||||
/* get getBrandId */
|
||||
private function getBrandId(){
|
||||
return $this->brand_id;
|
||||
}
|
||||
/* set setBrandId */
|
||||
public function setBrandId($brand_id){
|
||||
$this->brand_id = $brand_id;
|
||||
return $this;
|
||||
}
|
||||
/* set setApiKey */
|
||||
public function setApiKey($api_key){
|
||||
$this->api_key = $api_key;
|
||||
return $this;
|
||||
}
|
||||
/* get getApiKey */
|
||||
private function getApiKey(){
|
||||
return $this->api_key;
|
||||
}
|
||||
/*
|
||||
* charge_amount();
|
||||
* @required param list
|
||||
* $amount
|
||||
*
|
||||
*
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['amount']
|
||||
* $args['description']
|
||||
* $args['item_name']
|
||||
* $args['ipn_url']
|
||||
* $args['cancel_url']
|
||||
* $args['payment_track']
|
||||
* return redirect url for paypal
|
||||
* */
|
||||
|
||||
|
||||
public function charge_customer($args)
|
||||
{
|
||||
|
||||
try {
|
||||
$res = Http::withToken($this->getApiKey())->asJson()->post($this->endpoint.'purchases/', [
|
||||
"client" => [
|
||||
"email" => $args['email'],
|
||||
"full_name" => $args['name']
|
||||
],
|
||||
"purchase" => [
|
||||
"currency" => $this->getCurrency(), //default SAR
|
||||
"products" => [
|
||||
[
|
||||
"name" => $args['title'],
|
||||
"price" => $this->charge_amount($args['amount']) * 100 //price need to multiply by 100
|
||||
]
|
||||
]
|
||||
],
|
||||
"brand_id" => $this->getBrandId(),
|
||||
"success_redirect" => $args['success_url'],
|
||||
"failure_redirect" => $args['cancel_url'],
|
||||
"cancel_redirect" => $args['cancel_url'],
|
||||
"success_callback" => $args['ipn_url'],
|
||||
"reference" => json_encode([
|
||||
'order_id' => PaymentGatewayHelpers::wrapped_id($args['order_id']),
|
||||
'payment_type' => $args['payment_type']
|
||||
])
|
||||
]);
|
||||
|
||||
$response_object = $res->object();
|
||||
|
||||
if (is_object($response_object) && property_exists($response_object,"checkout_url")){
|
||||
$redirect_url = $response_object->checkout_url;
|
||||
return redirect()->away($redirect_url); //redirect to the payment provider website for complete payment
|
||||
}
|
||||
if (is_object($response_object) && property_exists($response_object,'__all__')){
|
||||
abort(500,current($response_object->__all__)->message);
|
||||
}
|
||||
|
||||
}catch (\Exception $e){
|
||||
abort(500,$e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @required param list
|
||||
* $args['request']
|
||||
* $args['cancel_url']
|
||||
* $args['success_url']
|
||||
*
|
||||
* return @void
|
||||
* */
|
||||
public function ipn_response($args = []){
|
||||
|
||||
$purchase_id = request()->id;
|
||||
$reference = json_decode(request()->reference);
|
||||
$res = Http::withToken($this->getApiKey())
|
||||
->acceptJson()
|
||||
->get($this->endpoint."purchases/{$purchase_id}/");
|
||||
$response_object = $res->object();
|
||||
if (is_object($response_object) && property_exists($response_object,"status")){
|
||||
|
||||
|
||||
if ($response_object->status === "paid"){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $purchase_id ,
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($reference->order_id ?? ""),
|
||||
'order_type' => $reference->payment_type ?? ""
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
if (is_object($response_object) && property_exists($response_object,'__all__')){
|
||||
abort(500,current($response_object->__all__)->message);
|
||||
}
|
||||
|
||||
return $this->verified_data([
|
||||
'status' => 'failed',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($reference->order_id ?? ""),
|
||||
'order_type' => $reference->payment_type ?? ""
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* geteway_name();
|
||||
* return @string
|
||||
* */
|
||||
public function gateway_name(){
|
||||
return 'sitesway';
|
||||
}
|
||||
/**
|
||||
* charge_currency();
|
||||
* return @string
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $this->getCurrency();
|
||||
}
|
||||
return "USD";
|
||||
}
|
||||
/**
|
||||
* supported_currency_list();
|
||||
* it will returl all of supported currency for the payment gateway
|
||||
* return array
|
||||
* */
|
||||
public function supported_currency_list(){
|
||||
return [
|
||||
'USD',
|
||||
'EUR',
|
||||
'INR',
|
||||
'IDR',
|
||||
'AUD',
|
||||
'SGD',
|
||||
'JPY',
|
||||
'GBP',
|
||||
'MYR',
|
||||
'PHP',
|
||||
'THB',
|
||||
'KRW',
|
||||
'NGN',
|
||||
'GHS',
|
||||
'BRL',
|
||||
'BIF',
|
||||
'CAD',
|
||||
'CDF',
|
||||
'CVE',
|
||||
'GHP',
|
||||
'GMD',
|
||||
'GNF',
|
||||
'KES',
|
||||
'LRD',
|
||||
'MWK',
|
||||
'MZN',
|
||||
'RWF',
|
||||
'SLL',
|
||||
'STD',
|
||||
'TZS',
|
||||
'UGX',
|
||||
'XAF',
|
||||
'XOF',
|
||||
'ZMK',
|
||||
'ZMW',
|
||||
'ZWD',
|
||||
'AED',
|
||||
'AFN',
|
||||
'ALL',
|
||||
'AMD',
|
||||
'ANG',
|
||||
'AOA',
|
||||
'ARS',
|
||||
'AWG',
|
||||
'AZN',
|
||||
'BAM',
|
||||
'BBD',
|
||||
'BDT',
|
||||
'BGN',
|
||||
'BMD',
|
||||
'BND',
|
||||
'BOB',
|
||||
'BSD',
|
||||
'BWP',
|
||||
'BZD',
|
||||
'CHF',
|
||||
'CNY',
|
||||
'CLP',
|
||||
'COP',
|
||||
'CRC',
|
||||
'CZK',
|
||||
'DJF',
|
||||
'DKK',
|
||||
'DOP',
|
||||
'DZD',
|
||||
'EGP',
|
||||
'ETB',
|
||||
'FJD',
|
||||
'FKP',
|
||||
'GEL',
|
||||
'GIP',
|
||||
'GTQ',
|
||||
'GYD',
|
||||
'HKD',
|
||||
'HNL',
|
||||
'HRK',
|
||||
'HTG',
|
||||
'HUF',
|
||||
'ILS',
|
||||
'ISK',
|
||||
'JMD',
|
||||
'KGS',
|
||||
'KHR',
|
||||
'KMF',
|
||||
'KYD',
|
||||
'KZT',
|
||||
'LAK',
|
||||
'LBP',
|
||||
'LKR',
|
||||
'LSL',
|
||||
'MAD',
|
||||
'MDL',
|
||||
'MGA',
|
||||
'MKD',
|
||||
'MMK',
|
||||
'MNT',
|
||||
'MOP',
|
||||
'MRO',
|
||||
'MUR',
|
||||
'MVR',
|
||||
'MXN',
|
||||
'NAD',
|
||||
'NIO',
|
||||
'NOK',
|
||||
'NPR',
|
||||
'NZD',
|
||||
'PAB',
|
||||
'PEN',
|
||||
'PGK',
|
||||
'PKR',
|
||||
'PLN',
|
||||
'PYG',
|
||||
'QAR',
|
||||
'RON',
|
||||
'RSD',
|
||||
'RUB',
|
||||
'SAR',
|
||||
'SBD',
|
||||
'SCR',
|
||||
'SEK',
|
||||
'SHP',
|
||||
'SOS',
|
||||
'SRD',
|
||||
'SZL',
|
||||
'TJS',
|
||||
'TRY',
|
||||
'TTD',
|
||||
'TWD',
|
||||
'UAH',
|
||||
'UYU',
|
||||
'UZS',
|
||||
'VND',
|
||||
'VUV',
|
||||
'WST',
|
||||
'XCD',
|
||||
'XPF',
|
||||
'YER',
|
||||
'ZAR',
|
||||
'BHD'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,410 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Square\SquareClient;
|
||||
use Square\Environment;
|
||||
use Square\Exceptions\ApiException;
|
||||
use Square\Models\Money;
|
||||
use Square\Models\CreateOrderRequest;
|
||||
use Square\Models\CreateCheckoutRequest;
|
||||
use Square\Models\Order;
|
||||
use Square\Models\OrderLineItem;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class SquarePay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
use PaymentEnvironment, CurrencySupport;
|
||||
|
||||
protected $application_id;
|
||||
protected $access_token;
|
||||
protected $location_id;
|
||||
|
||||
public function setApplicationId($application_id)
|
||||
{
|
||||
$this->application_id = $application_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationId()
|
||||
{
|
||||
return $this->application_id;
|
||||
}
|
||||
|
||||
public function setAccessToken($access_token)
|
||||
{
|
||||
$this->access_token = $access_token;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->access_token;
|
||||
}
|
||||
|
||||
public function setLocationId($location_id)
|
||||
{
|
||||
$this->location_id = $location_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocationId()
|
||||
{
|
||||
return $this->location_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* this payment gateway will not work without this package
|
||||
* @https://github.com/stripe/stripe-php
|
||||
* @since .0.01
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())) {
|
||||
return $amount * 100;
|
||||
}
|
||||
return $amount * 100;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
* required param list
|
||||
*
|
||||
* @return string[]
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public function ipn_response(array $args = []): array
|
||||
{
|
||||
|
||||
$square_order_id = session()->get('square_order_id');
|
||||
session()->forget('square_order_id');
|
||||
|
||||
$client = $this->setConfig();
|
||||
$transaction_id = \request()->get('transactionId');
|
||||
try {
|
||||
$orders_api = $client->getOrdersApi();
|
||||
$response = $orders_api->retrieveOrder($transaction_id);
|
||||
} catch (ApiException $e) {
|
||||
// If an error occurs, output the message
|
||||
echo 'Caught exception!<br/>';
|
||||
echo '<strong>Response body:</strong><br/>';
|
||||
echo '<pre>';
|
||||
var_dump($e->getResponseBody());
|
||||
echo '</pre>';
|
||||
echo '<br/><strong>Context:</strong><br/>';
|
||||
echo '<pre>';
|
||||
var_dump($e->getContext());
|
||||
echo '</pre>';
|
||||
exit();
|
||||
}
|
||||
|
||||
// If there was an error with the request we will
|
||||
// print them to the browser screen here
|
||||
if ($response->isError()) {
|
||||
echo 'Api response has Errors';
|
||||
$errors = $response->getErrors();
|
||||
echo '<ul>';
|
||||
foreach ($errors as $error) {
|
||||
echo '<li>❌ ' . $error->getDetail() . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
exit();
|
||||
} else {
|
||||
$order = $response->getResult()->getOrder();
|
||||
if($order->getState() === 'COMPLETED'){
|
||||
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $order->getId(),
|
||||
'order_id' => $square_order_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
* required param list
|
||||
*
|
||||
* product_name
|
||||
* amount
|
||||
* description
|
||||
* ipn_url
|
||||
* cancel_url
|
||||
* order_id
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$client = $this->setConfig();
|
||||
$location_id = $this->getLocationId();
|
||||
|
||||
try {
|
||||
$checkout_api = $client->getCheckoutApi();
|
||||
$currency = $client->getLocationsApi()->retrieveLocation($location_id)->getResult()->getLocation()->getCurrency();
|
||||
$money_A = new Money();
|
||||
$money_A->setCurrency($this->getCurrency());
|
||||
$money_A->setAmount(round($this->charge_amount($args['amount']),2));
|
||||
|
||||
$item_A = new OrderLineItem(1);
|
||||
$item_A->setName($args['title']);
|
||||
$item_A->setBasePriceMoney($money_A);
|
||||
|
||||
// Create a new order and add the line items as necessary.
|
||||
$order = new Order($location_id);
|
||||
$order->setLineItems([$item_A]);
|
||||
$create_order_request = new CreateOrderRequest();
|
||||
$create_order_request->setOrder($order);
|
||||
|
||||
// Similar to payments you must have a unique idempotency key.
|
||||
$checkout_request = new CreateCheckoutRequest(uniqid(), $create_order_request);
|
||||
// Set a custom redirect URL, otherwise a default Square confirmation page will be used
|
||||
$checkout_request->setRedirectUrl($args['ipn_url']);
|
||||
session()->put('square_order_id', $args['order_id']);
|
||||
$response = $checkout_api->createCheckout($location_id, $checkout_request);
|
||||
} catch (ApiException $e) {
|
||||
// If an error occurs, output the message
|
||||
abort(401,$e->getResponseBody().' '.$e->getContext());
|
||||
}
|
||||
|
||||
if ($response->isError()) {
|
||||
echo 'Api response has Errors';
|
||||
$errors = $response->getErrors();
|
||||
echo '<ul>';
|
||||
foreach ($errors as $error) {
|
||||
echo '<li>❌ ' . $error->getDetail() . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
exit();
|
||||
}
|
||||
|
||||
return redirect()->away($response->getResult()->getCheckout()->getCheckoutPageUrl());
|
||||
}
|
||||
|
||||
private function setConfig(){
|
||||
$client = new SquareClient([
|
||||
'accessToken' => $this->getAccessToken(),
|
||||
'environment' => $this->getEnv() ? 'sandbox' : 'production', //Environment::PRODUCTION,
|
||||
]);
|
||||
return $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* this will refund payment gateway charge currency
|
||||
* @since 0.0.1
|
||||
* */
|
||||
public function supported_currency_list(): array
|
||||
{
|
||||
return [
|
||||
"AUD",
|
||||
"CAD",
|
||||
"EUR",
|
||||
"GBP",
|
||||
"JPY",
|
||||
"USD",
|
||||
"AED",
|
||||
"AFN",
|
||||
"ALL",
|
||||
"AMD",
|
||||
"ANG",
|
||||
"AOA",
|
||||
"ARS",
|
||||
"AUD",
|
||||
"AWG",
|
||||
"AZN",
|
||||
"BAM",
|
||||
"BBD",
|
||||
"BDT",
|
||||
"BGN",
|
||||
"BHD",
|
||||
"BIF",
|
||||
"BMD",
|
||||
"BND",
|
||||
"BOB",
|
||||
"BOV",
|
||||
"BRL",
|
||||
"BSD",
|
||||
"BTN",
|
||||
"BWP",
|
||||
"BYR",
|
||||
"BZD",
|
||||
"CAD",
|
||||
"CDF",
|
||||
"CHE",
|
||||
"CHF",
|
||||
"CHW",
|
||||
"CLF",
|
||||
"CLP",
|
||||
"CNY",
|
||||
"COP",
|
||||
"COU",
|
||||
"CRC",
|
||||
"CUC",
|
||||
"CUP",
|
||||
"CVE",
|
||||
"CZK",
|
||||
"DJF",
|
||||
"DKK",
|
||||
"DOP",
|
||||
"DZD",
|
||||
"EGP",
|
||||
"ERN",
|
||||
"ETB",
|
||||
"EUR",
|
||||
"FJD",
|
||||
"FKP",
|
||||
"GBP",
|
||||
"GEL",
|
||||
"GHS",
|
||||
"GIP",
|
||||
"GMD",
|
||||
"GNF",
|
||||
"GTQ",
|
||||
"GYD",
|
||||
"HKD",
|
||||
"HNL",
|
||||
"HRK",
|
||||
"HTG",
|
||||
"HUF",
|
||||
"IDR",
|
||||
"ILS",
|
||||
"INR",
|
||||
"IQD",
|
||||
"IRR",
|
||||
"ISK",
|
||||
"JMD",
|
||||
"JOD",
|
||||
"JPY",
|
||||
"KES",
|
||||
"KGS",
|
||||
"KHR",
|
||||
"KMF",
|
||||
"KPW",
|
||||
"KRW",
|
||||
"KWD",
|
||||
"KYD",
|
||||
"KZT",
|
||||
"LAK",
|
||||
"LBP",
|
||||
"LKR",
|
||||
"LRD",
|
||||
"LSL",
|
||||
"LTL",
|
||||
"LVL",
|
||||
"LYD",
|
||||
"MAD",
|
||||
"MDL",
|
||||
"MGA",
|
||||
"MKD",
|
||||
"MMK",
|
||||
"MNT",
|
||||
"MOP",
|
||||
"MRO",
|
||||
"MUR",
|
||||
"MVR",
|
||||
"MWK",
|
||||
"MXN",
|
||||
"MXV",
|
||||
"MYR",
|
||||
"MZN",
|
||||
"NAD",
|
||||
"NGN",
|
||||
"NIO",
|
||||
"NOK",
|
||||
"NPR",
|
||||
"NZD",
|
||||
"OMR",
|
||||
"PAB",
|
||||
"PEN",
|
||||
"PGK",
|
||||
"PHP",
|
||||
"PKR",
|
||||
"PLN",
|
||||
"PYG",
|
||||
"QAR",
|
||||
"RON",
|
||||
"RSD",
|
||||
"RUB",
|
||||
"RWF",
|
||||
"SAR",
|
||||
"SBD",
|
||||
"SCR",
|
||||
"SDG",
|
||||
"SEK",
|
||||
"SGD",
|
||||
"SHP",
|
||||
"SLL",
|
||||
"SOS",
|
||||
"SRD",
|
||||
"SSP",
|
||||
"STD",
|
||||
"SVC",
|
||||
"SYP",
|
||||
"SZL",
|
||||
"THB",
|
||||
"TJS",
|
||||
"TMT",
|
||||
"TND",
|
||||
"TOP",
|
||||
"TRY",
|
||||
"TTD",
|
||||
"TWD",
|
||||
"TZS",
|
||||
"UAH",
|
||||
"UGX",
|
||||
"USD",
|
||||
"USN",
|
||||
"USS",
|
||||
"UYI",
|
||||
"UYU",
|
||||
"UZS",
|
||||
"VEF",
|
||||
"VND",
|
||||
"VUV",
|
||||
"WST",
|
||||
"XAF",
|
||||
"XAG",
|
||||
"XAU",
|
||||
"XBA",
|
||||
"XBB",
|
||||
"XBC",
|
||||
"XBD",
|
||||
"XCD",
|
||||
"XDR",
|
||||
"XOF",
|
||||
"XPD",
|
||||
"XPF",
|
||||
"XPT",
|
||||
"XTS",
|
||||
"XXX",
|
||||
"YER",
|
||||
"ZAR",
|
||||
"ZMK",
|
||||
"ZMW",
|
||||
"BTC",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* this will refund payment gateway charge currency
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
return $this->getCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
* this will refund payment gateway name
|
||||
* */
|
||||
public function gateway_name(): string
|
||||
{
|
||||
return 'squareup';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,317 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Stripe\Charge;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\StripeClient;
|
||||
use Stripe\Checkout\Session;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class StripePay extends PaymentGatewayBase
|
||||
{
|
||||
|
||||
use PaymentEnvironment,CurrencySupport;
|
||||
|
||||
protected $secret_key;
|
||||
protected $public_key;
|
||||
|
||||
public function setSecretKey($secret_key){
|
||||
$this->secret_key = $secret_key;
|
||||
return $this;
|
||||
}
|
||||
private function getSecretKey(){
|
||||
return $this->secret_key;
|
||||
}
|
||||
public function setPublicKey($public_key){
|
||||
$this->public_key = $public_key;
|
||||
return $this;
|
||||
}
|
||||
private function getPublicKey(){
|
||||
return $this->public_key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this payment gateway will not work without this package
|
||||
* @https://github.com/stripe/stripe-php
|
||||
* @since .0.01
|
||||
* */
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
$return_amount = $amount;
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list(), true)){
|
||||
if(in_array($this->getCurrency(), $this->zero_decimal_currencies())){
|
||||
return $return_amount;
|
||||
}
|
||||
return $amount * 100;
|
||||
}
|
||||
}
|
||||
private function zero_decimal_currencies(){
|
||||
return [
|
||||
'BIF','CLP','DJF','GNF','JPY', 'KMF','KRW', 'MGA', 'PYG','RWF','UGX','VND','VUV', 'XAF','XOF', 'XPF'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
* required param list
|
||||
*
|
||||
* @return string[]
|
||||
* @throws \Stripe\Exception\ApiErrorException
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public function ipn_response(array $args = []) : array
|
||||
{
|
||||
$stripe_session_id = session()->get('stripe_session_id');
|
||||
session()->forget('stripe_session_id');
|
||||
$stripe_order_id = session()->get('stripe_order_id');
|
||||
session()->forget('stripe_order_id');
|
||||
|
||||
$stripe = new StripeClient($this->getSecretKey());
|
||||
$response = $stripe->checkout->sessions->retrieve($stripe_session_id, []);
|
||||
$payment_intent = $response['payment_intent'] ?? '';
|
||||
$payment_status = $response['payment_status'] ?? '';
|
||||
|
||||
$capture = $stripe->paymentIntents->retrieve($payment_intent);
|
||||
if (!empty($payment_status) && $payment_status === 'paid' && $capture->status === 'succeeded') {
|
||||
$transaction_id = $payment_intent;
|
||||
if (!empty($transaction_id)) {
|
||||
return $this->verified_data([
|
||||
'transaction_id' => $transaction_id,
|
||||
'order_id' => $stripe_order_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => 'failed','order_id' => $stripe_order_id];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
* required param list
|
||||
*
|
||||
* product_name
|
||||
* amount
|
||||
* description
|
||||
* ipn_url
|
||||
* cancel_url
|
||||
* order_id
|
||||
*
|
||||
* @return array
|
||||
* @throws \Stripe\Exception\ApiErrorException
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
return $this->stripe_view($args);
|
||||
}
|
||||
|
||||
public function stripe_view($args){
|
||||
return view('paymentgateway::stripe', ['stripe_data' => array_merge($args,[
|
||||
'public_key' => $this->getPublicKey(),
|
||||
'currency' => $this->getCurrency(),
|
||||
'secret_key' => base64_encode($this->getSecretKey()),
|
||||
'charge_amount' => ceil($this->charge_amount($args['amount'])),
|
||||
])]);
|
||||
}
|
||||
|
||||
public function charge_customer_from_controller(array $args){
|
||||
Stripe::setApiKey(base64_decode($args['secret_key']));
|
||||
|
||||
$payment_types = ['card'];
|
||||
|
||||
if( strtolower($args['currency']) === "myr" ){
|
||||
$payment_types[] = 'fpx';
|
||||
}
|
||||
|
||||
$session = Session::create([
|
||||
'payment_method_types' => $payment_types,
|
||||
'line_items' => [[
|
||||
'price_data' => [
|
||||
'currency' => $args['currency'],
|
||||
'product_data' => [
|
||||
'name' => $args['title'],
|
||||
'description' => $args['description']
|
||||
],
|
||||
'unit_amount' => $args['charge_amount'],
|
||||
],
|
||||
'quantity' => 1
|
||||
]],
|
||||
'mode' => 'payment',
|
||||
'success_url' => $args['ipn_url'],
|
||||
'cancel_url' => $args['cancel_url'],
|
||||
]);
|
||||
|
||||
session()->put('stripe_session_id', $session->id);
|
||||
session()->put('stripe_order_id', $args['order_id']);
|
||||
|
||||
return ['id' => $session->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* this will refund payment gateway charge currency
|
||||
* @since 0.0.1
|
||||
* */
|
||||
public function supported_currency_list() : array
|
||||
{
|
||||
return [
|
||||
'USD',
|
||||
'EUR',
|
||||
'INR',
|
||||
'IDR',
|
||||
'AUD',
|
||||
'SGD',
|
||||
'JPY',
|
||||
'GBP',
|
||||
'MYR',
|
||||
'PHP',
|
||||
'THB',
|
||||
'KRW',
|
||||
'NGN',
|
||||
'GHS',
|
||||
'BRL',
|
||||
'BIF',
|
||||
'CAD',
|
||||
'CDF',
|
||||
'CVE',
|
||||
'GHP',
|
||||
'GMD',
|
||||
'GNF',
|
||||
'KES',
|
||||
'LRD',
|
||||
'MWK',
|
||||
'MZN',
|
||||
'RWF',
|
||||
'SLL',
|
||||
'STD',
|
||||
'TZS',
|
||||
'UGX',
|
||||
'XAF',
|
||||
'XOF',
|
||||
'ZMK',
|
||||
'ZMW',
|
||||
'ZWD',
|
||||
'AED',
|
||||
'AFN',
|
||||
'ALL',
|
||||
'AMD',
|
||||
'ANG',
|
||||
'AOA',
|
||||
'ARS',
|
||||
'AWG',
|
||||
'AZN',
|
||||
'BAM',
|
||||
'BBD',
|
||||
'BDT',
|
||||
'BGN',
|
||||
'BMD',
|
||||
'BND',
|
||||
'BOB',
|
||||
'BSD',
|
||||
'BWP',
|
||||
'BZD',
|
||||
'CHF',
|
||||
'CNY',
|
||||
'CLP',
|
||||
'COP',
|
||||
'CRC',
|
||||
'CZK',
|
||||
'DJF',
|
||||
'DKK',
|
||||
'DOP',
|
||||
'DZD',
|
||||
'EGP',
|
||||
'ETB',
|
||||
'FJD',
|
||||
'FKP',
|
||||
'GEL',
|
||||
'GIP',
|
||||
'GTQ',
|
||||
'GYD',
|
||||
'HKD',
|
||||
'HNL',
|
||||
'HRK',
|
||||
'HTG',
|
||||
'HUF',
|
||||
'ILS',
|
||||
'ISK',
|
||||
'JMD',
|
||||
'KGS',
|
||||
'KHR',
|
||||
'KMF',
|
||||
'KYD',
|
||||
'KZT',
|
||||
'LAK',
|
||||
'LBP',
|
||||
'LKR',
|
||||
'LSL',
|
||||
'MAD',
|
||||
'MDL',
|
||||
'MGA',
|
||||
'MKD',
|
||||
'MMK',
|
||||
'MNT',
|
||||
'MOP',
|
||||
'MRO',
|
||||
'MUR',
|
||||
'MVR',
|
||||
'MXN',
|
||||
'NAD',
|
||||
'NIO',
|
||||
'NOK',
|
||||
'NPR',
|
||||
'NZD',
|
||||
'PAB',
|
||||
'PEN',
|
||||
'PGK',
|
||||
'PKR',
|
||||
'PLN',
|
||||
'PYG',
|
||||
'QAR',
|
||||
'RON',
|
||||
'RSD',
|
||||
'RUB',
|
||||
'SAR',
|
||||
'SBD',
|
||||
'SCR',
|
||||
'SEK',
|
||||
'SHP',
|
||||
'SOS',
|
||||
'SRD',
|
||||
'SZL',
|
||||
'TJS',
|
||||
'TRY',
|
||||
'TTD',
|
||||
'TWD',
|
||||
'UAH',
|
||||
'UYU',
|
||||
'UZS',
|
||||
'VND',
|
||||
'VUV',
|
||||
'WST',
|
||||
'XCD',
|
||||
'XPF',
|
||||
'YER',
|
||||
'ZAR'
|
||||
];
|
||||
}
|
||||
/**
|
||||
* this will refund payment gateway charge currency
|
||||
* */
|
||||
public function charge_currency()
|
||||
{
|
||||
return $this->getCurrency();
|
||||
}
|
||||
/**
|
||||
* this will refund payment gateway name
|
||||
* */
|
||||
public function gateway_name() : string
|
||||
{
|
||||
return 'stripe';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Billplz\Laravel\Billplz;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\MyanmarCurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Billplz\Signature;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Toyyibpay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,MyanmarCurrencySupport,PaymentEnvironment;
|
||||
public $userSecretKey;
|
||||
public $categoryCode;
|
||||
|
||||
|
||||
public function getUserSecretKey(){
|
||||
return $this->userSecretKey;
|
||||
}
|
||||
public function setUserSecretKey($userSecretKey){
|
||||
$this->userSecretKey = $userSecretKey;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCategoryCode(){
|
||||
return $this->categoryCode;
|
||||
}
|
||||
public function setCategoryCode($categoryCode){
|
||||
$this->categoryCode = $categoryCode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount * 100;
|
||||
}
|
||||
return $this->get_amount_in_myr($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
|
||||
$some_data = [
|
||||
'billCode' => request()->billcode,
|
||||
'billpaymentStatus' => '1'
|
||||
];
|
||||
|
||||
//todo:: write code for verify payment
|
||||
$response = Http::asForm()->post($this->getBaseUrl().'/getBillTransactions',$some_data);
|
||||
if ($response->ok()) {
|
||||
if(!empty($response->json())){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'order_id' => substr( request()->order_id,5,-5),
|
||||
'payment_amount' => request()->amount,
|
||||
'transaction_id' => request()->billcode ,
|
||||
]);
|
||||
}
|
||||
else{
|
||||
return ['status' => 'failed','order_id' => substr( request()->SettlementReferenceNo,5,-5)];
|
||||
}
|
||||
}
|
||||
return ['status' => 'failed','order_id' => substr( request()->SettlementReferenceNo,5,-5)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$order_id = PaymentGatewayHelpers::wrapped_id($args['order_id']);
|
||||
$some_data = array(
|
||||
'userSecretKey'=> $this->getUserSecretKey(),
|
||||
'categoryCode'=> $this->getCategoryCode(),
|
||||
'billName'=> Str::limit($args['dtitleescription'],25),
|
||||
'billDescription'=> Str::limit($args['description'],90),
|
||||
'billPriceSetting'=>1,
|
||||
'billPayorInfo'=>1,
|
||||
'billAmount'=> $this->charge_amount($args['amount']), //100=1myr or 1RM
|
||||
'billReturnUrl'=> $args['success_url'], //return get url
|
||||
'billCallbackUrl'=> $args['ipn_url'], //webhook post url
|
||||
'billExternalReferenceNo' => $order_id, //order_id
|
||||
'billTo'=> $args['name'],
|
||||
'billEmail'=> $args['email'],
|
||||
'billPhone'=> $args['mobile'] ?? '123456789',
|
||||
'billSplitPayment'=>0,
|
||||
//'billSplitPaymentArgs'=>'',
|
||||
'billPaymentChannel'=>'2',
|
||||
//'billContentEmail'=>'Thank you for purchasing our product!',
|
||||
'billChargeToCustomer'=>1,
|
||||
'billExpiryDate'=> Carbon::now()->addDays(5)->format('d-m-Y h:i:s'),//'17-12-2020 17:00:00',
|
||||
'billExpiryDays'=>5
|
||||
);
|
||||
|
||||
$response = Http::asForm()->post($this->getBaseUrl().'/createBill',$some_data);
|
||||
|
||||
$result = $response->object();
|
||||
if ($response->ok() && !is_null($result)) {
|
||||
|
||||
if (!is_array($result) && property_exists($result,'status') && $result->status === 'error'){
|
||||
abort(422,$result->msg);
|
||||
}
|
||||
|
||||
$billCode = current($result)->BillCode;
|
||||
$redirect_url = $this->getBaseUrl(false) . $billCode;
|
||||
return redirect()->away($redirect_url);
|
||||
}
|
||||
|
||||
abort(422,__('Toyyibpay authorization failed'));
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['MYR'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
return 'MYR';
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'toyyibpay';
|
||||
}
|
||||
|
||||
private function getBaseUrl($api = true){
|
||||
$sandbox_prefix = $this->getEnv() ? 'dev.' : "";//sandbox
|
||||
$api_slug = $api ? 'index.php/api' : '';
|
||||
return 'https://'.$sandbox_prefix.'toyyibpay.com/'.$api_slug;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class TransactionCloudPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,ConvertUsdSupport,PaymentEnvironment;
|
||||
public $apiLogin;
|
||||
public $apiPassword;
|
||||
public $productID;
|
||||
|
||||
|
||||
public function getApiLogin(){
|
||||
return $this->apiLogin;
|
||||
}
|
||||
public function setApiLogin($apiLogin){
|
||||
$this->apiLogin = $apiLogin;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProductID(){
|
||||
return $this->productID;
|
||||
}
|
||||
public function setProductID($productID){
|
||||
$this->productID = $productID;
|
||||
return $this;
|
||||
}
|
||||
public function getApiPassword(){
|
||||
return $this->apiPassword;
|
||||
}
|
||||
public function setApiPassword($apiPassword){
|
||||
$this->apiPassword = $apiPassword;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
//todo:: retrieve transaction by transaction id
|
||||
if (empty(request()->get("id"))){
|
||||
abort(500,__("transaction id not found"));
|
||||
}
|
||||
$res = Http::withHeaders($this->getHeaders())
|
||||
->get($this->getBaseUrl()."/v1/transaction/".request()->id);
|
||||
|
||||
if ($res->status() === 200){
|
||||
//get response from transaction cloud
|
||||
$result = $res->object();
|
||||
if ($result->transactionStatus === "ONE_TIME_PAYMENT_STATUS_PAID" && $result->transactionType === "ONETIME" && $result->productId === $this->getProductID()){
|
||||
$payloads = json_decode(Crypt::decryptString($result->payload));
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($payloads->order_id),
|
||||
"payment_type" => $payloads->payment_type
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ['status' => 'failed','order_id' => null];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$order_id = PaymentGatewayHelpers::wrapped_id($args['order_id']);
|
||||
|
||||
//todo:: set customised product
|
||||
$res = Http::withHeaders($this->getHeaders())
|
||||
->acceptJson()
|
||||
->post($this->getBaseUrl().'/v1/customize-product/'.$this->getProductID(),[
|
||||
'prices' => [
|
||||
[
|
||||
'currency' => $this->getCurrency(),
|
||||
'value' => $this->charge_amount($args['amount'])
|
||||
]
|
||||
],
|
||||
'description' => $args["description"],
|
||||
'payload' => Crypt::encryptString(json_encode(["order_id" => $order_id,"payment_type" => $args['payment_type'] ?? " "])),
|
||||
'transactionIdToMigrate' => 'TC-TR_X'.random_int(111111,999999),
|
||||
'expiresIn' => 60
|
||||
]);
|
||||
|
||||
if ($res->status() === 200){
|
||||
$query_param = http_build_query([
|
||||
"email" => $args["email"],
|
||||
"firstname" => $args["name"],
|
||||
]);
|
||||
return redirect()->away($res->object()?->link."?".$query_param);
|
||||
}
|
||||
|
||||
abort(500,__("checkout url generate failed, check your api credentials"));
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['USD','EUR','PLN','INR','CAD','CNY','AUD','JPY','NOK','GBP','CHF','SGD','BRL','RUB','BGN','CZK','DKK','HUF','RON','SEK','GEL'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
return 'USD';
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'transactionclud';
|
||||
}
|
||||
private function getHeaders(){
|
||||
return [
|
||||
'User-Agent' => 'parthenon/transaction-cloud 0.1',
|
||||
'Authorization' => sprintf('%s:%s', $this->getApiLogin(), $this->getApiPassword()),
|
||||
];
|
||||
}
|
||||
private function getBaseUrl(){
|
||||
$sandbox_prefix = $this->getEnv() ? 'sandbox-' : "";//sandbox
|
||||
return 'https://'.$sandbox_prefix.'api.transaction.cloud';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class WiPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,ConvertUsdSupport,PaymentEnvironment;
|
||||
public $accountNumber;
|
||||
public $accountApi;
|
||||
public $feeStructure;
|
||||
public $countryCode;
|
||||
|
||||
|
||||
public function getAccountNumber(){
|
||||
return $this->accountNumber;
|
||||
}
|
||||
public function setAccountNumber($accountNumber){
|
||||
$this->accountNumber = $accountNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccountApi(){
|
||||
return $this->accountApi;
|
||||
}
|
||||
public function setAccountApi($accountApi){
|
||||
$this->accountApi = $accountApi;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFeeStructure(){
|
||||
return $this->feeStructure;
|
||||
}
|
||||
|
||||
public function setFeeStructure($feeStructure){
|
||||
$this->feeStructure = $feeStructure;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCountryCode($countryCode){
|
||||
$this->countryCode = $countryCode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryCode(){
|
||||
return $this->countryCode;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
|
||||
//todo check status is success
|
||||
$status = \request()->status;
|
||||
$hash = \request()->hash;
|
||||
$order_id = \request()->order_id;
|
||||
$transaction_id = \request()->transaction_id;
|
||||
$data = json_decode(\request()->data);
|
||||
$data = json_decode($data);
|
||||
|
||||
if (!empty($hash) && !empty($transaction_id) && !empty($order_id) && $status === 'success'){
|
||||
// add condition
|
||||
$charge_amount = \session()->get('wipay_total_amount');
|
||||
\session()->forget('wipay_total_amount');
|
||||
$generate_hash = md5($transaction_id.number_format($charge_amount,2).$this->getAccountApi());
|
||||
if (hash_equals($hash,$generate_hash)){
|
||||
return $this->verified_data([
|
||||
'status' => 'complete',
|
||||
'transaction_id' => $transaction_id ,
|
||||
'order_id' => PaymentGatewayHelpers::unwrapped_id($order_id ?? ""),
|
||||
'order_type' => $data->payment_type ?? ""
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => 'failed','order_id' => PaymentGatewayHelpers::unwrapped_id($order_id),'order_type' => $data->payment_type ?? ""];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$order_id = PaymentGatewayHelpers::wrapped_id($args['order_id']);
|
||||
|
||||
//https://tt.wipayfinancial.com/plugins/payments/request
|
||||
//https://jm.wipayfinancial.com/plugins/payments/request
|
||||
//https://bb.wipayfinancial.com/plugins/payments/request
|
||||
\session()->put('wipay_total_amount',number_format($this->charge_amount($args['amount']),2));
|
||||
$res = Http::acceptJson()->asForm()->post("https://".strtolower($this->getCountryCode()).".wipayfinancial.com/plugins/payments/request",[
|
||||
"account_number" => $this->getAccountNumber() , //If environment is sandbox, then you must use the WiPay SANDBOX Account Number 1234567890.
|
||||
"currency" => $this->getCurrency(), // JMD, TTD, USD
|
||||
"environment" => $this->getEnv() ? 'sandbox' : 'live' , //live, sandbox,
|
||||
"fee_structure" => $this->getFeeStructure(), //customer_pay, merchant_absorb, split, who will pay wipay transaction fee,
|
||||
"method" => "credit_card",
|
||||
"order_id" => $order_id, //order_id by application
|
||||
"origin" => env('APP_NAME'), //Your application's custom unique identifier for this transaction.
|
||||
"total" => number_format($this->charge_amount($args['amount']),2), //decimal value,
|
||||
"email" => $args['email'],
|
||||
"name" => $args['name'],
|
||||
'avs' => '0',
|
||||
"data" => json_encode($reference = [
|
||||
'order_id' => $order_id,
|
||||
'payment_type' => $args['payment_type']
|
||||
]),
|
||||
'country_code' => $this->getCountryCode(),
|
||||
'response_url' => $args['ipn_url'], //get: callback for get data about the payment
|
||||
]);
|
||||
|
||||
$redirect_url = $res->object()?->url;
|
||||
if (is_null($redirect_url)){
|
||||
abort(501,$res->object()?->message);
|
||||
}
|
||||
return redirect()->away($redirect_url);
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return ['JMD', 'TTD', 'USD'];
|
||||
}
|
||||
|
||||
public function charge_currency()
|
||||
{
|
||||
return 'USD';
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'wipay';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayBase;
|
||||
use Xgenious\Paymentgateway\Traits\ConvertUsdSupport;
|
||||
use Xgenious\Paymentgateway\Traits\CurrencySupport;
|
||||
use Xgenious\Paymentgateway\Traits\PaymentEnvironment;
|
||||
|
||||
class ZitoPay extends PaymentGatewayBase
|
||||
{
|
||||
use CurrencySupport,ConvertUsdSupport,PaymentEnvironment;
|
||||
protected $username;
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
public function setUsername($username){
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function charge_amount($amount)
|
||||
{
|
||||
if (in_array($this->getCurrency(), $this->supported_currency_list())){
|
||||
return $amount;
|
||||
}
|
||||
return $this->get_amount_in_usd($amount);
|
||||
}
|
||||
|
||||
public function ipn_response(array $args = [])
|
||||
{
|
||||
|
||||
if (request()->has('ref')){
|
||||
$response = Http::acceptJson()->asForm()->post('https://zitopay.africa/api_v1',[
|
||||
"action" => 'get_transaction',
|
||||
'receiver' => $this->getUsername(),
|
||||
'ref' => request()->get('ref'),
|
||||
'trade_id' => 0
|
||||
]);
|
||||
|
||||
if ($response->ok()){
|
||||
$result = $response->object();
|
||||
if (!empty($result) && !property_exists($result,'error')){
|
||||
if ($result->status_msg === 'COMPLETED'){
|
||||
return $this->verified_data([
|
||||
'status' => $result->status_msg === 'COMPLETED' ? 'complete' : strtolower($result->status_msg),
|
||||
'transaction_id' => request()->get('zitopay_transaction_reference'),
|
||||
'order_id' => Str::of(request()->get('ref'))->after('#')->__toString() ,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['status' => 'failed'];
|
||||
}
|
||||
|
||||
public function charge_customer(array $args)
|
||||
{
|
||||
$args['username'] = $this->getUsername();
|
||||
$args['currency'] = $this->getCurrency();
|
||||
return view('paymentgateway::zitopay',compact('args'));
|
||||
}
|
||||
|
||||
public function supported_currency_list()
|
||||
{
|
||||
return [
|
||||
"USD",
|
||||
"EUR",
|
||||
"GBP",
|
||||
"AED",
|
||||
"AFN",
|
||||
"ALL",
|
||||
"AMD",
|
||||
"ANG",
|
||||
"AOA",
|
||||
"ARS",
|
||||
"AUD",
|
||||
"AWG",
|
||||
"AZN",
|
||||
"BAM",
|
||||
"BBD",
|
||||
"BDT",
|
||||
"BGN",
|
||||
"BHD",
|
||||
"BIF",
|
||||
"BMD",
|
||||
"BND",
|
||||
"BOB",
|
||||
"BRL",
|
||||
"BSD",
|
||||
"BTN",
|
||||
"BWP",
|
||||
"BYN",
|
||||
"BZD",
|
||||
"CAD",
|
||||
"CDF",
|
||||
"CHF",
|
||||
"CLP",
|
||||
"CNY",
|
||||
"COP",
|
||||
"CRC",
|
||||
"CUP",
|
||||
"CVE",
|
||||
"CZK",
|
||||
"DJF",
|
||||
"DKK",
|
||||
"DOP",
|
||||
"DZD",
|
||||
"EGP",
|
||||
"ERN",
|
||||
"ETB",
|
||||
"FJD",
|
||||
"GEL",
|
||||
"GHS",
|
||||
"GMD",
|
||||
"GNF",
|
||||
"GTQ",
|
||||
"GYD",
|
||||
"HNL",
|
||||
"HRK",
|
||||
"HTG",
|
||||
"HUF",
|
||||
"IDR",
|
||||
"ILS",
|
||||
"INR",
|
||||
"IQD",
|
||||
"IRR",
|
||||
"ISK",
|
||||
"JMD",
|
||||
"JOD",
|
||||
"JPY",
|
||||
"KES",
|
||||
"KGS",
|
||||
"KHR",
|
||||
"KMF",
|
||||
"KPW",
|
||||
"KRW",
|
||||
"KWD",
|
||||
"KZT",
|
||||
"LAK",
|
||||
"LBP",
|
||||
"LKR",
|
||||
"LRD",
|
||||
"LSL",
|
||||
"LTL",
|
||||
"LVL",
|
||||
"LYD",
|
||||
"MAD",
|
||||
"MDL",
|
||||
"MGA",
|
||||
"MKD",
|
||||
"MMK",
|
||||
"MNT",
|
||||
"MRO",
|
||||
"MUR",
|
||||
"MVR",
|
||||
"MWK",
|
||||
"MXN",
|
||||
"MYR",
|
||||
"MZN",
|
||||
"NAD",
|
||||
"NGN",
|
||||
"NIO",
|
||||
"NOK",
|
||||
"NPR",
|
||||
"NZD",
|
||||
"OMR",
|
||||
"PAB",
|
||||
"PEN",
|
||||
"PGK",
|
||||
"PHP",
|
||||
"PKR",
|
||||
"PLN",
|
||||
"PYG",
|
||||
"QAR",
|
||||
"RON",
|
||||
"RSD",
|
||||
"RUB",
|
||||
"RWF",
|
||||
"SAR",
|
||||
"SCR",
|
||||
"SDG",
|
||||
"SEK",
|
||||
"SGD",
|
||||
"SLL",
|
||||
"SOS",
|
||||
"SRD",
|
||||
"STD",
|
||||
"SVC",
|
||||
"SYP",
|
||||
"SZL",
|
||||
"THB",
|
||||
"TJS",
|
||||
"TMT",
|
||||
"TND",
|
||||
"TOP",
|
||||
"TRY",
|
||||
"TTD",
|
||||
"TWD",
|
||||
"TZS",
|
||||
"UAH",
|
||||
"UGX",
|
||||
"UYU",
|
||||
"UZS",
|
||||
"VEF",
|
||||
"VND",
|
||||
"VUV",
|
||||
"WST",
|
||||
"XCD",
|
||||
"XOF",
|
||||
"YER",
|
||||
"ZAR",
|
||||
"ZMW",
|
||||
"ZWD",
|
||||
"XAF",
|
||||
];
|
||||
}
|
||||
public function charge_currency()
|
||||
{
|
||||
return "USD";
|
||||
}
|
||||
|
||||
public function gateway_name()
|
||||
{
|
||||
return 'zitopay';
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base;
|
||||
|
||||
abstract class PaymentGatewayBase
|
||||
{
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* return how them amount need to charge
|
||||
* */
|
||||
abstract public function charge_amount($amount);
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* handle payment gateway ipn response
|
||||
* */
|
||||
abstract public function ipn_response(array $args);
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* return customer payment verified data
|
||||
* */
|
||||
|
||||
public function verified_data($args) : array
|
||||
{
|
||||
return array_merge(['status' => 'complete'],$args);
|
||||
}
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* charge customer account by this method
|
||||
* */
|
||||
abstract public function charge_customer(array $args);
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* list of all supported currency by payment gateway
|
||||
* */
|
||||
abstract public function supported_currency_list();
|
||||
/**
|
||||
* charge_currency()
|
||||
* @since 1.0.0
|
||||
* get charge currency for payment gateway
|
||||
* */
|
||||
abstract public function charge_currency();
|
||||
/**
|
||||
* gateway_name()
|
||||
* @since 1.0.0
|
||||
* add payment gateway name
|
||||
* */
|
||||
abstract public function gateway_name();
|
||||
/**
|
||||
* global_currency()
|
||||
* @since 1.0.0
|
||||
* get global currency
|
||||
* */
|
||||
protected static function global_currency(){
|
||||
return config('paymentgateway.global_currency');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Base;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\Gateways\AuthorizeDotNetPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\BillPlzPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\CashFreePay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\CinetPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\FlutterwavePay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\InstamojoPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\Iyzipay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\KineticPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\MidtransPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\MolliePay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PagaliPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PayFastPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PaymobPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PaypalPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PaystackPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PayTabsPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PaytmPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PayUmoneyPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\PowertranzPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\RazorPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\SaltPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\Senangpay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\SitesWayPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\SquarePay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\StripePay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\MercadoPagoPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\Toyyibpay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\TransactionCloudPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\WiPay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\ZitoPay;
|
||||
|
||||
/**
|
||||
* @see SquarePay
|
||||
* @method setApplicationId();
|
||||
* @method setAccessToken();
|
||||
* @method setLocationId();
|
||||
*/
|
||||
|
||||
class PaymentGatewayHelpers
|
||||
{
|
||||
|
||||
public function stripe() : StripePay
|
||||
{
|
||||
return new StripePay();
|
||||
}
|
||||
public function paypal() : PaypalPay
|
||||
{
|
||||
return new PaypalPay();
|
||||
}
|
||||
public function midtrans() : MidtransPay
|
||||
{
|
||||
return new MidtransPay();
|
||||
}
|
||||
public function paytm() : PaytmPay
|
||||
{
|
||||
return new PaytmPay();
|
||||
}
|
||||
public function razorpay() : RazorPay
|
||||
{
|
||||
return new RazorPay();
|
||||
}
|
||||
public function mollie() : MolliePay
|
||||
{
|
||||
return new MolliePay();
|
||||
}
|
||||
public function flutterwave() : FlutterwavePay
|
||||
{
|
||||
return new FlutterwavePay();
|
||||
}
|
||||
public function paystack() : PaystackPay
|
||||
{
|
||||
return new PaystackPay();
|
||||
}
|
||||
|
||||
public function payfast() : PayFastPay
|
||||
{
|
||||
return new PayFastPay();
|
||||
}
|
||||
public function cashfree() : CashFreePay
|
||||
{
|
||||
return new CashFreePay();
|
||||
}
|
||||
public function instamojo() : InstamojoPay
|
||||
{
|
||||
return new InstamojoPay();
|
||||
}
|
||||
// deprecated
|
||||
public function mercadopago() : MercadoPagoPay
|
||||
{
|
||||
return new MercadoPagoPay();
|
||||
}
|
||||
public function payumoney() : PayUmoneyPay
|
||||
{
|
||||
return new PayUmoneyPay();
|
||||
}
|
||||
public function squareup() : SquarePay
|
||||
{
|
||||
return new SquarePay();
|
||||
}
|
||||
public function cinetpay() : CinetPay
|
||||
{
|
||||
return new CinetPay();
|
||||
}
|
||||
public function paytabs() : PayTabsPay
|
||||
{
|
||||
return new PayTabsPay();
|
||||
}
|
||||
public function billplz() : BillPlzPay
|
||||
{
|
||||
return new BillPlzPay();
|
||||
}
|
||||
|
||||
public function zitopay() : ZitoPay
|
||||
{
|
||||
return new ZitoPay();
|
||||
}
|
||||
public function toyyibpay() : Toyyibpay
|
||||
{
|
||||
return new Toyyibpay();
|
||||
}
|
||||
public function pagalipay() : PagaliPay
|
||||
{
|
||||
return new PagaliPay();
|
||||
}
|
||||
public function authorizenet() : AuthorizeDotNetPay
|
||||
{
|
||||
return new AuthorizeDotNetPay();
|
||||
}
|
||||
public function sitesway() : SitesWayPay
|
||||
{
|
||||
return new SitesWayPay();
|
||||
}
|
||||
public function wipay() : WiPay
|
||||
{
|
||||
return new WiPay();
|
||||
}
|
||||
public function kineticpay() : KineticPay
|
||||
{
|
||||
return new KineticPay();
|
||||
}
|
||||
public function transactionclud() : TransactionCloudPay
|
||||
{
|
||||
return new TransactionCloudPay();
|
||||
}
|
||||
|
||||
public function senangpay() : Senangpay
|
||||
{
|
||||
return new Senangpay();
|
||||
}
|
||||
public function saltpay() : SaltPay
|
||||
{
|
||||
return new SaltPay();
|
||||
}
|
||||
|
||||
public function paymob() : PaymobPay
|
||||
{
|
||||
return new PaymobPay();
|
||||
}
|
||||
|
||||
public function iyzipay() : Iyzipay
|
||||
{
|
||||
return new Iyzipay();
|
||||
}
|
||||
|
||||
public function powertranz() : PowertranzPay
|
||||
{
|
||||
return new PowertranzPay();
|
||||
}
|
||||
|
||||
public function all_payment_gateway_list() : array
|
||||
{
|
||||
return [
|
||||
'zitopay','billplz','paytabs','cinetpay','squareup',
|
||||
'mercadopago','instamojo','cashfree','payfast',
|
||||
'paystack','flutterwave','mollie','razopay','paytm',
|
||||
'midtrans','paypal','stripe','toyyibpay','pagali','authorizenet',
|
||||
'sitesway','transactionclud','wipay','kineticpay','senangpay','saltpay','paymob',
|
||||
'iyzipay','powertranz'
|
||||
// 'payumoney',
|
||||
];
|
||||
}
|
||||
public function script_currency_list(){
|
||||
return GlobalCurrency::script_currency_list();
|
||||
}
|
||||
|
||||
public static function wrapped_id($id) : string
|
||||
{
|
||||
return random_int(11111,99999).$id.random_int(11111,99999);
|
||||
}
|
||||
public static function unwrapped_id($id) : string
|
||||
{
|
||||
return substr($id,5,-5);
|
||||
}
|
||||
public static function get_current_file_url($Protocol='http://') {
|
||||
return $Protocol.$_SERVER['HTTP_HOST'].str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(__DIR__));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Base;
|
||||
interface RecurringSupport {
|
||||
public function charge_customer_recurring(array $args);
|
||||
public function ipn_response_recurring(array $args = []);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Base;
|
||||
interface RefundSupport {
|
||||
public function refund(array $args);
|
||||
public function ipn_response_refund(array $args = []);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PaymentgatewayCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'paymentgateway:command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\InstamojoPay;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\SquarePay;
|
||||
/**
|
||||
* @see GlobalCurrency
|
||||
* @method static script_currency_list()
|
||||
*
|
||||
* @see PaymentGatewayHelpers
|
||||
* @method static stripe()
|
||||
* @method static paypal()
|
||||
* @method static midtrans()
|
||||
* @method static paytm()
|
||||
* @method static razorpay()
|
||||
* @method static mollie()
|
||||
* @method static flutterwave()
|
||||
* @method static paystack()
|
||||
* @method static payfast()
|
||||
* @method static cashfree()
|
||||
* @method static instamojo()
|
||||
* @method static mercadopago()
|
||||
* @method static payumoney()
|
||||
* @method static squareup()
|
||||
* @method static cinetpay()
|
||||
* @method static paytabs()
|
||||
* @method static zitopay()
|
||||
* @method static toyyibpay()
|
||||
* @method static pagalipay()
|
||||
* @method static authorizenet()
|
||||
* @method static sitesway()
|
||||
* @method static transactionclud()
|
||||
* @method static wipay()
|
||||
* @method static kineticpay()
|
||||
* @method static senangpay()
|
||||
* @method static saltpay()
|
||||
* @method static paymob()
|
||||
* @method static iyzipay()
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @see GlobalCurrency
|
||||
* @method static script_currency_list()
|
||||
*
|
||||
* @see PaymentGatewayHelpers
|
||||
* @method static stripe()
|
||||
* @method static paypal()
|
||||
* @method static midtrans()
|
||||
* @method static paytm()
|
||||
* @method static razorpay()
|
||||
* @method static mollie()
|
||||
* @method static flutterwave()
|
||||
* @method static paystack()
|
||||
* @method static payfast()
|
||||
* @method static cashfree()
|
||||
* @method static instamojo()
|
||||
* @method static mercadopago()
|
||||
* @method static payumoney()
|
||||
* @method static squareup()
|
||||
* @method static cinetpay()
|
||||
* @method static paytabs()
|
||||
* @method static zitopay()
|
||||
* @method static toyyibpay()
|
||||
* @method static pagalipay()
|
||||
* @method static authorizenet()
|
||||
* @method static sitesway()
|
||||
* @method static transactionclud()
|
||||
* @method static wipay()
|
||||
* @method static kineticpay()
|
||||
* @method static senangpay()
|
||||
* @method static saltpay()
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @see GlobalCurrency
|
||||
* @method static script_currency_list()
|
||||
*
|
||||
* @see PaymentGatewayHelpers
|
||||
* @method static stripe()
|
||||
* @method static paypal()
|
||||
* @method static midtrans()
|
||||
* @method static paytm()
|
||||
* @method static razorpay()
|
||||
* @method static mollie()
|
||||
* @method static flutterwave()
|
||||
* @method static paystack()
|
||||
* @method static payfast()
|
||||
* @method static cashfree()
|
||||
* @method static instamojo()
|
||||
* @method static mercadopago()
|
||||
* @method static payumoney()
|
||||
* @method static squareup()
|
||||
* @method static cinetpay()
|
||||
* @method static paytabs()
|
||||
* @method static zitopay()
|
||||
* @method static toyyibpay()
|
||||
* @method static pagalipay()
|
||||
* @method static authorizenet()
|
||||
* @method static sitesway()
|
||||
* @method static transactionclud()
|
||||
* @method static wipay()
|
||||
* @method static kineticpay()
|
||||
* @method static senangpay()
|
||||
* @method static saltpay()
|
||||
* @method static paymob()
|
||||
*
|
||||
*/
|
||||
class XgPaymentGateway extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return 'XgPaymentGateway';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Unicodeveloper\Paystack\Facades\Paystack;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
|
||||
class AuthorizeNetPaymentController extends Controller
|
||||
{
|
||||
public function charge_customer(Request $request){
|
||||
$payment_data = XgPaymentGateway::authorizenet()->charge_customer_from_controller();
|
||||
$transaction_id = $payment_data['transaction_id'] ?? "";
|
||||
Session::put('authorizenet_last_transaction_id',$transaction_id);
|
||||
return redirect($request->ipn_url."?transaction_id=".$transaction_id."&order_id=".$request->order_id."&order_type=".$request->payment_type."&status=".$payment_data['status']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController{
|
||||
use AuthorizesRequests,DispatchesJobs,ValidatesRequests;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Unicodeveloper\Paystack\Facades\Paystack;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
|
||||
class PaystackPaymentController extends Controller
|
||||
{
|
||||
public function redirect_to_gateway(Request $request){
|
||||
config(array_merge([
|
||||
'paystack.merchantEmail' => $request->merchantEmail,
|
||||
'paystack.secretKey' => base64_decode($request->secretKey),
|
||||
'paystack.publicKey' => $request->publicKey,
|
||||
'paystack.paymentUrl' => 'https://api.paystack.co',
|
||||
]));
|
||||
|
||||
try{
|
||||
return Paystack::getAuthorizationUrl()->redirectNow();
|
||||
}catch(\Exception $e) {
|
||||
abort(405,$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Unicodeveloper\Paystack\Facades\Paystack;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
|
||||
class PowertranszPaymentController extends Controller
|
||||
{
|
||||
public function charge_customer(Request $request){
|
||||
$payment_data = XgPaymentGateway::powertranz()->charge_customer_from_controller();
|
||||
return $payment_data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Http\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Xgenious\Paymentgateway\Facades\XgPaymentGateway;
|
||||
|
||||
class StripePaymentController extends Controller
|
||||
{
|
||||
public function charge_customer(Request $request){
|
||||
try{
|
||||
$stripe_session = XgPaymentGateway::stripe()->charge_customer_from_controller([
|
||||
'amount' => $request->amount,
|
||||
'charge_amount' => $request->charge_amount,
|
||||
'title' => $request->title,
|
||||
'description' => $request->description,
|
||||
'ipn_url' => $request->ipn_url,
|
||||
'order_id' => $request->order_id,
|
||||
'track' => $request->track,
|
||||
'cancel_url' => $request->cancel_url,
|
||||
'success_url' => $request->success_url,
|
||||
'email' => $request->email,
|
||||
'name' => $request->name,
|
||||
'payment_type' => $request->payment_type,
|
||||
'secret_key' => $request->secret_key,
|
||||
'currency' => $request->currency,
|
||||
]);
|
||||
return response()->json(['id' => $stripe_session['id']]);
|
||||
}catch(\Exception $e){
|
||||
return response()->json(['msg' => $e->getMessage(),'type' => 'danger']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Xgenious\Paymentgateway\Base\PaymentGatewayHelpers;
|
||||
|
||||
class PaymentgatewayServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* Uncomment this function call to make the config file publishable using the 'config' tag.
|
||||
*/
|
||||
$this->publishes([
|
||||
__DIR__.'/../../config/paymentgateway.php' => config_path('paymentgateway.php'),
|
||||
], 'paymentgateway-config');
|
||||
|
||||
/**
|
||||
* Routes
|
||||
*
|
||||
* Uncomment this function call to load the route files.
|
||||
* A web.php file has already been generated.
|
||||
*/
|
||||
$this->loadRoutesFrom(__DIR__.'/../../routes/web.php');
|
||||
|
||||
/**
|
||||
* Translations
|
||||
*
|
||||
* Uncomment the first function call to load the translations.
|
||||
* Uncomment the second function call to load the JSON translations.
|
||||
* Uncomment the third function call to make the translations publishable using the 'translations' tag.
|
||||
*/
|
||||
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'paymentgateway');
|
||||
$this->loadJsonTranslationsFrom(__DIR__.'/../../resources/lang', 'paymentgateway');
|
||||
$this->publishes([
|
||||
__DIR__.'/../../resources/lang' => resource_path('lang/vendor/paymentgateway'),
|
||||
], 'translations');
|
||||
|
||||
/**
|
||||
* Views
|
||||
*
|
||||
* Uncomment the first section to load the views.
|
||||
* Uncomment the second section to make the view publishable using the 'view' tags.
|
||||
*/
|
||||
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'paymentgateway');
|
||||
$this->publishes([
|
||||
__DIR__.'/../../resources/views' => resource_path('views/vendor/paymentgateway'),
|
||||
], 'views');
|
||||
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* Uncomment this section to load the commands.
|
||||
* A basic command file has already been generated in 'src\Console\Commands\MyPackageCommand.php'.
|
||||
*/
|
||||
// if ($this->app->runningInConsole()) {
|
||||
// $this->commands([
|
||||
// \Xgenious\Paymentgateway\Console\Commands\PaymentgatewayCommand::class,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Public assets
|
||||
*
|
||||
* Uncomment this functin call to make the public assets publishable using the 'public' tag.
|
||||
*/
|
||||
// $this->publishes([
|
||||
// __DIR__.'/../../public' => public_path('vendor/paymentgateway'),
|
||||
// ], 'public');
|
||||
|
||||
/**
|
||||
* Migrations
|
||||
*
|
||||
* Uncomment the first function call to load the migrations.
|
||||
* Uncomment the second function call to make the migrations publishable using the 'migrations' tags.
|
||||
*/
|
||||
// $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
|
||||
// $this->publishes([
|
||||
// __DIR__.'/../../database/migrations/' => database_path('migrations')
|
||||
// ], 'migrations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
/**
|
||||
* Config file
|
||||
*
|
||||
* Uncomment this function call to load the config file.
|
||||
* If the config file is also publishable, it will merge with that file
|
||||
*/
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__.'/../../config/paymentgateway.php', 'paymentgateway'
|
||||
);
|
||||
|
||||
/**
|
||||
* register facades
|
||||
*
|
||||
* */
|
||||
app()->bind('XgPaymentGateway',function (){
|
||||
return new PaymentGatewayHelpers();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait ConvertUsdSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* get_amount_in_usd()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversation rate
|
||||
* */
|
||||
protected function get_amount_in_usd($amount){
|
||||
if (empty($this->getCurrency())){
|
||||
report("you have not yet set your global currency");
|
||||
}
|
||||
if ($this->getCurrency() === 'USD'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_usd($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('USD amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
protected function make_amount_in_usd($amount,$currency){
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'USD') {
|
||||
continue;
|
||||
}
|
||||
if ($cur === $currency) {
|
||||
$exchange_rate = $this->getExchangeRate(); // exchange rate
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\Gateways\CashFreePay;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait CurrencySupport
|
||||
{
|
||||
protected $currency;
|
||||
protected $exchange_rate;
|
||||
|
||||
private function getCurrency(){
|
||||
return $this->currency;
|
||||
}
|
||||
public function getExchangeRate()
|
||||
{
|
||||
return $this->exchange_rate ;
|
||||
}
|
||||
public function setExchangeRate($rate)
|
||||
{
|
||||
$this->exchange_rate = $rate;
|
||||
return $this;
|
||||
}
|
||||
public function setCurrency($currency = "USD")
|
||||
{
|
||||
$this->currency = $currency;
|
||||
return $this;
|
||||
}
|
||||
public function getCurrencyNumber($currency = "USD"): string
|
||||
{
|
||||
return GlobalCurrency::get_currency_number($currency);
|
||||
}
|
||||
|
||||
private function is_decimal($n) {
|
||||
// Note that floor returns a float
|
||||
return is_numeric($n) && floor($n) != $n;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait IndianCurrencySupport
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* get_amount_in_inr()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversation rate
|
||||
* */
|
||||
protected function get_amount_in_inr($amount){
|
||||
if ($this->getCurrency() === 'INR'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_inr($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('USD amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
/**
|
||||
* convert amount to ngn currency base on conversation given by admin
|
||||
* */
|
||||
private function make_amount_in_inr($amount, $currency)
|
||||
{
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'INR') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
use Stevebauman\Location\Facades\Location;
|
||||
|
||||
|
||||
trait LocationSupport{
|
||||
public function getLocationDetails($ip) {
|
||||
if ($position = Location::get($ip)) {
|
||||
// Successfully retrieved position.
|
||||
dd($position);
|
||||
return [
|
||||
'country' => $position->countryName,
|
||||
'city' => 'unknown'
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'country' => 'unknown',
|
||||
'city' => 'unknown'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait MalaysiaCurrencySupport
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* get_amount_in_myr()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversion rate
|
||||
* */
|
||||
protected function get_amount_in_myr($amount){
|
||||
if ($this->getCurrency() === 'MYR'){
|
||||
return $amount * 100;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_myr($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('USD amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount * 100;
|
||||
}
|
||||
/**
|
||||
* convert amount to ngn currency base on conversation given by admin
|
||||
* */
|
||||
private function make_amount_in_myr($amount, $currency)
|
||||
{
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'MYR') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait MyanmarCurrencySupport
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* get_amount_in_myr()
|
||||
* @since 1.0.0
|
||||
* this function return any amount to usd based on user given currency conversation value,
|
||||
* it will not work if admin did not give currency conversion rate
|
||||
* */
|
||||
protected function get_amount_in_myr($amount,$multiply = true){
|
||||
if ($this->getCurrency() === 'MYR'){
|
||||
return $multiply ? $amount * 100 : $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_myr($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('MYR amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $multiply ? $payable_amount * 100 : $payable_amount;
|
||||
}
|
||||
/**
|
||||
* convert amount to ngn currency base on conversation given by admin
|
||||
* */
|
||||
private function make_amount_in_myr($amount, $currency)
|
||||
{
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'MYR') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
|
||||
trait PaymentEnvironment
|
||||
{
|
||||
|
||||
/* true === 'sandbox', false = 'production|live'*/
|
||||
|
||||
protected $env;
|
||||
/* set environment : true or false */
|
||||
public function setEnv($env){
|
||||
$this->env = $env;
|
||||
return $this;
|
||||
}
|
||||
/* get environment: true or false */
|
||||
private function getEnv(){
|
||||
return $this->env;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Traits;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\GlobalCurrency;
|
||||
|
||||
trait ZarCurrencySupport
|
||||
{
|
||||
protected function get_amount_in_zar($amount){
|
||||
if ($this->getCurrency() === 'ZAR'){
|
||||
return $amount;
|
||||
}
|
||||
$payable_amount = $this->make_amount_in_zar($amount, $this->getCurrency());
|
||||
if ($payable_amount < 1) {
|
||||
return $payable_amount . __('amount is not supported by '.$this->gateway_name());
|
||||
}
|
||||
return $payable_amount;
|
||||
}
|
||||
protected function make_amount_in_zar($amount,$currency){
|
||||
$output = 0;
|
||||
$all_currency = GlobalCurrency::script_currency_list();
|
||||
foreach ($all_currency as $cur => $symbol) {
|
||||
if ($cur === 'ZAR') {
|
||||
continue;
|
||||
}
|
||||
if ($cur == $currency) {
|
||||
$exchange_rate = $this->getExchangeRate();
|
||||
$output = $amount * $exchange_rate ;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Tests\Gateways;
|
||||
|
||||
use Xgenious\Paymentgateway\Base\Gateways\Senangpay;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\ZitoPay;
|
||||
use Xgenious\Paymentgateway\Tests\TestCase;
|
||||
|
||||
class SenangpayTest extends TestCase
|
||||
{
|
||||
public function test_charge_amount()
|
||||
{
|
||||
$zitopay = new Senangpay();
|
||||
$zitopay->setCurrency('MYR');
|
||||
$this->assertEquals(10.00, $zitopay->charge_amount(10.00));
|
||||
}
|
||||
|
||||
public function test_charge_customer()
|
||||
{
|
||||
$zitopay = new Senangpay();
|
||||
$zitopay->setMerchantId('358169193868945');
|
||||
$zitopay->setSecretKey('5876-708');
|
||||
$zitopay->setEnv(true);
|
||||
$zitopay->setHashMethod('sha256');
|
||||
$zitopay->setCurrency('MYR');
|
||||
$response = $zitopay->charge_customer([
|
||||
'amount' => 25.5,
|
||||
'title' => 'this is test title',
|
||||
'description' => 'this is test description',
|
||||
'ipn_url' => route('post.ipn'), //post route
|
||||
'order_id' => 56,
|
||||
'track' => 'asdfasdfsdf',
|
||||
'cancel_url' => route('payment.failed'),
|
||||
'success_url' => route('payment.success'),
|
||||
'email' => 'dvrobin4@gmail.com',
|
||||
'name' => 'sharifur rahman',
|
||||
'payment_type' => 'order',
|
||||
]);
|
||||
$this->assertArrayHasKey('url', $response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Tests\Gateways;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Xgenious\Paymentgateway\Tests\TestCase;
|
||||
use Xgenious\Paymentgateway\Base\Gateways\ZitoPay;
|
||||
|
||||
class ZitoPayTest extends TestCase
|
||||
{
|
||||
public function test_charge_amount_returns_correct_amount()
|
||||
{
|
||||
$zitopay = new ZitoPay();
|
||||
$zitopay->setCurrency('USD');
|
||||
$this->assertEquals(10.00, $zitopay->charge_amount(10.00));
|
||||
}
|
||||
|
||||
public function test_charge_amount_converts_to_usd_if_not_supported_currency()
|
||||
{
|
||||
$zitopay = new ZitoPay();
|
||||
$zitopay->setCurrency('DBD');
|
||||
$zitopay->setEnv(true);
|
||||
$zitopay->setExchangeRate(5);
|
||||
$this->assertEquals(50, $zitopay->charge_amount(10));
|
||||
}
|
||||
|
||||
public function test_supported_currency_list_returns_array()
|
||||
{
|
||||
$zitopay = new ZitoPay();
|
||||
$this->assertIsArray($zitopay->supported_currency_list());
|
||||
}
|
||||
|
||||
public function test_gateway_name_returns_zitopay()
|
||||
{
|
||||
$zitopay = new ZitoPay();
|
||||
$this->assertEquals('zitopay', $zitopay->gateway_name());
|
||||
}
|
||||
/* need to fix this code test */
|
||||
// public function test_ipn_response_returns_complete_if_transaction_is_successful()
|
||||
// {
|
||||
// Http::fake([
|
||||
// 'zitopay.africa/api_v1' => Http::response([
|
||||
// 'status_msg' => 'COMPLETED',
|
||||
// 'zitopay_transaction_reference' => '123456',
|
||||
// ], 200),
|
||||
// ]);
|
||||
|
||||
// $zitopay = new ZitoPay();
|
||||
// $result = $zitopay->ipn_response();
|
||||
|
||||
// $this->assertEquals('COMPLETED', $result['status']);
|
||||
// $this->assertEquals('123456', $result['transaction_id']);
|
||||
// $this->assertEquals('123', $result['order_id']);
|
||||
// }
|
||||
|
||||
public function test_ipn_response_returns_failed_if_transaction_is_not_successful()
|
||||
{
|
||||
Http::fake([
|
||||
'zitopay.africa/api_v1' => Http::response([
|
||||
'status_msg' => 'DECLINED',
|
||||
'zitopay_transaction_reference' => '123456',
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$zitopay = new ZitoPay();
|
||||
$result = $zitopay->ipn_response(['ref' => 'order#123']);
|
||||
|
||||
$this->assertEquals('failed', $result['status']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Xgenious\Paymentgateway\Tests;
|
||||
|
||||
use Orchestra\Testbench\TestCase as OrchestraTestCase;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
/**
|
||||
* Override the standard PHPUnit testcase with the Testbench testcase
|
||||
*
|
||||
* @see https://github.com/orchestral/testbench#usage
|
||||
*/
|
||||
abstract class TestCase extends OrchestraTestCase
|
||||
{
|
||||
/**
|
||||
* Include the package's service provider(s)
|
||||
*
|
||||
* @see https://github.com/orchestral/testbench#custom-service-provider
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @return array
|
||||
*/
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
\Xgenious\Paymentgateway\Providers\PaymentgatewayServiceProvider::class
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue