Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
omalizadeh committed May 12, 2023
1 parent 35af33a commit 2d2caf8
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/gateway_idpay.php
Expand Up @@ -12,7 +12,7 @@
*/
'main' => [
'api_key' => '',
'sandbox' => true, // turning on/off sandbox (testing) mode
'sandbox' => true, // sandbox (testing) mode activation
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using idpay',
],
Expand Down
4 changes: 2 additions & 2 deletions config/gateway_parsian.php
Expand Up @@ -18,12 +18,12 @@
* gateway configurations.
*/
'main' => [
'pin_code' => '',
'pin' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => '',
],
'other' => [
'pin_code' => '',
'pin' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using parsian',
],
Expand Down
2 changes: 1 addition & 1 deletion config/gateway_payir.php
Expand Up @@ -11,7 +11,7 @@
* gateway configurations.
*/
'main' => [
'api_key' => '', // use 'test' as api_key for sandbox mode
'api_key' => '', // use 'test' to enable sandbox mode
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using payir',
],
Expand Down
2 changes: 1 addition & 1 deletion config/gateway_zarinpal.php
Expand Up @@ -14,7 +14,7 @@
'authorization_token' => '', // optional, used only to refund payments (can be created from zarinpal panel)
'merchant_id' => '',
'callback_url' => 'https://yoursite.com/path/to',
'mode' => 'sandbox', // supported values: normal, zaringate, sandbox
'mode' => 'sandbox', // supported values: sandbox, normal, zaringate
'description' => 'payment using zarinpal',
],
'other' => [
Expand Down
2 changes: 1 addition & 1 deletion config/gateway_zibal.php
Expand Up @@ -11,7 +11,7 @@
* gateway configurations.
*/
'main' => [
'merchant' => '', // use 'zibal' for sandbox (testing) mode
'merchant' => '', // use 'zibal' to enable sandbox (testing) mode
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using zarinpal',
],
Expand Down
2 changes: 1 addition & 1 deletion config/multipayment.php
Expand Up @@ -8,7 +8,7 @@
* valid pattern --> GATEWAY_NAME.GATEWAY_CONFIG_KEY
* valid GATEWAY_NAME --> zarinpal, saman, mellat, novin, parsian, pasargad, zibal, payir, idpay
*/
'default_gateway' => env('DEFAULT_GATEWAY', 'zarinpal.main'),
'default_gateway' => env('DEFAULT_PAYMENT_GATEWAY', 'zarinpal.main'),

/**
* set to false if your in-app currency is IRR.
Expand Down
54 changes: 54 additions & 0 deletions resources/views/gateway_redirection.html
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="fa">
<head>
<title>انتقال به درگاه پرداخت</title>
<style>
.progress-bar {
position: relative;
width: 200px;
height: 200px;
border-radius: 50%;
border: 10px solid lightgray;
margin: 50px auto;
}

.countdown {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
}
</style>
</head>
<body>
<div id="message">در حال انتقال به درگاه پرداخت بانکی. لطفا چند ثانیه صبر کنید...</div>
<div class="progress-bar">
<div id="countdown" class="countdown">8</div>
</div>
<form id="hidden-form" action="example_url" method="post">
<input type="hidden" name="key1" value="value1">
<input type="hidden" name="key2" value="value2">
<!-- Add more hidden inputs as needed -->
</form>

<script>
function countdown() {
var countdownElement = document.getElementById("countdown");
var countdownValue = parseInt(countdownElement.innerHTML);

// Submit the hidden form after the countdown reaches 0
if (countdownValue === 0) {
document.getElementById("hidden-form").submit();
} else {
countdownElement.innerHTML = countdownValue - 1;
setTimeout(countdown, 1000); // Run the countdown every 1 second (1000 milliseconds)
}
}

window.onload = function () {
setTimeout(countdown, 1000); // Start the countdown when the page loads after 1 second (1000 milliseconds)
};
</script>
</body>
</html>
8 changes: 4 additions & 4 deletions src/Drivers/Parsian/Parsian.php
Expand Up @@ -60,13 +60,13 @@ public function verify(): Receipt

protected function getPurchaseData(): array
{
if (empty($this->settings['pin_code'])) {
throw new InvalidConfigurationException('pin_code has not been set.');
if (empty($this->settings['pin'])) {
throw new InvalidConfigurationException('pin has not been set.');
}

return [
'requestData' => [
'LoginAccount' => $this->settings['pin_code'],
'LoginAccount' => $this->settings['pin'],
'OrderId' => $this->getInvoice()->getInvoiceId(),
'Amount' => $this->getInvoice()->getAmount(),
'CallBackUrl' => $this->getInvoice()->getCallbackUrl() ?: $this->settings['callback_url'],
Expand All @@ -80,7 +80,7 @@ protected function getVerificationData(): array
{
return [
'requestData' => [
'LoginAccount' => $this->settings['pin_code'],
'LoginAccount' => $this->settings['pin'],
'Token' => $this->getInvoice()->getTransactionId(),
],
];
Expand Down

0 comments on commit 2d2caf8

Please sign in to comment.