11<?php
22
3- declare (strict_types= 1 );
3+ declare (strict_types = 1 );
44
55namespace Tartan \Larapay \Adapter ;
66
7+ use a \Sharing ;
78use SoapFault ;
89use Tartan \Larapay \Adapter \Parsian \Exception ;
910use Tartan \Log \Facades \XLog ;
1415 */
1516class Parsian extends AdapterAbstract implements AdapterInterface
1617{
17- protected $ WSDLSale = 'https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?WSDL ' ;
18- protected $ WSDLConfirm = 'https://pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?WSDL ' ;
19- protected $ WSDLReversal = 'https://pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx ' ;
18+ protected $ WSDLSale = 'https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?WSDL ' ;
19+ protected $ WSDLConfirm = 'https://pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?WSDL ' ;
20+ protected $ WSDLReversal = 'https://pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx ' ;
2021 protected $ WSDLMultiplex = 'https://pec.shaparak.ir/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?wsdl ' ;
2122
22- protected $ endPoint = 'https://pec.shaparak.ir/NewIPG/ ' ;
23+ protected $ endPoint = 'https://pec.shaparak.ir/NewIPG/ ' ;
2324
24- protected $ testWSDLSale = 'http://banktest.ir/gateway/parsian-sale/ws?wsdl ' ;
25- protected $ testWSDLConfirm = 'http://banktest.ir/gateway/parsian-confirm/ws?wsdl ' ;
26- protected $ testWSDLReversal = 'http://banktest.ir/gateway/parsian-reverse/ws?wsdl ' ;
25+ protected $ testWSDLSale = 'http://banktest.ir/gateway/parsian-sale/ws?wsdl ' ;
26+ protected $ testWSDLConfirm = 'http://banktest.ir/gateway/parsian-confirm/ws?wsdl ' ;
27+ protected $ testWSDLReversal = 'http://banktest.ir/gateway/parsian-reverse/ws?wsdl ' ;
2728 protected $ testWSDLMultiplex = 'http://banktest.ir/parsian/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?wsdl ' ;
2829
29- protected $ testEndPoint = 'http://banktest.ir/gateway/parsian/gate ' ;
30+ protected $ testEndPoint = 'http://banktest.ir/gateway/parsian/gate ' ;
3031
3132 protected $ reverseSupport = true ;
3233
@@ -123,20 +124,25 @@ private function requestTokenWithoutSharing($sendParams)
123124 */
124125 private function requestTokenWithSharing ($ sendParams )
125126 {
126- foreach ($ this ->sharing as $ item ) {
127- if (isset ($ item ->IBAN )) {
128- // dynamic sharing
129- $ method = 'MultiplexedSaleWithIBANPaymentRequest ' ;
130- $ respo = 'MultiplexedSaleWithIBANPaymentResult ' ;
127+ if (!isset ($ this ->sharing ['type ' ]) || !isset ($ this ->sharing ['data ' ])) {
128+ throw new Exception ('larapay::larapay.invalid_sharing_data ' );
129+ }
130+ if ($ this ->sharing ['type ' ] == Sharing::DYNAMIC ) {
131+ // dynamic sharing
132+ $ method = 'MultiplexedSaleWithIBANPaymentRequest ' ;
133+ $ respo = 'MultiplexedSaleWithIBANPaymentResult ' ;
134+ foreach ($ this ->sharing ['data ' ] as $ item ) {
131135 $ sendParams ['MultiplexedAccounts ' ]['Account ' ][] = [
132136 'Amount ' => $ item ->share ,
133137 'PayId ' => $ item ->pay_id ?? '' ,
134- 'IBAN ' => $ item ->iban
138+ 'IBAN ' => $ item ->iban ,
135139 ];
136- } else {
137- // fix sharing
138- $ method = 'MultiplexedSalePaymentRequest ' ;
139- $ respo = 'MultiplexedSalePaymentResult ' ;
140+ }
141+ } else {
142+ // fix sharing
143+ $ method = 'MultiplexedSalePaymentRequest ' ;
144+ $ respo = 'MultiplexedSalePaymentResult ' ;
145+ foreach ($ this ->sharing ['data ' ] as $ item ) {
140146 $ sendParams ['MultiplexedAccounts ' ]['Account ' ][] = [
141147 'Amount ' => $ item ->share ,
142148 'PayId ' => $ item ->pay_id ?? '' ,
@@ -169,6 +175,7 @@ private function requestTokenWithSharing($sendParams)
169175 throw new Exception ('SoapFault: ' . $ e ->getMessage () . ' # ' . $ e ->getCode (), $ e ->getCode ());
170176 }
171177 }
178+
172179 /**
173180 * @return mixed
174181 * @throws Exception
@@ -195,9 +202,9 @@ public function formParams(): array
195202 {
196203 $ authority = $ this ->requestToken ();
197204
198- return [
199- 'endPoint ' => $ this ->getEndPoint (),
200- 'refId ' => $ authority ,
205+ return [
206+ 'endPoint ' => $ this ->getEndPoint (),
207+ 'refId ' => $ authority ,
201208 ];
202209 }
203210
0 commit comments