Skip to content

Commit 2bc2885

Browse files
committed
added cumulative to Asanpardakht & Mellat
1 parent 2b81b46 commit 2bc2885

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

config/shaparak.php

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
'prefix' => 'SHAPARAK->',
2323
],
2424

25+
'iban' => env('SETTLEMENT_IBAN'),
26+
2527
'providers' => [
2628
/*
2729
|--------------------------------------------------------------------------
@@ -34,6 +36,7 @@
3436
'terminal_id' => env('AP_MERCHANT_ID'),
3537
'key' => env('AP_KEY'),
3638
'iv' => env('AP_IV'),
39+
'cumulative' => env('AP_CUMULATIVE', false),
3740
],
3841
/*
3942
|--------------------------------------------------------------------------
@@ -43,6 +46,7 @@
4346
'saman' => [
4447
'terminal_id' => env('SAMAN_TERMINAL_ID'),
4548
'terminal_pass' => env('SAMAN_TERMINAL_PASS'),
49+
'cumulative' => env('SAMAN_CUMULATIVE', false),
4650
],
4751
/*
4852
|--------------------------------------------------------------------------
@@ -51,6 +55,7 @@
5155
*/
5256
'parsian' => [
5357
'pin' => env('PARSIAN_PIN', ''),
58+
'cumulative' => env('PARSIAN_CUMULATIVE', false),
5459
],
5560
/*
5661
|--------------------------------------------------------------------------
@@ -61,6 +66,7 @@
6166
'terminal_id' => env('PASARGAD_TERMINAL_ID'),
6267
'merchant_id' => env('PASARGAD_MERCHANT_ID'),
6368
'certificate_path' => env('PASARGAD_CERT_PATH', storage_path('shaparak/pasargad/certificate.xml')),
69+
'cumulative' => env('PASARGAD_CUMULATIVE', false),
6470
],
6571
/*
6672
|--------------------------------------------------------------------------
@@ -71,6 +77,7 @@
7177
'username' => env('MELLAT_USERNAME'),
7278
'password' => env('MELLAT_PASSWORD'),
7379
'terminal_id' => env('MELLAT_TERMINAL_ID'),
80+
'cumulative' => env('MELLAT_CUMULATIVE', false),
7481
],
7582
/*
7683
|--------------------------------------------------------------------------
@@ -81,6 +88,7 @@
8188
'merchant_id' => env('MELLI_MERCHANT_ID'),
8289
'terminal_id' => env('MELLI_TERMINAL_ID'),
8390
'transaction_key' => env('MELLI_TRANS_KEY'),
91+
'cumulative' => env('MELLI_CUMULATIVE', false),
8492
],
8593
/*
8694
|--------------------------------------------------------------------------
@@ -89,6 +97,7 @@
8997
*/
9098
'saderat' => [
9199
'terminal_id' => env('SADERAT_MERCHANT_ID'),
100+
'cumulative' => env('SADERAT_CUMULATIVE', false),
92101
],
93102
/*
94103
|--------------------------------------------------------------------------
@@ -97,6 +106,7 @@
97106
*/
98107
'zarinpal' => [
99108
'merchant_id' => env('ZARINPAL_MERCHANT_ID'),
109+
'cumulative' => env('ZARINPAL_CUMULATIVE', false),
100110
],
101111
],
102112

src/Provider/AsanPardakhtProvider.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,18 @@ public function requestTokenData(): array
162162
'local_time',
163163
]);
164164

165-
return [
165+
$data = [
166166
'serviceTypeId' => 1,
167167
'merchantConfigurationId' => $this->getParameters('terminal_id'),
168168
'localInvoiceId' => $this->getGatewayOrderId(), // get it from Transaction
169169
'amountInRials' => $this->getAmount(),
170170
'localDate' => $this->getParameters('local_date').' '.$this->getParameters('local_time'),
171171
'callbackURL' => $this->getCallbackUrl(),
172-
'paymentId' => 0,
172+
'paymentId' => $this->getParameters('payment_id', 0),
173173
'additionalData' => (string) $this->getParameters('additional_data', ''),
174174
];
175+
176+
return array_merge($data, $this->cumulativeData());
175177
}
176178

177179
public function sendParamToAp(array $params, string $url, string $method): mixed
@@ -392,4 +394,14 @@ protected function generateComplementaryOperation($method): bool
392394

393395
return false;
394396
}
397+
398+
private function cumulativeData(): array
399+
{
400+
if ($this->getParameters('cumulative')) {
401+
return [
402+
'settlementPortions' => $this->getParameters('settlement_portions')
403+
];
404+
}
405+
return [];
406+
}
395407
}

src/Provider/MellatProvider.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ protected function requestToken(): string
4545
'additionalData' => (string) $this->getParameters('additional_data'),
4646
'callBackUrl' => $this->getCallbackUrl(),
4747
'payerId' => (int) $this->getParameters('payer_id'),
48+
'user_mobile' => '98' . substr($this->getParameters('user_mobile'), -10)
4849
];
4950

5051
try {
5152
$soapClient = $this->getSoapClient(self::URL_TOKEN);
5253

53-
$response = $soapClient->bpPayRequest($sendParams);
54+
if ($this->getParameters('cumulative')) {
55+
$response = $soapClient->bpCumulativeDynamicPayRequest($sendParams);
56+
} else {
57+
$response = $soapClient->bpPayRequest($sendParams);
58+
}
5459

5560
if (isset($response->return)) {
5661
$response = explode(',', $response->return);

0 commit comments

Comments
 (0)