From 9704ed5cce1fd975a1b821b3370d78e346060409 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 15 May 2021 22:28:33 +0300 Subject: [PATCH] fix CodeSniffer warnings --- src/Gateways/AbstractGateway.php | 8 +- src/Gateways/EstPos.php | 391 +++++------ src/Gateways/GarantiPos.php | 734 ++++++++++----------- src/Gateways/PayForPos.php | 354 +++++----- src/Gateways/PosNet.php | 479 +++++++------- src/PosInterface.php | 11 +- tests/Entity/Card/CreditCardEstPosTest.php | 3 +- tests/Entity/Card/CreditCardPosNetTest.php | 2 +- tests/Gateways/EstPostTest.php | 295 +++++---- tests/Gateways/GarantiPosTest.php | 406 ++++++------ tests/Gateways/PayForTest.php | 274 ++++---- tests/Gateways/PosNetCryptTest.php | 1 - tests/Gateways/PosNetTest.php | 212 +++--- 13 files changed, 1624 insertions(+), 1546 deletions(-) diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 4b036be7..687542b4 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -3,7 +3,6 @@ namespace Mews\Pos\Gateways; -use GuzzleHttp\Exception\GuzzleException; use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Exceptions\UnsupportedPaymentModelException; @@ -296,12 +295,7 @@ public function setTxType(string $txType) } /** - * @param AbstractCreditCard|null $card - * - * @return $this - * - * @throws GuzzleException - * @throws UnsupportedPaymentModelException + * @inheritDoc */ public function payment($card = null) { diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index d5aa592b..1b949ee5 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -48,13 +48,13 @@ class EstPos extends AbstractGateway * @var array */ protected $types = [ - self::TX_PAY => 'Auth', - self::TX_PRE_PAY => 'PreAuth', + self::TX_PAY => 'Auth', + self::TX_PRE_PAY => 'PreAuth', self::TX_POST_PAY => 'PostAuth', - self::TX_CANCEL => 'Void', - self::TX_REFUND => 'Credit', - self::TX_STATUS => 'ORDERSTATUS', - self::TX_HISTORY => 'ORDERHISTORY', + self::TX_CANCEL => 'Void', + self::TX_REFUND => 'Credit', + self::TX_STATUS => 'ORDERSTATUS', + self::TX_HISTORY => 'ORDERHISTORY', ]; @@ -64,12 +64,12 @@ class EstPos extends AbstractGateway * @var array */ protected $currencies = [ - 'TRY' => 949, - 'USD' => 840, - 'EUR' => 978, - 'GBP' => 826, - 'JPY' => 392, - 'RUB' => 643, + 'TRY' => 949, + 'USD' => 840, + 'EUR' => 978, + 'GBP' => 826, + 'JPY' => 392, + 'RUB' => 643, ]; /** @@ -85,9 +85,9 @@ class EstPos extends AbstractGateway /** * EstPos constructor. * - * @param array $config + * @param array $config * @param EstPosAccount $account - * @param array $currencies + * @param array $currencies */ public function __construct($config, $account, array $currencies = []) { @@ -112,9 +112,9 @@ public function create3DHash() $hashStr = ''; if ($this->account->getModel() === '3d') { - $hashStr = $this->account->getClientId() . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->order->rand . $this->account->getStoreKey(); + $hashStr = $this->account->getClientId().$this->order->id.$this->order->amount.$this->order->success_url.$this->order->fail_url.$this->order->rand.$this->account->getStoreKey(); } elseif ($this->account->getModel() === '3d_pay') { - $hashStr = $this->account->getClientId() . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->getStoreKey(); + $hashStr = $this->account->getClientId().$this->order->id.$this->order->amount.$this->order->success_url.$this->order->fail_url.$this->type.$this->order->installment.$this->order->rand.$this->account->getStoreKey(); } return base64_encode(sha1($hashStr, true)); @@ -122,6 +122,7 @@ public function create3DHash() /** * Check 3D Hash + * * @param array $data * * @return bool @@ -209,24 +210,24 @@ public function get3DFormData() $this->order->hash = $this->create3DHash(); $inputs = [ - 'clientid' => $this->account->getClientId(), + 'clientid' => $this->account->getClientId(), 'storetype' => $this->account->getModel(), - 'hash' => $this->order->hash, - 'firmaadi' => $this->order->name, - 'Email' => $this->order->email, - 'amount' => $this->order->amount, - 'oid' => $this->order->id, - 'okUrl' => $this->order->success_url, - 'failUrl' => $this->order->fail_url, - 'rnd' => $this->order->rand, - 'lang' => $this->getLang(), - 'currency' => $this->order->currency, + 'hash' => $this->order->hash, + 'firmaadi' => $this->order->name, + 'Email' => $this->order->email, + 'amount' => $this->order->amount, + 'oid' => $this->order->id, + 'okUrl' => $this->order->success_url, + 'failUrl' => $this->order->fail_url, + 'rnd' => $this->order->rand, + 'lang' => $this->getLang(), + 'currency' => $this->order->currency, ]; if ($this->account->getModel() === '3d_pay') { $inputs = array_merge($inputs, [ 'islemtipi' => $this->type, - 'taksit' => $this->order->installment, + 'taksit' => $this->order->installment, ]); } @@ -240,7 +241,7 @@ public function get3DFormData() return [ 'gateway' => $this->get3DGatewayURL(), - 'inputs' => $inputs, + 'inputs' => $inputs, ]; } @@ -304,25 +305,25 @@ public function setCard($card) public function createRegularPaymentXML() { $requestData = [ - 'Name' => $this->account->getUsername(), - 'Password' => $this->account->getPassword(), - 'ClientId' => $this->account->getClientId(), - 'Type' => $this->type, + 'Name' => $this->account->getUsername(), + 'Password' => $this->account->getPassword(), + 'ClientId' => $this->account->getClientId(), + 'Type' => $this->type, 'IPAddress' => $this->order->ip, - 'Email' => $this->order->email, - 'OrderId' => $this->order->id, - 'UserId' => isset($this->order->user_id) ? $this->order->user_id : null, - 'Total' => $this->order->amount, - 'Currency' => $this->order->currency, - 'Taksit' => $this->order->installment, - 'CardType' => $this->card->getType(), - 'Number' => $this->card->getNumber(), - 'Expires' => $this->card->getExpirationDate(), - 'Cvv2Val' => $this->card->getCvv(), - 'Mode' => 'P', //TODO what is this constant for? - 'GroupId' => '', - 'TransId' => '', - 'BillTo' => [ + 'Email' => $this->order->email, + 'OrderId' => $this->order->id, + 'UserId' => isset($this->order->user_id) ? $this->order->user_id : null, + 'Total' => $this->order->amount, + 'Currency' => $this->order->currency, + 'Taksit' => $this->order->installment, + 'CardType' => $this->card->getType(), + 'Number' => $this->card->getNumber(), + 'Expires' => $this->card->getExpirationDate(), + 'Cvv2Val' => $this->card->getCvv(), + 'Mode' => 'P', //TODO what is this constant for? + 'GroupId' => '', + 'TransId' => '', + 'BillTo' => [ 'Name' => $this->order->name ? $this->order->name : null, ], ]; @@ -336,11 +337,11 @@ public function createRegularPaymentXML() public function createRegularPostXML() { $requestData = [ - 'Name' => $this->account->getUsername(), + 'Name' => $this->account->getUsername(), 'Password' => $this->account->getPassword(), 'ClientId' => $this->account->getClientId(), - 'Type' => $this->types[self::TX_POST_PAY], - 'OrderId' => $this->order->id, + 'Type' => $this->types[self::TX_POST_PAY], + 'OrderId' => $this->order->id, ]; return $this->createXML($requestData); @@ -352,27 +353,27 @@ public function createRegularPostXML() public function create3DPaymentXML($responseData) { $requestData = [ - 'Name' => $this->account->getUsername(), - 'Password' => $this->account->getPassword(), - 'ClientId' => $this->account->getClientId(), - 'Type' => $this->type, - 'IPAddress' => $this->order->ip, - 'Email' => $this->order->email, - 'OrderId' => $this->order->id, - 'UserId' => isset($this->order->user_id) ? $this->order->user_id : null, - 'Total' => $this->order->amount, - 'Currency' => $this->order->currency, - 'Taksit' => $this->order->installment, - 'Number' => $responseData['md'], - 'Expires' => '', - 'Cvv2Val' => '', - 'PayerTxnId' => $responseData['xid'], - 'PayerSecurityLevel' => $responseData['eci'], + 'Name' => $this->account->getUsername(), + 'Password' => $this->account->getPassword(), + 'ClientId' => $this->account->getClientId(), + 'Type' => $this->type, + 'IPAddress' => $this->order->ip, + 'Email' => $this->order->email, + 'OrderId' => $this->order->id, + 'UserId' => isset($this->order->user_id) ? $this->order->user_id : null, + 'Total' => $this->order->amount, + 'Currency' => $this->order->currency, + 'Taksit' => $this->order->installment, + 'Number' => $responseData['md'], + 'Expires' => '', + 'Cvv2Val' => '', + 'PayerTxnId' => $responseData['xid'], + 'PayerSecurityLevel' => $responseData['eci'], 'PayerAuthenticationCode' => $responseData['cavv'], - 'CardholderPresentCode' => '13', - 'Mode' => 'P', - 'GroupId' => '', - 'TransId' => '', + 'CardholderPresentCode' => '13', + 'Mode' => 'P', + 'GroupId' => '', + 'TransId' => '', ]; if ($this->order->name) { @@ -390,11 +391,11 @@ public function create3DPaymentXML($responseData) public function createStatusXML() { $requestData = [ - 'Name' => $this->account->getUsername(), + 'Name' => $this->account->getUsername(), 'Password' => $this->account->getPassword(), 'ClientId' => $this->account->getClientId(), - 'OrderId' => $this->order->id, - 'Extra' => [ + 'OrderId' => $this->order->id, + 'Extra' => [ $this->types[self::TX_STATUS] => 'QUERY', ], ]; @@ -408,11 +409,11 @@ public function createStatusXML() public function createHistoryXML($customQueryData) { $requestData = [ - 'Name' => $this->account->getUsername(), + 'Name' => $this->account->getUsername(), 'Password' => $this->account->getPassword(), 'ClientId' => $this->account->getClientId(), - 'OrderId' => $this->order->id, - 'Extra' => [ + 'OrderId' => $this->order->id, + 'Extra' => [ $this->types[self::TX_HISTORY] => 'QUERY', ], ]; @@ -426,11 +427,11 @@ public function createHistoryXML($customQueryData) public function createCancelXML() { $requestData = [ - 'Name' => $this->account->getUsername(), + 'Name' => $this->account->getUsername(), 'Password' => $this->account->getPassword(), 'ClientId' => $this->account->getClientId(), - 'OrderId' => $this->order->id, - 'Type' => $this->types[self::TX_CANCEL], + 'OrderId' => $this->order->id, + 'Type' => $this->types[self::TX_CANCEL], ]; return $this->createXML($requestData); @@ -442,11 +443,11 @@ public function createCancelXML() public function createRefundXML() { $requestData = [ - 'Name' => $this->account->getUsername(), + 'Name' => $this->account->getUsername(), 'Password' => $this->account->getPassword(), 'ClientId' => $this->account->getClientId(), - 'OrderId' => $this->order->id, - 'Type' => $this->types[self::TX_REFUND], + 'OrderId' => $this->order->id, + 'Type' => $this->types[self::TX_REFUND], ]; if (isset($this->order->amount)) { @@ -496,23 +497,23 @@ protected function map3DPaymentData($raw3DAuthResponseData, $rawPaymentResponseD $threeDResponse = [ 'transaction_security' => $transactionSecurity, - 'md_status' => $raw3DAuthResponseData['mdStatus'], - 'hash' => (string) $raw3DAuthResponseData['HASH'], - 'rand' => (string) $raw3DAuthResponseData['rnd'], - 'hash_params' => (string) $raw3DAuthResponseData['HASHPARAMS'], - 'hash_params_val' => (string) $raw3DAuthResponseData['HASHPARAMSVAL'], - 'masked_number' => (string) $raw3DAuthResponseData['maskedCreditCard'], - 'month' => (string) $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'], - 'year' => (string) $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'], - 'amount' => (string) $raw3DAuthResponseData['amount'], - 'currency' => (string) $raw3DAuthResponseData['currency'], - 'eci' => (string) $raw3DAuthResponseData['eci'], - 'tx_status' => null, - 'cavv' => (string) $raw3DAuthResponseData['cavv'], - 'xid' => (string) $raw3DAuthResponseData['oid'], - 'md_error_message' => (string) $raw3DAuthResponseData['mdErrorMsg'], - 'name' => (string) $raw3DAuthResponseData['firmaadi'], - '3d_all' => $raw3DAuthResponseData, + 'md_status' => $raw3DAuthResponseData['mdStatus'], + 'hash' => (string) $raw3DAuthResponseData['HASH'], + 'rand' => (string) $raw3DAuthResponseData['rnd'], + 'hash_params' => (string) $raw3DAuthResponseData['HASHPARAMS'], + 'hash_params_val' => (string) $raw3DAuthResponseData['HASHPARAMSVAL'], + 'masked_number' => (string) $raw3DAuthResponseData['maskedCreditCard'], + 'month' => (string) $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'], + 'year' => (string) $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'], + 'amount' => (string) $raw3DAuthResponseData['amount'], + 'currency' => (string) $raw3DAuthResponseData['currency'], + 'eci' => (string) $raw3DAuthResponseData['eci'], + 'tx_status' => null, + 'cavv' => (string) $raw3DAuthResponseData['cavv'], + 'xid' => (string) $raw3DAuthResponseData['oid'], + 'md_error_message' => (string) $raw3DAuthResponseData['mdErrorMsg'], + 'name' => (string) $raw3DAuthResponseData['firmaadi'], + '3d_all' => $raw3DAuthResponseData, ]; return (object) array_merge($threeDResponse, $paymentResponseData); @@ -541,39 +542,39 @@ protected function map3DPayResponseData($raw3DAuthResponseData) } return (object) [ - 'id' => $raw3DAuthResponseData['AuthCode'], - 'trans_id' => $raw3DAuthResponseData['TransId'], - 'auth_code' => $raw3DAuthResponseData['AuthCode'], - 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], - 'response' => $raw3DAuthResponseData['Response'], - 'order_id' => $raw3DAuthResponseData['oid'], - 'transaction_type' => $this->type, - 'transaction' => $this->type, + 'id' => $raw3DAuthResponseData['AuthCode'], + 'trans_id' => $raw3DAuthResponseData['TransId'], + 'auth_code' => $raw3DAuthResponseData['AuthCode'], + 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], + 'response' => $raw3DAuthResponseData['Response'], + 'order_id' => $raw3DAuthResponseData['oid'], + 'transaction_type' => $this->type, + 'transaction' => $this->type, 'transaction_security' => $transactionSecurity, - 'code' => $raw3DAuthResponseData['ProcReturnCode'], - 'md_status' => $raw3DAuthResponseData['mdStatus'], - 'status' => $status, - 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $raw3DAuthResponseData['ProcReturnCode'] : null, - 'hash' => $raw3DAuthResponseData['HASH'], - 'rand' => $raw3DAuthResponseData['rnd'], - 'hash_params' => $raw3DAuthResponseData['HASHPARAMS'], - 'hash_params_val' => $raw3DAuthResponseData['HASHPARAMSVAL'], - 'masked_number' => $raw3DAuthResponseData['maskedCreditCard'], - 'month' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'], - 'year' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'], - 'amount' => $raw3DAuthResponseData['amount'], - 'currency' => $raw3DAuthResponseData['currency'], - 'tx_status' => null, - 'eci' => $raw3DAuthResponseData['eci'], - 'cavv' => $raw3DAuthResponseData['cavv'], - 'xid' => $raw3DAuthResponseData['oid'], - 'error_code' => isset($raw3DAuthResponseData['ErrMsg']) ? $raw3DAuthResponseData['ProcReturnCode'] : null, - 'error_message' => $raw3DAuthResponseData['ErrMsg'], - 'md_error_message' => $raw3DAuthResponseData['mdErrorMsg'], - 'name' => $raw3DAuthResponseData['firmaadi'], - 'email' => $raw3DAuthResponseData['Email'], - 'campaign_url' => null, - 'all' => $raw3DAuthResponseData, + 'code' => $raw3DAuthResponseData['ProcReturnCode'], + 'md_status' => $raw3DAuthResponseData['mdStatus'], + 'status' => $status, + 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $raw3DAuthResponseData['ProcReturnCode'] : null, + 'hash' => $raw3DAuthResponseData['HASH'], + 'rand' => $raw3DAuthResponseData['rnd'], + 'hash_params' => $raw3DAuthResponseData['HASHPARAMS'], + 'hash_params_val' => $raw3DAuthResponseData['HASHPARAMSVAL'], + 'masked_number' => $raw3DAuthResponseData['maskedCreditCard'], + 'month' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'], + 'year' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'], + 'amount' => $raw3DAuthResponseData['amount'], + 'currency' => $raw3DAuthResponseData['currency'], + 'tx_status' => null, + 'eci' => $raw3DAuthResponseData['eci'], + 'cavv' => $raw3DAuthResponseData['cavv'], + 'xid' => $raw3DAuthResponseData['oid'], + 'error_code' => isset($raw3DAuthResponseData['ErrMsg']) ? $raw3DAuthResponseData['ProcReturnCode'] : null, + 'error_message' => $raw3DAuthResponseData['ErrMsg'], + 'md_error_message' => $raw3DAuthResponseData['mdErrorMsg'], + 'name' => $raw3DAuthResponseData['firmaadi'], + 'email' => $raw3DAuthResponseData['Email'], + 'campaign_url' => null, + 'all' => $raw3DAuthResponseData, ]; } @@ -588,18 +589,18 @@ protected function mapRefundResponse($rawResponseData) } return (object) [ - 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, - 'group_id' => isset($rawResponseData->GroupId) ? $rawResponseData->GroupId : null, - 'response' => isset($rawResponseData->Response) ? $rawResponseData->Response : null, - 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, - 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, + 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, + 'group_id' => isset($rawResponseData->GroupId) ? $rawResponseData->GroupId : null, + 'response' => isset($rawResponseData->Response) ? $rawResponseData->Response : null, + 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, + 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $rawResponseData->ProcReturnCode : null, - 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, - 'error_code' => isset($rawResponseData->Extra->ERRORCODE) ? $rawResponseData->Extra->ERRORCODE : null, - 'error_message' => isset($rawResponseData->ErrMsg) ? $rawResponseData->ErrMsg : null, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'all' => $rawResponseData, + 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, + 'error_code' => isset($rawResponseData->Extra->ERRORCODE) ? $rawResponseData->Extra->ERRORCODE : null, + 'error_message' => isset($rawResponseData->ErrMsg) ? $rawResponseData->ErrMsg : null, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'all' => $rawResponseData, ]; } @@ -614,18 +615,18 @@ protected function mapCancelResponse($rawResponseData) } $this->response = (object) [ - 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, - 'group_id' => isset($rawResponseData->GroupId) ? $rawResponseData->GroupId : null, - 'response' => isset($rawResponseData->Response) ? $rawResponseData->Response : null, - 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, - 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, + 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, + 'group_id' => isset($rawResponseData->GroupId) ? $rawResponseData->GroupId : null, + 'response' => isset($rawResponseData->Response) ? $rawResponseData->Response : null, + 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, + 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $rawResponseData->ProcReturnCode : null, - 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, - 'error_code' => isset($rawResponseData->Extra->ERRORCODE) ? $rawResponseData->Extra->ERRORCODE : null, - 'error_message' => isset($rawResponseData->ErrMsg) ? $rawResponseData->ErrMsg : null, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'all' => $rawResponseData, + 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, + 'error_code' => isset($rawResponseData->Extra->ERRORCODE) ? $rawResponseData->Extra->ERRORCODE : null, + 'error_message' => isset($rawResponseData->ErrMsg) ? $rawResponseData->ErrMsg : null, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'all' => $rawResponseData, ]; } @@ -644,22 +645,22 @@ protected function mapStatusResponse($rawResponseData) $capture = $firstAmount === $captureAmount ? true : false; return (object) [ - 'order_id' => isset($rawResponseData->OrderId) ? $this->printData($rawResponseData->OrderId) : null, - 'response' => isset($rawResponseData->Response) ? $this->printData($rawResponseData->Response) : null, + 'order_id' => isset($rawResponseData->OrderId) ? $this->printData($rawResponseData->OrderId) : null, + 'response' => isset($rawResponseData->Response) ? $this->printData($rawResponseData->Response) : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $this->printData($rawResponseData->ProcReturnCode) : null, - 'trans_id' => isset($rawResponseData->TransId) ? $this->printData($rawResponseData->TransId) : null, - 'error_message' => isset($rawResponseData->ErrMsg) ? $this->printData($rawResponseData->ErrMsg) : null, - 'host_ref_num' => isset($rawResponseData->Extra->HOST_REF_NUM) ? $this->printData($rawResponseData->Extra->HOST_REF_NUM) : null, - 'order_status' => isset($rawResponseData->Extra->ORDERSTATUS) ? $this->printData($rawResponseData->Extra->ORDERSTATUS) : null, - 'process_type' => isset($rawResponseData->Extra->CHARGE_TYPE_CD) ? $this->printData($rawResponseData->Extra->CHARGE_TYPE_CD) : null, - 'pan' => isset($rawResponseData->Extra->PAN) ? $this->printData($rawResponseData->Extra->PAN) : null, - 'num_code' => isset($rawResponseData->Extra->NUMCODE) ? $this->printData($rawResponseData->Extra->NUMCODE) : null, - 'first_amount' => $firstAmount, - 'capture_amount' => $captureAmount, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'capture' => $capture, - 'all' => $rawResponseData, + 'trans_id' => isset($rawResponseData->TransId) ? $this->printData($rawResponseData->TransId) : null, + 'error_message' => isset($rawResponseData->ErrMsg) ? $this->printData($rawResponseData->ErrMsg) : null, + 'host_ref_num' => isset($rawResponseData->Extra->HOST_REF_NUM) ? $this->printData($rawResponseData->Extra->HOST_REF_NUM) : null, + 'order_status' => isset($rawResponseData->Extra->ORDERSTATUS) ? $this->printData($rawResponseData->Extra->ORDERSTATUS) : null, + 'process_type' => isset($rawResponseData->Extra->CHARGE_TYPE_CD) ? $this->printData($rawResponseData->Extra->CHARGE_TYPE_CD) : null, + 'pan' => isset($rawResponseData->Extra->PAN) ? $this->printData($rawResponseData->Extra->PAN) : null, + 'num_code' => isset($rawResponseData->Extra->NUMCODE) ? $this->printData($rawResponseData->Extra->NUMCODE) : null, + 'first_amount' => $firstAmount, + 'capture_amount' => $captureAmount, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'capture' => $capture, + 'all' => $rawResponseData, ]; } @@ -673,25 +674,25 @@ protected function mapPaymentResponse($responseData) $status = 'approved'; } - return [ - 'id' => isset($responseData->AuthCode) ? $this->printData($responseData->AuthCode) : null, - 'order_id' => isset($responseData->OrderId) ? $this->printData($responseData->OrderId) : null, - 'group_id' => isset($responseData->GroupId) ? $this->printData($responseData->GroupId) : null, - 'trans_id' => isset($responseData->TransId) ? $this->printData($responseData->TransId) : null, - 'response' => isset($responseData->Response) ? $this->printData($responseData->Response) : null, + return [ + 'id' => isset($responseData->AuthCode) ? $this->printData($responseData->AuthCode) : null, + 'order_id' => isset($responseData->OrderId) ? $this->printData($responseData->OrderId) : null, + 'group_id' => isset($responseData->GroupId) ? $this->printData($responseData->GroupId) : null, + 'trans_id' => isset($responseData->TransId) ? $this->printData($responseData->TransId) : null, + 'response' => isset($responseData->Response) ? $this->printData($responseData->Response) : null, 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'auth_code' => isset($responseData->AuthCode) ? $this->printData($responseData->AuthCode) : null, - 'host_ref_num' => isset($responseData->HostRefNum) ? $this->printData($responseData->HostRefNum) : null, + 'transaction' => $this->type, + 'auth_code' => isset($responseData->AuthCode) ? $this->printData($responseData->AuthCode) : null, + 'host_ref_num' => isset($responseData->HostRefNum) ? $this->printData($responseData->HostRefNum) : null, 'proc_return_code' => isset($responseData->ProcReturnCode) ? $this->printData($responseData->ProcReturnCode) : null, - 'code' => isset($responseData->ProcReturnCode) ? $this->printData($responseData->ProcReturnCode) : null, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => isset($responseData->Extra->ERRORCODE) ? $this->printData($responseData->Extra->ERRORCODE) : null, - 'error_message' => isset($responseData->Extra->ERRORCODE) ? $this->printData($responseData->ErrMsg) : null, - 'campaign_url' => null, - 'extra' => isset($responseData->Extra) ? $responseData->Extra : null, - 'all' => $responseData, + 'code' => isset($responseData->ProcReturnCode) ? $this->printData($responseData->ProcReturnCode) : null, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => isset($responseData->Extra->ERRORCODE) ? $this->printData($responseData->Extra->ERRORCODE) : null, + 'error_message' => isset($responseData->Extra->ERRORCODE) ? $this->printData($responseData->ErrMsg) : null, + 'campaign_url' => null, + 'extra' => isset($responseData->Extra) ? $responseData->Extra : null, + 'all' => $responseData, ]; } @@ -706,15 +707,15 @@ protected function mapHistoryResponse($rawResponseData) } return (object) [ - 'order_id' => isset($rawResponseData->OrderId) ? $this->printData($rawResponseData->OrderId) : null, - 'response' => isset($rawResponseData->Response) ? $this->printData($rawResponseData->Response) : null, + 'order_id' => isset($rawResponseData->OrderId) ? $this->printData($rawResponseData->OrderId) : null, + 'response' => isset($rawResponseData->Response) ? $this->printData($rawResponseData->Response) : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $this->printData($rawResponseData->ProcReturnCode) : null, - 'error_message' => isset($rawResponseData->ErrMsg) ? $this->printData($rawResponseData->ErrMsg) : null, - 'num_code' => isset($rawResponseData->Extra->NUMCODE) ? $this->printData($rawResponseData->Extra->NUMCODE) : null, - 'trans_count' => isset($rawResponseData->Extra->TRXCOUNT) ? $this->printData($rawResponseData->Extra->TRXCOUNT) : null, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'all' => $rawResponseData, + 'error_message' => isset($rawResponseData->ErrMsg) ? $this->printData($rawResponseData->ErrMsg) : null, + 'num_code' => isset($rawResponseData->Extra->NUMCODE) ? $this->printData($rawResponseData->Extra->NUMCODE) : null, + 'trans_count' => isset($rawResponseData->Extra->TRXCOUNT) ? $this->printData($rawResponseData->Extra->TRXCOUNT) : null, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'all' => $rawResponseData, ]; } @@ -731,8 +732,8 @@ protected function preparePaymentOrder(array $order) // Order return (object) array_merge($order, [ - 'installment' => $installment, - 'currency' => $this->mapCurrency($order['currency']), + 'installment' => $installment, + 'currency' => $this->mapCurrency($order['currency']), ]); } diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index bc913b6d..588e3225 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -33,19 +33,19 @@ class GarantiPos extends AbstractGateway * @var array */ protected $codes = [ - '00' => 'approved', - '01' => 'bank_call', - '02' => 'bank_call', - '05' => 'reject', - '09' => 'try_again', - '12' => 'invalid_transaction', - '28' => 'reject', - '51' => 'insufficient_balance', - '54' => 'expired_card', - '57' => 'does_not_allow_card_holder', - '62' => 'restricted_card', - '77' => 'request_rejected', - '99' => 'general_error', + '00' => 'approved', + '01' => 'bank_call', + '02' => 'bank_call', + '05' => 'reject', + '09' => 'try_again', + '12' => 'invalid_transaction', + '28' => 'reject', + '51' => 'insufficient_balance', + '54' => 'expired_card', + '57' => 'does_not_allow_card_holder', + '62' => 'restricted_card', + '77' => 'request_rejected', + '99' => 'general_error', ]; /** @@ -54,13 +54,13 @@ class GarantiPos extends AbstractGateway * @var array */ protected $types = [ - self::TX_PAY => 'sales', - self::TX_PRE_PAY => 'preauth', + self::TX_PAY => 'sales', + self::TX_PRE_PAY => 'preauth', self::TX_POST_PAY => 'postauth', - self::TX_CANCEL => 'void', - self::TX_REFUND => 'refund', - self::TX_HISTORY => 'orderhistoryinq', - self::TX_STATUS => 'orderinq', + self::TX_CANCEL => 'void', + self::TX_REFUND => 'refund', + self::TX_HISTORY => 'orderhistoryinq', + self::TX_STATUS => 'orderinq', ]; @@ -70,12 +70,12 @@ class GarantiPos extends AbstractGateway * @var array */ protected $currencies = [ - 'TRY' => 949, - 'USD' => 840, - 'EUR' => 978, - 'GBP' => 826, - 'JPY' => 392, - 'RUB' => 643, + 'TRY' => 949, + 'USD' => 840, + 'EUR' => 978, + 'GBP' => 826, + 'JPY' => 392, + 'RUB' => 643, ]; /** @@ -91,9 +91,9 @@ class GarantiPos extends AbstractGateway /** * GarantiPost constructor. * - * @param array $config + * @param array $config * @param GarantiPosAccount $account - * @param array $currencies + * @param array $currencies */ public function __construct($config, $account, array $currencies = []) { @@ -185,7 +185,7 @@ public function send($contents) $client = new Client(); $response = $client->request('POST', $this->getApiURL(), [ - 'body' => $contents, + 'body' => $contents, ]); $this->data = $this->XMLStringToObject($response->getBody()->getContents()); @@ -232,8 +232,8 @@ public function get3DFormData() } return [ - 'gateway' => $this->get3DGatewayURL(), - 'inputs' => $inputs, + 'gateway' => $this->get3DGatewayURL(), + 'inputs' => $inputs, ]; } @@ -252,43 +252,43 @@ public function make3DHostPayment() public function createRegularPaymentXML() { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'Terminal' => [ - 'ProvUserID' => $this->account->getUsername(), - 'UserID' => $this->account->getUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getTerminalId(), - ], - 'Customer' => [ - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Card' => [ - 'Number' => $this->card->getNumber(), - 'ExpireDate' => $this->card->getExpirationDate(), - 'CVV2' => $this->card->getCvv(), - ], - 'Order' => [ - 'OrderID' => $this->order->id, - 'GroupID' => '', - 'AddressList' => [ - 'Address' => [ - 'Type' => 'S', - 'Name' => $this->order->name, - 'LastName' => '', - 'Company' => '', - 'Text' => '', - 'District' => '', - 'City' => '', - 'PostalCode' => '', - 'Country' => '', - 'PhoneNumber' => '', + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'Terminal' => [ + 'ProvUserID' => $this->account->getUsername(), + 'UserID' => $this->account->getUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getTerminalId(), + ], + 'Customer' => [ + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Card' => [ + 'Number' => $this->card->getNumber(), + 'ExpireDate' => $this->card->getExpirationDate(), + 'CVV2' => $this->card->getCvv(), + ], + 'Order' => [ + 'OrderID' => $this->order->id, + 'GroupID' => '', + 'AddressList' => [ + 'Address' => [ + 'Type' => 'S', + 'Name' => $this->order->name, + 'LastName' => '', + 'Company' => '', + 'Text' => '', + 'District' => '', + 'City' => '', + 'PostalCode' => '', + 'Country' => '', + 'PhoneNumber' => '', ], ], ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => $this->type, 'InstallmentCnt' => $this->order->installment, 'Amount' => $this->order->amount, @@ -309,23 +309,23 @@ public function createRegularPaymentXML() public function createRegularPostXML() { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'Terminal' => [ - 'ProvUserID' => $this->account->getUsername(), - 'UserID' => $this->account->getUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Order' => [ - 'OrderID' => $this->order->id, - ], - 'Transaction' => [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'Terminal' => [ + 'ProvUserID' => $this->account->getUsername(), + 'UserID' => $this->account->getUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Order' => [ + 'OrderID' => $this->order->id, + ], + 'Transaction' => [ 'Type' => $this->types[self::TX_POST_PAY], 'Amount' => $this->order->amount, 'CurrencyCode' => $this->order->currency, @@ -342,44 +342,44 @@ public function createRegularPostXML() public function create3DPaymentXML($responseData) { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $this->account->getUsername(), - 'UserID' => $this->account->getUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ - 'IPAddress' => $responseData['customeripaddress'], - 'EmailAddress' => $responseData['customeremailaddress'], - ], - 'Card' => [ - 'Number' => '', - 'ExpireDate' => '', - 'CVV2' => '', - ], - 'Order' => [ - 'OrderID' => $responseData['orderid'], - 'GroupID' => '', - 'AddressList' => [ - 'Address' => [ - 'Type' => 'B', - 'Name' => $this->order->name, - 'LastName' => '', - 'Company' => '', - 'Text' => '', - 'District' => '', - 'City' => '', - 'PostalCode' => '', - 'Country' => '', - 'PhoneNumber' => '', + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $this->account->getUsername(), + 'UserID' => $this->account->getUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ + 'IPAddress' => $responseData['customeripaddress'], + 'EmailAddress' => $responseData['customeremailaddress'], + ], + 'Card' => [ + 'Number' => '', + 'ExpireDate' => '', + 'CVV2' => '', + ], + 'Order' => [ + 'OrderID' => $responseData['orderid'], + 'GroupID' => '', + 'AddressList' => [ + 'Address' => [ + 'Type' => 'B', + 'Name' => $this->order->name, + 'LastName' => '', + 'Company' => '', + 'Text' => '', + 'District' => '', + 'City' => '', + 'PostalCode' => '', + 'Country' => '', + 'PhoneNumber' => '', ], ], ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => $responseData['txntype'], 'InstallmentCnt' => $this->order->installment, 'Amount' => $responseData['txnamount'], @@ -387,10 +387,10 @@ public function create3DPaymentXML($responseData) 'CardholderPresentCode' => '13', 'MotoInd' => 'N', 'Secure3D' => [ - 'AuthenticationCode' => $responseData['cavv'], - 'SecurityLevel' => $responseData['eci'], - 'TxnID' => $responseData['xid'], - 'Md' => $responseData['md'], + 'AuthenticationCode' => $responseData['cavv'], + 'SecurityLevel' => $responseData['eci'], + 'TxnID' => $responseData['xid'], + 'Md' => $responseData['md'], ], ], ]; @@ -404,25 +404,25 @@ public function create3DPaymentXML($responseData) public function createCancelXML() { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $this->account->getRefundUsername(), - 'UserID' => $this->account->getRefundUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Order' => [ - 'OrderID' => $this->order->id, - 'GroupID' => '', - ], - 'Transaction' => [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $this->account->getRefundUsername(), + 'UserID' => $this->account->getRefundUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Order' => [ + 'OrderID' => $this->order->id, + 'GroupID' => '', + ], + 'Transaction' => [ 'Type' => $this->types[self::TX_CANCEL], 'InstallmentCnt' => $this->order->installment, 'Amount' => $this->order->amount, //TODO we need this field here? @@ -442,25 +442,25 @@ public function createCancelXML() public function createRefundXML() { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $this->account->getRefundUsername(), - 'UserID' => $this->account->getRefundUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Order' => [ - 'OrderID' => $this->order->id, - 'GroupID' => '', - ], - 'Transaction' => [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $this->account->getRefundUsername(), + 'UserID' => $this->account->getRefundUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Order' => [ + 'OrderID' => $this->order->id, + 'GroupID' => '', + ], + 'Transaction' => [ 'Type' => $this->types[self::TX_REFUND], 'InstallmentCnt' => $this->order->installment, 'Amount' => $this->order->amount, @@ -480,30 +480,30 @@ public function createRefundXML() public function createHistoryXML($customQueryData) { $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $this->account->getUsername(), - 'UserID' => $this->account->getUsername(), - 'HashData' => $this->createHashData(), - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ //TODO we need this data? - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Order' => [ - 'OrderID' => $this->order->id, - 'GroupID' => '', - ], - 'Card' => [ - 'Number' => '', - 'ExpireDate' => '', - 'CVV2' => '', - ], - 'Transaction' => [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $this->account->getUsername(), + 'UserID' => $this->account->getUsername(), + 'HashData' => $this->createHashData(), + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ //TODO we need this data? + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Order' => [ + 'OrderID' => $this->order->id, + 'GroupID' => '', + ], + 'Card' => [ + 'Number' => '', + 'ExpireDate' => '', + 'CVV2' => '', + ], + 'Transaction' => [ 'Type' => $this->types[self::TX_HISTORY], 'InstallmentCnt' => $this->order->installment, 'Amount' => $this->order->amount, @@ -524,30 +524,30 @@ public function createStatusXML() $hashData = $this->createHashData(); $requestData = [ - 'Mode' => $this->getMode(), - 'Version' => self::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $this->account->getUsername(), - 'UserID' => $this->account->getUsername(), - 'HashData' => $hashData, - 'ID' => $this->account->getTerminalId(), - 'MerchantID' => $this->account->getClientId(), - ], - 'Customer' => [ //TODO we need this data? - 'IPAddress' => $this->order->ip, - 'EmailAddress' => $this->order->email, - ], - 'Order' => [ - 'OrderID' => $this->order->id, - 'GroupID' => '', - ], - 'Card' => [ - 'Number' => '', - 'ExpireDate' => '', - 'CVV2' => '', - ], - 'Transaction' => [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $this->account->getUsername(), + 'UserID' => $this->account->getUsername(), + 'HashData' => $hashData, + 'ID' => $this->account->getTerminalId(), + 'MerchantID' => $this->account->getClientId(), + ], + 'Customer' => [ //TODO we need this data? + 'IPAddress' => $this->order->ip, + 'EmailAddress' => $this->order->email, + ], + 'Order' => [ + 'OrderID' => $this->order->id, + 'GroupID' => '', + ], + 'Card' => [ + 'Number' => '', + 'ExpireDate' => '', + 'CVV2' => '', + ], + 'Transaction' => [ 'Type' => $this->types[self::TX_STATUS], 'InstallmentCnt' => $this->order->installment, 'Amount' => $this->order->amount, //TODO we need it? @@ -646,46 +646,46 @@ protected function map3DPaymentData($raw3DAuthResponseData, $rawPaymentResponseD } return (object) [ - 'id' => isset($rawPaymentResponseData->Transaction->AuthCode) ? $this->printData($rawPaymentResponseData->Transaction->AuthCode) : null, - 'order_id' => $raw3DAuthResponseData['oid'], - 'group_id' => isset($rawPaymentResponseData->Transaction->SequenceNum) ? $this->printData($rawPaymentResponseData->Transaction->SequenceNum) : null, - 'auth_code' => isset($rawPaymentResponseData->Transaction->AuthCode) ? $this->printData($rawPaymentResponseData->Transaction->AuthCode) : null, - 'host_ref_num' => isset($rawPaymentResponseData->Transaction->RetrefNum) ? $this->printData($rawPaymentResponseData->Transaction->RetrefNum) : null, - 'ret_ref_num' => isset($rawPaymentResponseData->Transaction->RetrefNum) ? $this->printData($rawPaymentResponseData->Transaction->RetrefNum) : null, - 'batch_num' => isset($rawPaymentResponseData->Transaction->BatchNum) ? $this->printData($rawPaymentResponseData->Transaction->BatchNum) : null, - 'error_code' => isset($rawPaymentResponseData->Transaction->Response->ErrorCode) ? $this->printData($rawPaymentResponseData->Transaction->Response->ErrorCode) : null, - 'error_message' => isset($rawPaymentResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawPaymentResponseData->Transaction->Response->ErrorMsg) : null, - 'reason_code' => isset($rawPaymentResponseData->Transaction->Response->ReasonCode) ? $this->printData($rawPaymentResponseData->Transaction->Response->ReasonCode) : null, - 'campaign_url' => isset($rawPaymentResponseData->Transaction->CampaignChooseLink) ? $this->printData($rawPaymentResponseData->Transaction->CampaignChooseLink) : null, - 'all' => $rawPaymentResponseData, - 'trans_id' => $raw3DAuthResponseData['transid'], - 'response' => $response, - 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'transaction_security' => $transactionSecurity, - 'proc_return_code' => $procReturnCode, - 'code' => $procReturnCode, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'md_status' => $raw3DAuthResponseData['mdstatus'], - 'rand' => (string) $raw3DAuthResponseData['rnd'], - 'hash' => (string) $raw3DAuthResponseData['secure3dhash'], - 'hash_params' => (string) $raw3DAuthResponseData['hashparams'], - 'hash_params_val' => (string) $raw3DAuthResponseData['hashparamsval'], - 'secure_3d_hash' => (string) $raw3DAuthResponseData['secure3dhash'], - 'secure_3d_level' => (string) $raw3DAuthResponseData['secure3dsecuritylevel'], - 'masked_number' => (string) $raw3DAuthResponseData['MaskedPan'], - 'amount' => (string) $raw3DAuthResponseData['txnamount'], - 'currency' => (string) $raw3DAuthResponseData['txncurrencycode'], - 'tx_status' => (string) $raw3DAuthResponseData['txnstatus'], - 'eci' => (string) $raw3DAuthResponseData['eci'], - 'cavv' => (string) $raw3DAuthResponseData['cavv'], - 'xid' => (string) $raw3DAuthResponseData['xid'], - 'md_error_message' => (string) $raw3DAuthResponseData['mderrormessage'], + 'id' => isset($rawPaymentResponseData->Transaction->AuthCode) ? $this->printData($rawPaymentResponseData->Transaction->AuthCode) : null, + 'order_id' => $raw3DAuthResponseData['oid'], + 'group_id' => isset($rawPaymentResponseData->Transaction->SequenceNum) ? $this->printData($rawPaymentResponseData->Transaction->SequenceNum) : null, + 'auth_code' => isset($rawPaymentResponseData->Transaction->AuthCode) ? $this->printData($rawPaymentResponseData->Transaction->AuthCode) : null, + 'host_ref_num' => isset($rawPaymentResponseData->Transaction->RetrefNum) ? $this->printData($rawPaymentResponseData->Transaction->RetrefNum) : null, + 'ret_ref_num' => isset($rawPaymentResponseData->Transaction->RetrefNum) ? $this->printData($rawPaymentResponseData->Transaction->RetrefNum) : null, + 'batch_num' => isset($rawPaymentResponseData->Transaction->BatchNum) ? $this->printData($rawPaymentResponseData->Transaction->BatchNum) : null, + 'error_code' => isset($rawPaymentResponseData->Transaction->Response->ErrorCode) ? $this->printData($rawPaymentResponseData->Transaction->Response->ErrorCode) : null, + 'error_message' => isset($rawPaymentResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawPaymentResponseData->Transaction->Response->ErrorMsg) : null, + 'reason_code' => isset($rawPaymentResponseData->Transaction->Response->ReasonCode) ? $this->printData($rawPaymentResponseData->Transaction->Response->ReasonCode) : null, + 'campaign_url' => isset($rawPaymentResponseData->Transaction->CampaignChooseLink) ? $this->printData($rawPaymentResponseData->Transaction->CampaignChooseLink) : null, + 'all' => $rawPaymentResponseData, + 'trans_id' => $raw3DAuthResponseData['transid'], + 'response' => $response, + 'transaction_type' => $this->type, + 'transaction' => $this->type, + 'transaction_security' => $transactionSecurity, + 'proc_return_code' => $procReturnCode, + 'code' => $procReturnCode, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'md_status' => $raw3DAuthResponseData['mdstatus'], + 'rand' => (string) $raw3DAuthResponseData['rnd'], + 'hash' => (string) $raw3DAuthResponseData['secure3dhash'], + 'hash_params' => (string) $raw3DAuthResponseData['hashparams'], + 'hash_params_val' => (string) $raw3DAuthResponseData['hashparamsval'], + 'secure_3d_hash' => (string) $raw3DAuthResponseData['secure3dhash'], + 'secure_3d_level' => (string) $raw3DAuthResponseData['secure3dsecuritylevel'], + 'masked_number' => (string) $raw3DAuthResponseData['MaskedPan'], + 'amount' => (string) $raw3DAuthResponseData['txnamount'], + 'currency' => (string) $raw3DAuthResponseData['txncurrencycode'], + 'tx_status' => (string) $raw3DAuthResponseData['txnstatus'], + 'eci' => (string) $raw3DAuthResponseData['eci'], + 'cavv' => (string) $raw3DAuthResponseData['cavv'], + 'xid' => (string) $raw3DAuthResponseData['xid'], + 'md_error_message' => (string) $raw3DAuthResponseData['mderrormessage'], //'name' => (string) $raw3DAuthResponseData['firmaadi'], - 'email' => (string) $raw3DAuthResponseData['customeremailaddress'], - 'extra' => null, - '3d_all' => $raw3DAuthResponseData, + 'email' => (string) $raw3DAuthResponseData['customeremailaddress'], + 'extra' => null, + '3d_all' => $raw3DAuthResponseData, ]; } @@ -711,39 +711,39 @@ protected function map3DPayResponseData($raw3DAuthResponseData) } $this->response = (object) [ - 'id' => (string) $raw3DAuthResponseData['authcode'], - 'order_id' => (string) $raw3DAuthResponseData['oid'], - 'trans_id' => (string) $raw3DAuthResponseData['transid'], - 'auth_code' => (string) $raw3DAuthResponseData['authcode'], - 'host_ref_num' => (string) $raw3DAuthResponseData['hostrefnum'], - 'response' => $response, - 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'transaction_security' => $transactionSecurity, - 'proc_return_code' => $procReturnCode, - 'code' => $procReturnCode, - 'md_status' => $raw3DAuthResponseData['mdStatus'], - 'status' => $status, - 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? (string) $raw3DAuthResponseData['ProcReturnCode'] : null, - 'hash' => (string) $raw3DAuthResponseData['secure3dhash'], - 'rand' => (string) $raw3DAuthResponseData['rnd'], - 'hash_params' => (string) $raw3DAuthResponseData['hashparams'], - 'hash_params_val' => (string) $raw3DAuthResponseData['hashparamsval'], - 'masked_number' => (string) $raw3DAuthResponseData['MaskedPan'], - 'amount' => (string) $raw3DAuthResponseData['txnamount'], - 'currency' => (string) $raw3DAuthResponseData['txncurrencycode'], - 'tx_status' => (string) $raw3DAuthResponseData['txnstatus'], - 'eci' => (string) $raw3DAuthResponseData['eci'], - 'cavv' => (string) $raw3DAuthResponseData['cavv'], - 'xid' => (string) $raw3DAuthResponseData['xid'], - 'error_code' => (string) $raw3DAuthResponseData['errcode'], - 'error_message' => (string) $raw3DAuthResponseData['errmsg'], - 'md_error_message' => (string) $raw3DAuthResponseData['mderrormessage'], - 'campaign_url' => null, + 'id' => (string) $raw3DAuthResponseData['authcode'], + 'order_id' => (string) $raw3DAuthResponseData['oid'], + 'trans_id' => (string) $raw3DAuthResponseData['transid'], + 'auth_code' => (string) $raw3DAuthResponseData['authcode'], + 'host_ref_num' => (string) $raw3DAuthResponseData['hostrefnum'], + 'response' => $response, + 'transaction_type' => $this->type, + 'transaction' => $this->type, + 'transaction_security' => $transactionSecurity, + 'proc_return_code' => $procReturnCode, + 'code' => $procReturnCode, + 'md_status' => $raw3DAuthResponseData['mdStatus'], + 'status' => $status, + 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? (string) $raw3DAuthResponseData['ProcReturnCode'] : null, + 'hash' => (string) $raw3DAuthResponseData['secure3dhash'], + 'rand' => (string) $raw3DAuthResponseData['rnd'], + 'hash_params' => (string) $raw3DAuthResponseData['hashparams'], + 'hash_params_val' => (string) $raw3DAuthResponseData['hashparamsval'], + 'masked_number' => (string) $raw3DAuthResponseData['MaskedPan'], + 'amount' => (string) $raw3DAuthResponseData['txnamount'], + 'currency' => (string) $raw3DAuthResponseData['txncurrencycode'], + 'tx_status' => (string) $raw3DAuthResponseData['txnstatus'], + 'eci' => (string) $raw3DAuthResponseData['eci'], + 'cavv' => (string) $raw3DAuthResponseData['cavv'], + 'xid' => (string) $raw3DAuthResponseData['xid'], + 'error_code' => (string) $raw3DAuthResponseData['errcode'], + 'error_message' => (string) $raw3DAuthResponseData['errmsg'], + 'md_error_message' => (string) $raw3DAuthResponseData['mderrormessage'], + 'campaign_url' => null, //'name' => (string) $raw3DAuthResponseData['firmaadi'], - 'email' => (string) $raw3DAuthResponseData['customeremailaddress'], - 'extra' => $raw3DAuthResponseData['Extra'], - 'all' => $raw3DAuthResponseData, + 'email' => (string) $raw3DAuthResponseData['customeremailaddress'], + 'extra' => $raw3DAuthResponseData['Extra'], + 'all' => $raw3DAuthResponseData, ]; } @@ -758,26 +758,26 @@ protected function mapPaymentResponse($responseData) } return (object) [ - 'id' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, - 'order_id' => isset($responseData->Order->OrderID) ? $this->printData($responseData->Order->OrderID) : null, - 'group_id' => isset($responseData->Order->GroupID) ? $this->printData($responseData->Order->GroupID) : null, - 'trans_id' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, - 'response' => isset($responseData->Transaction->Response->Message) ? $this->printData($responseData->Transaction->Response->Message) : null, - 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'auth_code' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, - 'host_ref_num' => isset($responseData->Transaction->RetrefNum) ? $this->printData($responseData->Transaction->RetrefNum) : null, - 'ret_ref_num' => isset($responseData->Transaction->RetrefNum) ? $this->printData($responseData->Transaction->RetrefNum) : null, - 'hash_data' => isset($responseData->Transaction->HashData) ? $this->printData($responseData->Transaction->HashData) : null, - 'proc_return_code' => $this->getProcReturnCode(), - 'code' => $this->getProcReturnCode(), - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => isset($responseData->Transaction->Response->Code) ? $this->printData($responseData->Transaction->Response->Code) : null, - 'error_message' => isset($responseData->Transaction->Response->ErrorMsg) ? $this->printData($responseData->Transaction->Response->ErrorMsg) : null, - 'campaign_url' => isset($responseData->Transaction->CampaignChooseLink) ? $this->printData($responseData->Transaction->CampaignChooseLink) : null, - 'extra' => isset($responseData->Extra) ? $responseData->Extra : null, - 'all' => $responseData, + 'id' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, + 'order_id' => isset($responseData->Order->OrderID) ? $this->printData($responseData->Order->OrderID) : null, + 'group_id' => isset($responseData->Order->GroupID) ? $this->printData($responseData->Order->GroupID) : null, + 'trans_id' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, + 'response' => isset($responseData->Transaction->Response->Message) ? $this->printData($responseData->Transaction->Response->Message) : null, + 'transaction_type' => $this->type, + 'transaction' => $this->type, + 'auth_code' => isset($responseData->Transaction->AuthCode) ? $this->printData($responseData->Transaction->AuthCode) : null, + 'host_ref_num' => isset($responseData->Transaction->RetrefNum) ? $this->printData($responseData->Transaction->RetrefNum) : null, + 'ret_ref_num' => isset($responseData->Transaction->RetrefNum) ? $this->printData($responseData->Transaction->RetrefNum) : null, + 'hash_data' => isset($responseData->Transaction->HashData) ? $this->printData($responseData->Transaction->HashData) : null, + 'proc_return_code' => $this->getProcReturnCode(), + 'code' => $this->getProcReturnCode(), + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => isset($responseData->Transaction->Response->Code) ? $this->printData($responseData->Transaction->Response->Code) : null, + 'error_message' => isset($responseData->Transaction->Response->ErrorMsg) ? $this->printData($responseData->Transaction->Response->ErrorMsg) : null, + 'campaign_url' => isset($responseData->Transaction->CampaignChooseLink) ? $this->printData($responseData->Transaction->CampaignChooseLink) : null, + 'extra' => isset($responseData->Extra) ? $responseData->Extra : null, + 'all' => $responseData, ]; } @@ -792,22 +792,22 @@ protected function mapRefundResponse($rawResponseData) } return (object) [ - 'id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, - 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, - 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, - 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, - 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, - 'auth_code' => isset($rawResponseData->Transaction->AuthCode) ? $rawResponseData->Transaction->AuthCode : null, - 'host_ref_num' => isset($rawResponseData->Transaction->RetrefNum) ? $this->printData($rawResponseData->Transaction->RetrefNum) : null, - 'ret_ref_num' => isset($rawResponseData->Transaction->RetrefNum) ? $this->printData($rawResponseData->Transaction->RetrefNum) : null, - 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, - 'proc_return_code' => $this->getProcReturnCode(), - 'code' => $this->getProcReturnCode(), - 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, - 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'all' => $rawResponseData, + 'id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, + 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, + 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, + 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, + 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, + 'auth_code' => isset($rawResponseData->Transaction->AuthCode) ? $rawResponseData->Transaction->AuthCode : null, + 'host_ref_num' => isset($rawResponseData->Transaction->RetrefNum) ? $this->printData($rawResponseData->Transaction->RetrefNum) : null, + 'ret_ref_num' => isset($rawResponseData->Transaction->RetrefNum) ? $this->printData($rawResponseData->Transaction->RetrefNum) : null, + 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, + 'proc_return_code' => $this->getProcReturnCode(), + 'code' => $this->getProcReturnCode(), + 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, + 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'all' => $rawResponseData, ]; } @@ -830,23 +830,23 @@ protected function mapStatusResponse($rawResponseData) } return (object) [ - 'id' => isset($rawResponseData->Order->OrderInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderInqResult->AuthCode) : null, - 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, - 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, - 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, - 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, - 'auth_code' => isset($rawResponseData->Order->OrderInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderInqResult->AuthCode) : null, - 'host_ref_num' => isset($rawResponseData->Order->OrderInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderInqResult->RetrefNum) : null, - 'ret_ref_num' => isset($rawResponseData->Order->OrderInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderInqResult->RetrefNum) : null, - 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, - 'proc_return_code' => $this->getProcReturnCode(), - 'code' => $this->getProcReturnCode(), - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, - 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, - 'extra' => isset($rawResponseData->Extra) ? $rawResponseData->Extra : null, - 'all' => $rawResponseData, + 'id' => isset($rawResponseData->Order->OrderInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderInqResult->AuthCode) : null, + 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, + 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, + 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, + 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, + 'auth_code' => isset($rawResponseData->Order->OrderInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderInqResult->AuthCode) : null, + 'host_ref_num' => isset($rawResponseData->Order->OrderInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderInqResult->RetrefNum) : null, + 'ret_ref_num' => isset($rawResponseData->Order->OrderInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderInqResult->RetrefNum) : null, + 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, + 'proc_return_code' => $this->getProcReturnCode(), + 'code' => $this->getProcReturnCode(), + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, + 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, + 'extra' => isset($rawResponseData->Extra) ? $rawResponseData->Extra : null, + 'all' => $rawResponseData, ]; } @@ -861,24 +861,24 @@ protected function mapHistoryResponse($rawResponseData) } return (object) [ - 'id' => isset($rawResponseData->Order->OrderHistInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderHistInqResult->AuthCode) : null, - 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, - 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, - 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, - 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, - 'auth_code' => isset($rawResponseData->Order->OrderHistInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderHistInqResult->AuthCode) : null, - 'host_ref_num' => isset($rawResponseData->Order->OrderHistInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderHistInqResult->RetrefNum) : null, - 'ret_ref_num' => isset($rawResponseData->Order->OrderHistInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderHistInqResult->RetrefNum) : null, - 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, - 'proc_return_code' => $this->getProcReturnCode(), - 'code' => $this->getProcReturnCode(), - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, - 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, - 'extra' => isset($rawResponseData->Extra) ? $rawResponseData->Extra : null, - 'order_txn' => isset($rawResponseData->Order->OrderHistInqResult->OrderTxnList->OrderTxn) ? $rawResponseData->Order->OrderHistInqResult->OrderTxnList->OrderTxn : [], - 'all' => $rawResponseData, + 'id' => isset($rawResponseData->Order->OrderHistInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderHistInqResult->AuthCode) : null, + 'order_id' => isset($rawResponseData->Order->OrderID) ? $this->printData($rawResponseData->Order->OrderID) : null, + 'group_id' => isset($rawResponseData->Order->GroupID) ? $this->printData($rawResponseData->Order->GroupID) : null, + 'trans_id' => isset($rawResponseData->Transaction->AuthCode) ? $this->printData($rawResponseData->Transaction->AuthCode) : null, + 'response' => isset($rawResponseData->Transaction->Response->Message) ? $this->printData($rawResponseData->Transaction->Response->Message) : null, + 'auth_code' => isset($rawResponseData->Order->OrderHistInqResult->AuthCode) ? $this->printData($rawResponseData->Order->OrderHistInqResult->AuthCode) : null, + 'host_ref_num' => isset($rawResponseData->Order->OrderHistInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderHistInqResult->RetrefNum) : null, + 'ret_ref_num' => isset($rawResponseData->Order->OrderHistInqResult->RetrefNum) ? $this->printData($rawResponseData->Order->OrderHistInqResult->RetrefNum) : null, + 'hash_data' => isset($rawResponseData->Transaction->HashData) ? $this->printData($rawResponseData->Transaction->HashData) : null, + 'proc_return_code' => $this->getProcReturnCode(), + 'code' => $this->getProcReturnCode(), + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => isset($rawResponseData->Transaction->Response->Code) ? $this->printData($rawResponseData->Transaction->Response->Code) : null, + 'error_message' => isset($rawResponseData->Transaction->Response->ErrorMsg) ? $this->printData($rawResponseData->Transaction->Response->ErrorMsg) : null, + 'extra' => isset($rawResponseData->Extra) ? $rawResponseData->Extra : null, + 'order_txn' => isset($rawResponseData->Order->OrderHistInqResult->OrderTxnList->OrderTxn) ? $rawResponseData->Order->OrderHistInqResult->OrderTxnList->OrderTxn : [], + 'all' => $rawResponseData, ]; } @@ -917,11 +917,11 @@ protected function preparePaymentOrder(array $order) // Order return (object) array_merge($order, [ - 'installment' => $installment, - 'currency' => $this->mapCurrency($order['currency']), - 'amount' => self::amountFormat($order['amount']), - 'ip' => isset($order['ip']) ? $order['ip'] : '', - 'email' => isset($order['email']) ? $order['email'] : '', + 'installment' => $installment, + 'currency' => $this->mapCurrency($order['currency']), + 'amount' => self::amountFormat($order['amount']), + 'ip' => isset($order['ip']) ? $order['ip'] : '', + 'email' => isset($order['email']) ? $order['email'] : '', ]); } @@ -931,12 +931,12 @@ protected function preparePaymentOrder(array $order) protected function preparePostPaymentOrder(array $order) { return (object) [ - 'id' => $order['id'], + 'id' => $order['id'], 'ref_ret_num' => $order['ref_ret_num'], - 'currency' => $this->mapCurrency($order['currency']), + 'currency' => $this->mapCurrency($order['currency']), 'amount' => self::amountFormat($order['amount']), - 'ip' => isset($order['ip']) ? $order['ip'] : '', - 'email' => isset($order['email']) ? $order['email'] : '', + 'ip' => isset($order['ip']) ? $order['ip'] : '', + 'email' => isset($order['email']) ? $order['email'] : '', ]; } @@ -946,11 +946,11 @@ protected function preparePostPaymentOrder(array $order) protected function prepareStatusOrder(array $order) { return (object) [ - 'id' => $order['id'], - 'amount' => self::amountFormat(1), - 'currency' => $this->mapCurrency($order['currency']), - 'ip' => isset($order['ip']) ? $order['ip'] : '', - 'email' => isset($order['email']) ? $order['email'] : '', + 'id' => $order['id'], + 'amount' => self::amountFormat(1), + 'currency' => $this->mapCurrency($order['currency']), + 'ip' => isset($order['ip']) ? $order['ip'] : '', + 'email' => isset($order['email']) ? $order['email'] : '', 'installment' => '', ]; } @@ -969,12 +969,12 @@ protected function prepareHistoryOrder(array $order) protected function prepareCancelOrder(array $order) { return (object) [ - 'id' => $order['id'], - 'amount' => self::amountFormat(1), - 'currency' => $this->mapCurrency($order['currency']), + 'id' => $order['id'], + 'amount' => self::amountFormat(1), + 'currency' => $this->mapCurrency($order['currency']), 'ref_ret_num' => $order['ref_ret_num'], - 'ip' => isset($order['ip']) ? $order['ip'] : '', - 'email' => isset($order['email']) ? $order['email'] : '', + 'ip' => isset($order['ip']) ? $order['ip'] : '', + 'email' => isset($order['email']) ? $order['email'] : '', 'installment' => '', ]; } diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index f2abfbde..4f01ac35 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -43,8 +43,8 @@ class PayForPos extends AbstractGateway * @var array */ protected $codes = [ - '00' => 'approved', - '96' => 'general_error', + '00' => 'approved', + '96' => 'general_error', 'V004' => 'invalid_credentials', 'V001' => 'invalid_credentials', 'V111' => 'general_error', @@ -70,13 +70,13 @@ class PayForPos extends AbstractGateway * @var array */ protected $types = [ - self::TX_PAY => 'Auth', - self::TX_PRE_PAY => 'PreAuth', + self::TX_PAY => 'Auth', + self::TX_PRE_PAY => 'PreAuth', self::TX_POST_PAY => 'PostAuth', - self::TX_CANCEL => 'Void', - self::TX_REFUND => 'Refund', - self::TX_HISTORY => 'TxnHistory', - self::TX_STATUS => 'OrderInquiry', + self::TX_CANCEL => 'Void', + self::TX_REFUND => 'Refund', + self::TX_HISTORY => 'TxnHistory', + self::TX_STATUS => 'OrderInquiry', ]; /** @@ -85,12 +85,12 @@ class PayForPos extends AbstractGateway * @var array */ protected $currencies = [ - 'TRY' => 949, - 'USD' => 840, - 'EUR' => 978, - 'GBP' => 826, - 'JPY' => 392, - 'RUB' => 643, + 'TRY' => 949, + 'USD' => 840, + 'EUR' => 978, + 'GBP' => 826, + 'JPY' => 392, + 'RUB' => 643, ]; /** @@ -227,7 +227,6 @@ public function get3DFormData() } - /** * @inheritDoc */ @@ -276,11 +275,11 @@ public function createXML(array $data, $encoding = 'UTF-8'): string */ public function create3DHash() { - $hashStr = self::MBR_ID . $this->order->id - . $this->order->amount . $this->order->success_url - . $this->order->fail_url . $this->type - . $this->order->installment . $this->order->rand - . $this->account->getStoreKey(); + $hashStr = self::MBR_ID.$this->order->id + .$this->order->amount.$this->order->success_url + .$this->order->fail_url.$this->type + .$this->order->installment.$this->order->rand + .$this->account->getStoreKey(); return base64_encode(sha1($hashStr, true)); } @@ -295,10 +294,10 @@ public function create3DHash() public function check3DHash($data) { - $hashStr = $this->account->getClientId() . $this->account->getStoreKey() - . $data['OrderId'] . $data['AuthCode'] - . $data['ProcReturnCode'] . $data['3DStatus'] - . $data['ResponseRnd'] . $this->account->getUsername(); + $hashStr = $this->account->getClientId().$this->account->getStoreKey() + .$data['OrderId'].$data['AuthCode'] + .$data['ProcReturnCode'].$data['3DStatus'] + .$data['ResponseRnd'].$this->account->getUsername(); $hash = base64_encode(sha1($hashStr, true)); @@ -311,22 +310,22 @@ public function check3DHash($data) public function createRegularPaymentXML() { $requestData = [ - 'MbrId' => self::MBR_ID, - 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), - 'MOTO' => self::MOTO, - 'OrderId' => $this->order->id, - 'SecureType' => 'NonSecure', - 'TxnType' => $this->type, - 'PurchAmount' => $this->order->amount, - 'Currency' => $this->order->currency, + 'MbrId' => self::MBR_ID, + 'MerchantId' => $this->account->getClientId(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), + 'MOTO' => self::MOTO, + 'OrderId' => $this->order->id, + 'SecureType' => 'NonSecure', + 'TxnType' => $this->type, + 'PurchAmount' => $this->order->amount, + 'Currency' => $this->order->currency, 'InstallmentCount' => $this->order->installment, - 'Lang' => $this->getLang(), - 'CardHolderName' => $this->card->getHolderName(), - 'Pan' => $this->card->getNumber(), - 'Expiry' => $this->card->getExpirationDate(), - 'Cvv2' => $this->card->getCvv(), + 'Lang' => $this->getLang(), + 'CardHolderName' => $this->card->getHolderName(), + 'Pan' => $this->card->getNumber(), + 'Expiry' => $this->card->getExpirationDate(), + 'Cvv2' => $this->card->getCvv(), ]; return $this->createXML($requestData); @@ -338,16 +337,16 @@ public function createRegularPaymentXML() public function createRegularPostXML() { $requestData = [ - 'MbrId' => self::MBR_ID, - 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), - 'OrgOrderId' => $this->order->id, - 'SecureType' => 'NonSecure', - 'TxnType' => $this->type, + 'MbrId' => self::MBR_ID, + 'MerchantId' => $this->account->getClientId(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), + 'OrgOrderId' => $this->order->id, + 'SecureType' => 'NonSecure', + 'TxnType' => $this->type, 'PurchAmount' => $this->order->amount, - 'Currency' => $this->order->currency, - 'Lang' => $this->getLang(), + 'Currency' => $this->order->currency, + 'Lang' => $this->getLang(), ]; return $this->createXML($requestData); @@ -360,10 +359,10 @@ public function create3DPaymentXML($responseData) { $requestData = [ 'RequestGuid' => $responseData['RequestGuid'], - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), - 'OrderId' => $this->order->id, - 'SecureType' => '3DModelPayment', + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), + 'OrderId' => $this->order->id, + 'SecureType' => '3DModelPayment', ]; return $this->createXML($requestData); @@ -375,14 +374,14 @@ public function create3DPaymentXML($responseData) public function createStatusXML() { $requestData = [ - 'MbrId' => self::MBR_ID, + 'MbrId' => self::MBR_ID, 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), 'OrgOrderId' => $this->order->id, 'SecureType' => 'Inquiry', - 'Lang' => $this->getLang(), - 'TxnType' => $this->types[self::TX_STATUS], + 'Lang' => $this->getLang(), + 'TxnType' => $this->types[self::TX_STATUS], ]; return $this->createXML($requestData); @@ -394,13 +393,13 @@ public function createStatusXML() public function createHistoryXML($customQueryData) { $requestData = [ - 'MbrId' => self::MBR_ID, + 'MbrId' => self::MBR_ID, 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), 'SecureType' => 'Report', - 'TxnType' => $this->types[self::TX_HISTORY], - 'Lang' => $this->getLang(), + 'TxnType' => $this->types[self::TX_HISTORY], + 'Lang' => $this->getLang(), ]; if (isset($customQueryData['orderId'])) { @@ -420,16 +419,16 @@ public function createHistoryXML($customQueryData) public function createRefundXML() { $requestData = [ - 'MbrId' => self::MBR_ID, - 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), - 'SecureType' => 'NonSecure', - 'Lang' => $this->getLang(), - 'OrgOrderId' => $this->order->id, - 'TxnType' => $this->types[self::TX_REFUND], + 'MbrId' => self::MBR_ID, + 'MerchantId' => $this->account->getClientId(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), + 'SecureType' => 'NonSecure', + 'Lang' => $this->getLang(), + 'OrgOrderId' => $this->order->id, + 'TxnType' => $this->types[self::TX_REFUND], 'PurchAmount' => $this->order->amount, - 'Currency' => $this->order->currency, + 'Currency' => $this->order->currency, ]; return $this->createXML($requestData); @@ -441,15 +440,15 @@ public function createRefundXML() public function createCancelXML() { $requestData = [ - 'MbrId' => self::MBR_ID, + 'MbrId' => self::MBR_ID, 'MerchantId' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'UserPass' => $this->account->getPassword(), + 'UserCode' => $this->account->getUsername(), + 'UserPass' => $this->account->getPassword(), 'OrgOrderId' => $this->order->id, 'SecureType' => 'NonSecure', - 'TxnType' => $this->types[self::TX_CANCEL], - 'Currency' => $this->order->currency, - 'Lang' => $this->getLang(), + 'TxnType' => $this->types[self::TX_CANCEL], + 'Currency' => $this->order->currency, + 'Lang' => $this->getLang(), ]; return $this->createXML($requestData); @@ -468,17 +467,17 @@ protected function map3DPaymentData($raw3DAuthResponseData, $rawPaymentResponseD } $threeDResponse = [ - 'id' => $raw3DAuthResponseData['AuthCode'], - 'trans_id' => $raw3DAuthResponseData['OrderId'], - 'auth_code' => $raw3DAuthResponseData['AuthCode'], - 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], - 'order_id' => $raw3DAuthResponseData['OrderId'], + 'id' => $raw3DAuthResponseData['AuthCode'], + 'trans_id' => $raw3DAuthResponseData['OrderId'], + 'auth_code' => $raw3DAuthResponseData['AuthCode'], + 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], + 'order_id' => $raw3DAuthResponseData['OrderId'], 'proc_return_code' => $raw3DAuthResponseData['ProcReturnCode'], - 'code' => $raw3DAuthResponseData['ProcReturnCode'], - 'status' => 'declined', - 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, - 'error_code' => $raw3DAuthResponseData['ProcReturnCode'], - 'error_message' => $raw3DAuthResponseData['ErrMsg'], + 'code' => $raw3DAuthResponseData['ProcReturnCode'], + 'status' => 'declined', + 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, + 'error_code' => $raw3DAuthResponseData['ProcReturnCode'], + 'error_message' => $raw3DAuthResponseData['ErrMsg'], ]; if (empty($paymentResponseData)) { @@ -496,19 +495,19 @@ protected function map3DPayResponseData($raw3DAuthResponseData) $status = '00' === $raw3DAuthResponseData['ProcReturnCode'] ? 'approved' : 'declined'; $threeDResponse = [ - 'id' => $raw3DAuthResponseData['AuthCode'], - 'trans_id' => $raw3DAuthResponseData['OrderId'], - 'auth_code' => $raw3DAuthResponseData['AuthCode'], - 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], - 'order_id' => $raw3DAuthResponseData['OrderId'], + 'id' => $raw3DAuthResponseData['AuthCode'], + 'trans_id' => $raw3DAuthResponseData['OrderId'], + 'auth_code' => $raw3DAuthResponseData['AuthCode'], + 'host_ref_num' => $raw3DAuthResponseData['HostRefNum'], + 'order_id' => $raw3DAuthResponseData['OrderId'], 'proc_return_code' => $raw3DAuthResponseData['ProcReturnCode'], - 'code' => $raw3DAuthResponseData['ProcReturnCode'], - 'status' => $status, - 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, - 'error_code' => ('approved' !== $status) ? $raw3DAuthResponseData['ProcReturnCode'] : null, - 'error_message' => ('approved' !== $status) ? $raw3DAuthResponseData['ErrMsg'] : null, + 'code' => $raw3DAuthResponseData['ProcReturnCode'], + 'status' => $status, + 'status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, + 'error_code' => ('approved' !== $status) ? $raw3DAuthResponseData['ProcReturnCode'] : null, + 'error_message' => ('approved' !== $status) ? $raw3DAuthResponseData['ErrMsg'] : null, 'transaction_type' => array_search($raw3DAuthResponseData['TxnType'], $this->types, true), - 'transaction' => $this->type, + 'transaction' => $this->type, ]; return (object) array_merge($threeDResponse, $this->map3DCommonResponseData($raw3DAuthResponseData)); @@ -516,6 +515,7 @@ protected function map3DPayResponseData($raw3DAuthResponseData) /** * returns mapped data of the common response data among all 3d models. + * * @param $raw3DAuthResponseData * * @return array @@ -526,20 +526,20 @@ protected function map3DCommonResponseData($raw3DAuthResponseData) return [ 'transaction_security' => $raw3DAuthResponseData['SecureType'], - 'hash' => $raw3DAuthResponseData['ResponseHash'], - 'rand' => $raw3DAuthResponseData['ResponseRnd'], - 'masked_number' => $raw3DAuthResponseData['CardMask'], - 'amount' => $raw3DAuthResponseData['PurchAmount'], - 'currency' => array_search($raw3DAuthResponseData['Currency'], $this->currencies), - 'tx_status' => $raw3DAuthResponseData['TxnResult'], - 'xid' => $raw3DAuthResponseData['PayerTxnId'], - 'md_code' => $raw3DAuthResponseData['ProcReturnCode'], - 'md_status' => $raw3DAuthResponseData['3DStatus'], - 'md_error_code' => ('declined' === $threeDAuthStatus) ? $raw3DAuthResponseData['ProcReturnCode'] : null, - 'md_error_message' => ('declined' === $threeDAuthStatus) ? $raw3DAuthResponseData['ErrMsg'] : null, - 'md_status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, - 'eci' => $raw3DAuthResponseData['Eci'], - '3d_all' => $raw3DAuthResponseData, + 'hash' => $raw3DAuthResponseData['ResponseHash'], + 'rand' => $raw3DAuthResponseData['ResponseRnd'], + 'masked_number' => $raw3DAuthResponseData['CardMask'], + 'amount' => $raw3DAuthResponseData['PurchAmount'], + 'currency' => array_search($raw3DAuthResponseData['Currency'], $this->currencies), + 'tx_status' => $raw3DAuthResponseData['TxnResult'], + 'xid' => $raw3DAuthResponseData['PayerTxnId'], + 'md_code' => $raw3DAuthResponseData['ProcReturnCode'], + 'md_status' => $raw3DAuthResponseData['3DStatus'], + 'md_error_code' => ('declined' === $threeDAuthStatus) ? $raw3DAuthResponseData['ProcReturnCode'] : null, + 'md_error_message' => ('declined' === $threeDAuthStatus) ? $raw3DAuthResponseData['ErrMsg'] : null, + 'md_status_detail' => isset($this->codes[$raw3DAuthResponseData['ProcReturnCode']]) ? $this->codes[$raw3DAuthResponseData['ProcReturnCode']] : null, + 'eci' => $raw3DAuthResponseData['Eci'], + '3d_all' => $raw3DAuthResponseData, ]; } @@ -563,16 +563,16 @@ protected function mapCancelResponse($rawResponseData) } return (object) [ - 'order_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, - 'auth_code' => ('declined' !== $status) ? $rawResponseData->AuthCode : null, - 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, + 'order_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, + 'auth_code' => ('declined' !== $status) ? $rawResponseData->AuthCode : null, + 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $rawResponseData->ProcReturnCode : null, - 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, - 'error_code' => ('declined' === $status) ? $rawResponseData->ProcReturnCode : null, - 'error_message' => ('declined' === $status) ? $rawResponseData->ErrMsg : null, - 'status' => $status, - 'status_detail' => isset($this->codes[$rawResponseData->ProcReturnCode]) ? $this->codes[$rawResponseData->ProcReturnCode] : null, - 'all' => $rawResponseData, + 'trans_id' => isset($rawResponseData->TransId) ? $rawResponseData->TransId : null, + 'error_code' => ('declined' === $status) ? $rawResponseData->ProcReturnCode : null, + 'error_message' => ('declined' === $status) ? $rawResponseData->ErrMsg : null, + 'status' => $status, + 'status_detail' => isset($this->codes[$rawResponseData->ProcReturnCode]) ? $this->codes[$rawResponseData->ProcReturnCode] : null, + 'all' => $rawResponseData, ]; } @@ -587,20 +587,20 @@ protected function mapPaymentResponse($responseData) } return [ - 'id' => $responseData->AuthCode, - 'order_id' => $responseData->TransId, - 'trans_id' => $responseData->TransId, + 'id' => $responseData->AuthCode, + 'order_id' => $responseData->TransId, + 'trans_id' => $responseData->TransId, 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'auth_code' => $responseData->AuthCode, - 'host_ref_num' => $responseData->HostRefNum, + 'transaction' => $this->type, + 'auth_code' => $responseData->AuthCode, + 'host_ref_num' => $responseData->HostRefNum, 'proc_return_code' => $responseData->ProcReturnCode, - 'code' => $responseData->ProcReturnCode, - 'status' => $status, - 'status_detail' => isset($this->codes[$responseData->ProcReturnCode]) ? $this->codes[$responseData->ProcReturnCode] : null, - 'error_code' => ('declined' === $status) ? $responseData->ProcReturnCode : null, - 'error_message' => ('declined' === $status) ? $responseData->ErrMsg : null, - 'all' => $responseData, + 'code' => $responseData->ProcReturnCode, + 'status' => $status, + 'status_detail' => isset($this->codes[$responseData->ProcReturnCode]) ? $this->codes[$responseData->ProcReturnCode] : null, + 'error_code' => ('declined' === $status) ? $responseData->ProcReturnCode : null, + 'error_message' => ('declined' === $status) ? $responseData->ErrMsg : null, + 'all' => $responseData, ]; } @@ -624,20 +624,20 @@ protected function mapStatusResponse($rawResponseData) } return (object) [ - 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, - 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, - 'org_order_id' => isset($rawResponseData->OrgOrderId) ? $rawResponseData->OrgOrderId : null, + 'auth_code' => isset($rawResponseData->AuthCode) ? $rawResponseData->AuthCode : null, + 'order_id' => isset($rawResponseData->OrderId) ? $rawResponseData->OrderId : null, + 'org_order_id' => isset($rawResponseData->OrgOrderId) ? $rawResponseData->OrgOrderId : null, 'proc_return_code' => isset($rawResponseData->ProcReturnCode) ? $rawResponseData->ProcReturnCode : null, - 'error_message' => ('declined' === $status) ? $rawResponseData->ErrMsg : null, - 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, - 'order_status' => $orderStatus, - 'process_type' => isset($rawResponseData->TxnType) ? array_search($rawResponseData->TxnType, $this->types, true) : null, - 'masked_number' => isset($rawResponseData->CardMask) ? $rawResponseData->CardMask : null, - 'amount' => isset($rawResponseData->PurchAmount) ? $rawResponseData->PurchAmount : null, - 'currency' => isset($rawResponseData->Currency) ? array_search($rawResponseData->Currency, $this->currencies) : null, - 'status' => $status, - 'status_detail' => isset($this->codes[$rawResponseData->ProcReturnCode]) ? $this->codes[$rawResponseData->ProcReturnCode] : null, - 'all' => $rawResponseData, + 'error_message' => ('declined' === $status) ? $rawResponseData->ErrMsg : null, + 'host_ref_num' => isset($rawResponseData->HostRefNum) ? $rawResponseData->HostRefNum : null, + 'order_status' => $orderStatus, + 'process_type' => isset($rawResponseData->TxnType) ? array_search($rawResponseData->TxnType, $this->types, true) : null, + 'masked_number' => isset($rawResponseData->CardMask) ? $rawResponseData->CardMask : null, + 'amount' => isset($rawResponseData->PurchAmount) ? $rawResponseData->PurchAmount : null, + 'currency' => isset($rawResponseData->Currency) ? array_search($rawResponseData->Currency, $this->currencies) : null, + 'status' => $status, + 'status_detail' => isset($this->codes[$rawResponseData->ProcReturnCode]) ? $this->codes[$rawResponseData->ProcReturnCode] : null, + 'all' => $rawResponseData, ]; } @@ -649,20 +649,20 @@ protected function mapStatusResponse($rawResponseData) protected function getDefaultPaymentResponse() { return [ - 'id' => null, - 'order_id' => null, - 'trans_id' => null, + 'id' => null, + 'order_id' => null, + 'trans_id' => null, 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'auth_code' => null, - 'host_ref_num' => null, + 'transaction' => $this->type, + 'auth_code' => null, + 'host_ref_num' => null, 'proc_return_code' => null, - 'code' => null, - 'status' => 'declined', - 'status_detail' => null, - 'error_code' => null, - 'error_message' => null, - 'all' => null, + 'code' => null, + 'status' => 'declined', + 'status_detail' => null, + 'error_code' => null, + 'error_message' => null, + 'all' => null, ]; } @@ -674,20 +674,20 @@ protected function getDefaultPaymentResponse() protected function getCommon3DFormData() { $inputs = [ - 'MbrId' => self::MBR_ID, - 'MerchantID' => $this->account->getClientId(), - 'UserCode' => $this->account->getUsername(), - 'OrderId' => $this->order->id, - 'Lang' => $this->getLang(), - 'SecureType' => null, //to be filled by the caller - 'TxnType' => $this->type, - 'PurchAmount' => $this->order->amount, + 'MbrId' => self::MBR_ID, + 'MerchantID' => $this->account->getClientId(), + 'UserCode' => $this->account->getUsername(), + 'OrderId' => $this->order->id, + 'Lang' => $this->getLang(), + 'SecureType' => null, //to be filled by the caller + 'TxnType' => $this->type, + 'PurchAmount' => $this->order->amount, 'InstallmentCount' => $this->order->installment, - 'Currency' => $this->order->currency, - 'OkUrl' => $this->order->success_url, - 'FailUrl' => $this->order->fail_url, - 'Rnd' => $this->order->rand, - 'Hash' => $this->order->hash, + 'Currency' => $this->order->currency, + 'OkUrl' => $this->order->success_url, + 'FailUrl' => $this->order->fail_url, + 'Rnd' => $this->order->rand, + 'Hash' => $this->order->hash, ]; if ($this->card) { @@ -699,7 +699,7 @@ protected function getCommon3DFormData() return [ 'gateway' => null, //to be filled by the caller - 'inputs' => $inputs, + 'inputs' => $inputs, ]; } @@ -726,8 +726,8 @@ protected function preparePaymentOrder(array $order) // Order return (object) array_merge($order, [ - 'installment' => $installment, - 'currency' => $this->mapCurrency($currency), + 'installment' => $installment, + 'currency' => $this->mapCurrency($currency), ]); } @@ -737,8 +737,8 @@ protected function preparePaymentOrder(array $order) protected function preparePostPaymentOrder(array $order) { return (object) [ - 'id' => $order['id'], - 'amount' => $order['amount'], + 'id' => $order['id'], + 'amount' => $order['amount'], 'currency' => $this->mapCurrency($order['currency']), ]; } @@ -759,7 +759,7 @@ protected function prepareHistoryOrder(array $order) return (object) [ //reqDate or order id 'reqDate' => isset($order['reqDate']) ? $order['reqDate'] : null, - 'id' => isset($order['id']) ? $order['id'] : null, + 'id' => isset($order['id']) ? $order['id'] : null, ]; } diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index cf2fa3fe..210a21ce 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -40,28 +40,28 @@ class PosNet extends AbstractGateway * @var array */ protected $codes = [ - '0' => 'declined', - '1' => 'approved', - '2' => 'declined', - '00' => 'approved', - '0001' => 'bank_call', - '0005' => 'reject', - '0007' => 'bank_call', - '0012' => 'reject', - '0014' => 'reject', - '0030' => 'bank_call', - '0041' => 'reject', - '0043' => 'reject', - '0051' => 'reject', - '0053' => 'bank_call', - '0054' => 'reject', - '0057' => 'reject', - '0058' => 'reject', - '0062' => 'reject', - '0065' => 'reject', - '0091' => 'bank_call', - '0123' => 'transaction_not_found', - '0444' => 'bank_call', + '0' => 'declined', + '1' => 'approved', + '2' => 'declined', + '00' => 'approved', + '0001' => 'bank_call', + '0005' => 'reject', + '0007' => 'bank_call', + '0012' => 'reject', + '0014' => 'reject', + '0030' => 'bank_call', + '0041' => 'reject', + '0043' => 'reject', + '0051' => 'reject', + '0053' => 'bank_call', + '0054' => 'reject', + '0057' => 'reject', + '0058' => 'reject', + '0062' => 'reject', + '0065' => 'reject', + '0091' => 'bank_call', + '0123' => 'transaction_not_found', + '0444' => 'bank_call', ]; /** @@ -70,12 +70,12 @@ class PosNet extends AbstractGateway * @var array */ protected $types = [ - self::TX_PAY => 'Sale', - self::TX_PRE_PAY => 'Auth', + self::TX_PAY => 'Sale', + self::TX_PRE_PAY => 'Auth', self::TX_POST_PAY => 'Capt', - self::TX_CANCEL => 'reverse', - self::TX_REFUND => 'return', - self::TX_STATUS => 'agreement', + self::TX_CANCEL => 'reverse', + self::TX_REFUND => 'return', + self::TX_STATUS => 'agreement', ]; /** @@ -83,12 +83,12 @@ class PosNet extends AbstractGateway * @var array */ protected $currencies = [ - 'TRY' => 'TL', - 'USD' => 'US', - 'EUR' => 'EU', - 'GBP' => 'GB', - 'JPY' => 'JP', - 'RUB' => 'RU', + 'TRY' => 'TL', + 'USD' => 'US', + 'EUR' => 'EU', + 'GBP' => 'GB', + 'JPY' => 'JP', + 'RUB' => 'RU', ]; /** @@ -118,9 +118,9 @@ class PosNet extends AbstractGateway /** * PosNet constructor. * - * @param array $config + * @param array $config * @param PosNetAccount $account - * @param array $currencies + * @param array $currencies */ public function __construct($config, $account, array $currencies) { @@ -158,19 +158,19 @@ public function getOosTransactionData() } $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), 'oosRequestData' => [ - 'posnetid' => $this->account->getPosNetId(), - 'ccno' => $this->card->getNumber(), - 'expDate' => $this->card->getExpirationDate(), - 'cvc' => $this->card->getCvv(), - 'amount' => $this->order->amount, - 'currencyCode' => $this->order->currency, - 'installment' => $this->order->installment, - 'XID' => self::formatOrderId($this->order->id), - 'cardHolderName' => $this->card->getHolderName(), - 'tranType' => $this->type, + 'posnetid' => $this->account->getPosNetId(), + 'ccno' => $this->card->getNumber(), + 'expDate' => $this->card->getExpirationDate(), + 'cvc' => $this->card->getCvv(), + 'amount' => $this->order->amount, + 'currencyCode' => $this->order->currency, + 'installment' => $this->order->installment, + 'XID' => self::formatOrderId($this->order->id), + 'cardHolderName' => $this->card->getHolderName(), + 'tranType' => $this->type, ], ]; $xml = $this->createXML($requestData); @@ -238,20 +238,20 @@ public function get3DFormData() $data = $this->getOosTransactionData(); $inputs = [ - 'posnetData' => $data->oosRequestDataResponse->data1, - 'posnetData2' => $data->oosRequestDataResponse->data2, - 'mid' => $this->account->getClientId(), - 'posnetID' => $this->account->getPosNetId(), - 'digest' => $data->oosRequestDataResponse->sign, - 'vftCode' => isset($this->account->promotion_code) ? $this->account->promotion_code : null, - 'merchantReturnURL' => $this->order->success_url, - 'url' => '', - 'lang' => $this->getLang(), + 'posnetData' => $data->oosRequestDataResponse->data1, + 'posnetData2' => $data->oosRequestDataResponse->data2, + 'mid' => $this->account->getClientId(), + 'posnetID' => $this->account->getPosNetId(), + 'digest' => $data->oosRequestDataResponse->sign, + 'vftCode' => isset($this->account->promotion_code) ? $this->account->promotion_code : null, + 'merchantReturnURL' => $this->order->success_url, + 'url' => '', + 'lang' => $this->getLang(), ]; return [ - 'gateway' => $this->get3DGatewayURL(), - 'inputs' => $inputs, + 'gateway' => $this->get3DGatewayURL(), + 'inputs' => $inputs, ]; } @@ -267,8 +267,8 @@ public function send($contents) ]; $response = $client->request('POST', $this->getApiURL(), [ - 'headers' => $headers, - 'body' => "xmldata=$contents", + 'headers' => $headers, + 'body' => "xmldata=$contents", ]); $this->data = $this->XMLStringToObject($response->getBody()->getContents()); @@ -302,6 +302,7 @@ public function setCard($card) /** * Hash string + * * @param string $str * * @return string @@ -352,7 +353,7 @@ public function verifyResponseMAC($data) /** * formats order id by adding 0 pad to the left * - * @param $orderId + * @param $orderId * @param int $padLength * * @return string @@ -369,6 +370,7 @@ public static function formatOrderId($orderId, int $padLength = null) /** * Get amount * formats 10.01 to 1001 + * * @param float $amount * * @return int @@ -404,6 +406,7 @@ public static function mapOrderIdToPrefixedOrderId(string $orderId, string $acco /** * formats installment in 00, 02, 06 format + * * @param int|string $installment * * @return string @@ -423,17 +426,17 @@ public static function formatInstallment($installment) public function createRegularPaymentXML() { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), - 'tranDateRequired' => '1', - strtolower($this->type) => [ - 'orderID' => self::formatOrderId($this->order->id), - 'installment' => $this->order->installment, - 'amount' => $this->order->amount, - 'currencyCode' => $this->order->currency, - 'ccno' => $this->card->getNumber(), - 'expDate' => $this->card->getExpirationDate(), - 'cvc' => $this->card->getCvv(), + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), + 'tranDateRequired' => '1', + strtolower($this->type) => [ + 'orderID' => self::formatOrderId($this->order->id), + 'installment' => $this->order->installment, + 'amount' => $this->order->amount, + 'currencyCode' => $this->order->currency, + 'ccno' => $this->card->getNumber(), + 'expDate' => $this->card->getExpirationDate(), + 'cvc' => $this->card->getCvv(), ], ]; @@ -446,14 +449,14 @@ public function createRegularPaymentXML() public function createRegularPostXML() { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), - 'tranDateRequired' => '1', - strtolower($this->types[self::TX_POST_PAY]) => [ - 'hostLogKey' => $this->order->host_ref_num, - 'amount' => $this->order->amount, - 'currencyCode' => $this->order->currency, - 'installment' => $this->order->installment, + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), + 'tranDateRequired' => '1', + strtolower($this->types[self::TX_POST_PAY]) => [ + 'hostLogKey' => $this->order->host_ref_num, + 'amount' => $this->order->amount, + 'currencyCode' => $this->order->currency, + 'installment' => $this->order->installment, ], ]; @@ -466,14 +469,14 @@ public function createRegularPostXML() public function create3DPaymentXML($responseData) { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), 'oosTranData' => [ - 'bankData' => $responseData['BankPacket'], - 'merchantData' => $responseData['MerchantPacket'], - 'sign' => $responseData['Sign'], - 'wpAmount' => 0, - 'mac' => $this->create3DHash(), + 'bankData' => $responseData['BankPacket'], + 'merchantData' => $responseData['MerchantPacket'], + 'sign' => $responseData['Sign'], + 'wpAmount' => 0, + 'mac' => $this->create3DHash(), ], ]; @@ -488,13 +491,13 @@ public function create3DPaymentXML($responseData) public function create3DResolveMerchantDataXML($responseData) { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), - 'oosResolveMerchantData' => [ - 'bankData' => $responseData['BankPacket'], - 'merchantData' => $responseData['MerchantPacket'], - 'sign' => $responseData['Sign'], - 'mac' => $this->create3DHash(), + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), + 'oosResolveMerchantData' => [ + 'bankData' => $responseData['BankPacket'], + 'merchantData' => $responseData['MerchantPacket'], + 'sign' => $responseData['Sign'], + 'mac' => $this->create3DHash(), ], ]; @@ -517,10 +520,10 @@ public function createHistoryXML($customQueryData) public function createStatusXML() { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), $this->types[self::TX_STATUS] => [ - 'orderID' => $this->order->id, + 'orderID' => $this->order->id, ], ]; @@ -533,11 +536,11 @@ public function createStatusXML() public function createCancelXML() { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), - 'tranDateRequired' => '1', + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), + 'tranDateRequired' => '1', $this->types[self::TX_CANCEL] => [ - 'transaction' => 'sale', + 'transaction' => 'sale', ], ]; @@ -561,12 +564,12 @@ public function createCancelXML() public function createRefundXML() { $requestData = [ - 'mid' => $this->account->getClientId(), - 'tid' => $this->account->getTerminalId(), - 'tranDateRequired' => '1', + 'mid' => $this->account->getClientId(), + 'tid' => $this->account->getTerminalId(), + 'tranDateRequired' => '1', $this->types[self::TX_REFUND] => [ - 'amount' => $this->order->amount, - 'currencyCode' => $this->order->currency, + 'amount' => $this->order->amount, + 'currencyCode' => $this->order->currency, ], ]; @@ -660,34 +663,34 @@ protected function map3DPaymentData($raw3DAuthResponseData, $rawPaymentResponseD } return (object) [ - 'id' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, - 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, - 'group_id' => isset($rawPaymentResponseData->groupID) ? $this->printData($rawPaymentResponseData->groupID) : null, - 'trans_id' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, - 'response' => $this->getStatusDetail(), - 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'transaction_security' => $transactionSecurity, - 'auth_code' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, - 'host_ref_num' => isset($rawPaymentResponseData->hostlogkey) ? $this->printData($rawPaymentResponseData->hostlogkey) : null, - 'ret_ref_num' => isset($rawPaymentResponseData->transaction->hostlogkey) ? $this->printData($rawPaymentResponseData->transaction->hostlogkey) : null, - 'proc_return_code' => $this->getProcReturnCode(), - 'code' => $this->getProcReturnCode(), - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => !empty($rawPaymentResponseData->respCode) ? $this->printData($rawPaymentResponseData->respCode) : null, - 'error_message' => !empty($rawPaymentResponseData->respText) ? $this->printData($rawPaymentResponseData->respText) : null, - 'md_status' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->mdStatus) ? $this->printData($rawPaymentResponseData->oosResolveMerchantDataResponse->mdStatus) : null, - 'hash' => [ - 'merchant_packet' => $raw3DAuthResponseData['MerchantPacket'], - 'bank_packet' => $raw3DAuthResponseData['BankPacket'], - 'sign' => $raw3DAuthResponseData['Sign'], + 'id' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, + 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, + 'group_id' => isset($rawPaymentResponseData->groupID) ? $this->printData($rawPaymentResponseData->groupID) : null, + 'trans_id' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, + 'response' => $this->getStatusDetail(), + 'transaction_type' => $this->type, + 'transaction' => $this->type, + 'transaction_security' => $transactionSecurity, + 'auth_code' => isset($rawPaymentResponseData->authCode) ? $this->printData($rawPaymentResponseData->authCode) : null, + 'host_ref_num' => isset($rawPaymentResponseData->hostlogkey) ? $this->printData($rawPaymentResponseData->hostlogkey) : null, + 'ret_ref_num' => isset($rawPaymentResponseData->transaction->hostlogkey) ? $this->printData($rawPaymentResponseData->transaction->hostlogkey) : null, + 'proc_return_code' => $this->getProcReturnCode(), + 'code' => $this->getProcReturnCode(), + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => !empty($rawPaymentResponseData->respCode) ? $this->printData($rawPaymentResponseData->respCode) : null, + 'error_message' => !empty($rawPaymentResponseData->respText) ? $this->printData($rawPaymentResponseData->respText) : null, + 'md_status' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->mdStatus) ? $this->printData($rawPaymentResponseData->oosResolveMerchantDataResponse->mdStatus) : null, + 'hash' => [ + 'merchant_packet' => $raw3DAuthResponseData['MerchantPacket'], + 'bank_packet' => $raw3DAuthResponseData['BankPacket'], + 'sign' => $raw3DAuthResponseData['Sign'], ], - 'xid' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->xid) ? $rawPaymentResponseData->oosResolveMerchantDataResponse->xid : null, - 'md_error_message' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->mdErrorMessage) ? $rawPaymentResponseData->oosResolveMerchantDataResponse->mdErrorMessage : null, - 'campaign_url' => null, - 'all' => $rawPaymentResponseData, - '3d_all' => $raw3DAuthResponseData, + 'xid' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->xid) ? $rawPaymentResponseData->oosResolveMerchantDataResponse->xid : null, + 'md_error_message' => isset($rawPaymentResponseData->oosResolveMerchantDataResponse->mdErrorMessage) ? $rawPaymentResponseData->oosResolveMerchantDataResponse->mdErrorMessage : null, + 'campaign_url' => null, + 'all' => $rawPaymentResponseData, + '3d_all' => $raw3DAuthResponseData, ]; } @@ -716,26 +719,26 @@ protected function mapPaymentResponse($responseData) } return (object) [ - 'id' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, - 'order_id' => $this->order->id, - 'fixed_order_id' => self::formatOrderId($this->order->id), - 'group_id' => isset($responseData->groupID) ? $this->printData($responseData->groupID) : null, - 'trans_id' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, - 'response' => $this->getStatusDetail(), - 'transaction_type' => $this->type, - 'transaction' => $this->type, - 'auth_code' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, - 'host_ref_num' => isset($responseData->hostlogkey) ? $this->printData($responseData->hostlogkey) : null, - 'ret_ref_num' => isset($responseData->hostlogkey) ? $this->printData($responseData->hostlogkey) : null, - 'proc_return_code' => $procReturnCode, - 'code' => $code, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => $errorCode, - 'error_message' => !empty($responseData->respText) ? $this->printData($responseData->respText) : null, - 'campaign_url' => null, - 'extra' => null, - 'all' => $responseData, + 'id' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, + 'order_id' => $this->order->id, + 'fixed_order_id' => self::formatOrderId($this->order->id), + 'group_id' => isset($responseData->groupID) ? $this->printData($responseData->groupID) : null, + 'trans_id' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, + 'response' => $this->getStatusDetail(), + 'transaction_type' => $this->type, + 'transaction' => $this->type, + 'auth_code' => isset($responseData->authCode) ? $this->printData($responseData->authCode) : null, + 'host_ref_num' => isset($responseData->hostlogkey) ? $this->printData($responseData->hostlogkey) : null, + 'ret_ref_num' => isset($responseData->hostlogkey) ? $this->printData($responseData->hostlogkey) : null, + 'proc_return_code' => $procReturnCode, + 'code' => $code, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => $errorCode, + 'error_message' => !empty($responseData->respText) ? $this->printData($responseData->respText) : null, + 'campaign_url' => null, + 'extra' => null, + 'all' => $responseData, ]; } @@ -758,39 +761,39 @@ protected function mapRefundResponse($rawResponseData) $transaction = null; $transactionType = null; $state = isset($rawResponseData->state) ? $rawResponseData->state : null; - if ($state === 'Sale') { + if ('Sale' === $state) { $transaction = 'pay'; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Authorization') { + } elseif ('Authorization' === $state) { $transaction = 'pre'; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Capture') { + } elseif ('Capture' === $state) { $transaction = 'post'; $transactionType = $this->types[$transaction]; } return (object) [ - 'id' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, - 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, - 'fixed_order_id' => isset($rawResponseData->transaction->orderID) ? $this->printData($rawResponseData->transaction->orderID) : null, - 'group_id' => isset($rawResponseData->transaction->groupID) ? $this->printData($rawResponseData->transaction->groupID) : null, - 'trans_id' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, - 'response' => $this->getStatusDetail(), - 'auth_code' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, - 'host_ref_num' => isset($rawResponseData->transaction->hostlogkey) ? $this->printData($rawResponseData->transaction->hostlogkey) : null, - 'ret_ref_num' => isset($rawResponseData->transaction->hostlogkey) ? $this->printData($rawResponseData->transaction->hostlogkey) : null, - 'transaction' => $transaction, - 'transaction_type' => $transactionType, - 'state' => $state, - 'date' => isset($rawResponseData->transaction->tranDate) ? $this->printData($rawResponseData->transaction->tranDate) : null, - 'proc_return_code' => $procReturnCode, - 'code' => $code, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => $errorCode, - 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, - 'extra' => null, - 'all' => $rawResponseData, + 'id' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, + 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, + 'fixed_order_id' => isset($rawResponseData->transaction->orderID) ? $this->printData($rawResponseData->transaction->orderID) : null, + 'group_id' => isset($rawResponseData->transaction->groupID) ? $this->printData($rawResponseData->transaction->groupID) : null, + 'trans_id' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, + 'response' => $this->getStatusDetail(), + 'auth_code' => isset($rawResponseData->transaction->authCode) ? $this->printData($rawResponseData->transaction->authCode) : null, + 'host_ref_num' => isset($rawResponseData->transaction->hostlogkey) ? $this->printData($rawResponseData->transaction->hostlogkey) : null, + 'ret_ref_num' => isset($rawResponseData->transaction->hostlogkey) ? $this->printData($rawResponseData->transaction->hostlogkey) : null, + 'transaction' => $transaction, + 'transaction_type' => $transactionType, + 'state' => $state, + 'date' => isset($rawResponseData->transaction->tranDate) ? $this->printData($rawResponseData->transaction->tranDate) : null, + 'proc_return_code' => $procReturnCode, + 'code' => $code, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => $errorCode, + 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, + 'extra' => null, + 'all' => $rawResponseData, ]; } @@ -836,46 +839,46 @@ protected function mapStatusResponse($rawResponseData) } } - if ($state === 'Sale') { + if ('Sale' === $state) { $transaction = 'pay'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Authorization') { + } elseif ('Authorization' === $state) { $transaction = 'pre'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Capture') { + } elseif ('Capture' === $state) { $transaction = 'post'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Bonus_Reverse') { + } elseif ('Bonus_Reverse' === $state) { $state = 'cancel'; } else { $state = 'mixed'; } return (object) [ - 'id' => $authCode, - 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, - 'fixed_order_id' => self::formatOrderId($this->order->id), - 'group_id' => isset($rawResponseData->transactions->transaction->groupID) ? $this->printData($rawResponseData->transactions->transaction->groupID) : null, - 'trans_id' => $authCode, - 'response' => $this->getStatusDetail(), - 'auth_code' => $authCode, - 'host_ref_num' => isset($rawResponseData->transactions->transaction->hostLogKey) ? $this->printData($rawResponseData->transactions->transaction->hostLogKey) : null, - 'ret_ref_num' => null, - 'transaction' => $transaction, - 'transaction_type' => $transactionType, - 'state' => $state, - 'date' => isset($rawResponseData->transactions->transaction->tranDate) ? $this->printData($rawResponseData->transactions->transaction->tranDate) : null, - 'proc_return_code' => $procReturnCode, - 'code' => $code, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => $errorCode, - 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, - 'extra' => null, - 'all' => $rawResponseData, + 'id' => $authCode, + 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, + 'fixed_order_id' => self::formatOrderId($this->order->id), + 'group_id' => isset($rawResponseData->transactions->transaction->groupID) ? $this->printData($rawResponseData->transactions->transaction->groupID) : null, + 'trans_id' => $authCode, + 'response' => $this->getStatusDetail(), + 'auth_code' => $authCode, + 'host_ref_num' => isset($rawResponseData->transactions->transaction->hostLogKey) ? $this->printData($rawResponseData->transactions->transaction->hostLogKey) : null, + 'ret_ref_num' => null, + 'transaction' => $transaction, + 'transaction_type' => $transactionType, + 'state' => $state, + 'date' => isset($rawResponseData->transactions->transaction->tranDate) ? $this->printData($rawResponseData->transactions->transaction->tranDate) : null, + 'proc_return_code' => $procReturnCode, + 'code' => $code, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => $errorCode, + 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, + 'extra' => null, + 'all' => $rawResponseData, ]; } @@ -932,46 +935,46 @@ protected function mapHistoryResponse($rawResponseData) } } - if ($state === 'Sale') { + if ('Sale' === $state) { $transaction = 'pay'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Authorization') { + } elseif ('Authorization' === $state) { $transaction = 'pre'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Capture') { + } elseif ('Capture' === $state) { $transaction = 'post'; $state = $transaction; $transactionType = $this->types[$transaction]; - } elseif ($state === 'Bonus_Reverse') { + } elseif ('Bonus_Reverse' === $state) { $state = 'cancel'; } else { $state = 'mixed'; } return (object) [ - 'id' => $authCode, - 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, - 'group_id' => isset($rawResponseData->transactions->transaction->groupID) ? $this->printData($rawResponseData->transactions->transaction->groupID) : null, - 'trans_id' => $authCode, - 'response' => $this->getStatusDetail(), - 'auth_code' => $authCode, - 'host_ref_num' => isset($rawResponseData->transactions->transaction->hostLogKey) ? $this->printData($rawResponseData->transactions->transaction->hostLogKey) : null, - 'ret_ref_num' => null, - 'transaction' => $transaction, - 'transaction_type' => $transactionType, - 'state' => $state, - 'date' => isset($rawResponseData->transactions->transaction->tranDate) ? $this->printData($rawResponseData->transactions->transaction->tranDate) : null, - 'refunds' => $refunds, - 'proc_return_code' => $procReturnCode, - 'code' => $code, - 'status' => $status, - 'status_detail' => $this->getStatusDetail(), - 'error_code' => $errorCode, - 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, - 'extra' => null, - 'all' => $rawResponseData, + 'id' => $authCode, + 'order_id' => isset($this->order->id) ? $this->printData($this->order->id) : null, + 'group_id' => isset($rawResponseData->transactions->transaction->groupID) ? $this->printData($rawResponseData->transactions->transaction->groupID) : null, + 'trans_id' => $authCode, + 'response' => $this->getStatusDetail(), + 'auth_code' => $authCode, + 'host_ref_num' => isset($rawResponseData->transactions->transaction->hostLogKey) ? $this->printData($rawResponseData->transactions->transaction->hostLogKey) : null, + 'ret_ref_num' => null, + 'transaction' => $transaction, + 'transaction_type' => $transactionType, + 'state' => $state, + 'date' => isset($rawResponseData->transactions->transaction->tranDate) ? $this->printData($rawResponseData->transactions->transaction->tranDate) : null, + 'refunds' => $refunds, + 'proc_return_code' => $procReturnCode, + 'code' => $code, + 'status' => $status, + 'status_detail' => $this->getStatusDetail(), + 'error_code' => $errorCode, + 'error_message' => !empty($rawResponseData->respText) ? $this->printData($rawResponseData->respText) : null, + 'extra' => null, + 'all' => $rawResponseData, ]; } @@ -987,10 +990,10 @@ protected function preparePaymentOrder(array $order) } return (object) array_merge($order, [ - 'id' => self::formatOrderId($order['id']), - 'installment' => self::formatInstallment($installment), - 'amount' => self::formatAmount($order['amount']), - 'currency' => $this->mapCurrency($order['currency']), + 'id' => self::formatOrderId($order['id']), + 'installment' => self::formatInstallment($installment), + 'amount' => self::formatAmount($order['amount']), + 'currency' => $this->mapCurrency($order['currency']), ]); } @@ -1006,10 +1009,10 @@ protected function preparePostPaymentOrder(array $order) } return (object) [ - 'host_ref_num' => $order['host_ref_num'], - 'amount' => self::formatAmount($order['amount']), - 'currency' => $this->mapCurrency($order['currency']), - 'installment' => self::formatInstallment($installment), + 'host_ref_num' => $order['host_ref_num'], + 'amount' => self::formatAmount($order['amount']), + 'currency' => $this->mapCurrency($order['currency']), + 'installment' => self::formatInstallment($installment), ]; } @@ -1038,10 +1041,10 @@ protected function prepareCancelOrder(array $order) { return (object) [ //id or host_ref_num - 'id' => isset($order['id']) ? self::mapOrderIdToPrefixedOrderId($order['id'], $this->account->getModel()) : null, + 'id' => isset($order['id']) ? self::mapOrderIdToPrefixedOrderId($order['id'], $this->account->getModel()) : null, 'host_ref_num' => isset($order['host_ref_num']) ? $order['host_ref_num'] : null, //optional - 'auth_code' => isset($order['auth_code']) ? $order['auth_code'] : null, + 'auth_code' => isset($order['auth_code']) ? $order['auth_code'] : null, ]; } @@ -1052,7 +1055,7 @@ protected function prepareRefundOrder(array $order) { return (object) [ //id or host_ref_num - 'id' => isset($order['id']) ? self::mapOrderIdToPrefixedOrderId($order['id'], $this->account->getModel()) : null, + 'id' => isset($order['id']) ? self::mapOrderIdToPrefixedOrderId($order['id'], $this->account->getModel()) : null, 'host_ref_num' => isset($order['host_ref_num']) ? $order['host_ref_num'] : null, 'amount' => self::formatAmount($order['amount']), 'currency' => self::mapCurrency($order['currency']), diff --git a/src/PosInterface.php b/src/PosInterface.php index b741b0d6..b8dfdb03 100644 --- a/src/PosInterface.php +++ b/src/PosInterface.php @@ -6,7 +6,6 @@ use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Exceptions\UnsupportedPaymentModelException; -use Mews\Pos\Exceptions\UnsupportedTransactionTypeException; use Mews\Pos\Gateways\AbstractGateway; /** @@ -17,9 +16,9 @@ interface PosInterface /** * PosInterface constructor. * - * @param object $config + * @param object $config * @param AbstractPosAccount $account - * @param array $currencies + * @param array $currencies */ public function __construct($config, $account, array $currencies); @@ -88,9 +87,9 @@ public function send($contents); /** * Prepare Order * - * @param array $order - * @param string $txType //txTypes from AbstractGateway - * @param AbstractCreditCard|null $card need when 3DFormData requested + * @param array $order + * @param string $txType //txTypes from AbstractGateway + * @param AbstractCreditCard|null $card need when 3DFormData requested * * @return void */ diff --git a/tests/Entity/Card/CreditCardEstPosTest.php b/tests/Entity/Card/CreditCardEstPosTest.php index 4453ad2f..9596f49f 100644 --- a/tests/Entity/Card/CreditCardEstPosTest.php +++ b/tests/Entity/Card/CreditCardEstPosTest.php @@ -12,5 +12,4 @@ public function testGetCardCode() $card = new CreditCardEstPos('1111222233334444', '02', '03', '111', 'ahmet mehmet', 'visa'); $this->assertEquals('1', $card->getCardCode()); } - -} \ No newline at end of file +} diff --git a/tests/Entity/Card/CreditCardPosNetTest.php b/tests/Entity/Card/CreditCardPosNetTest.php index e33d2336..f42cef4a 100644 --- a/tests/Entity/Card/CreditCardPosNetTest.php +++ b/tests/Entity/Card/CreditCardPosNetTest.php @@ -12,4 +12,4 @@ public function testGetExpirationDate() $card = new CreditCardPosNet('1111222233334444', '02', '03', '111', 'ahmet mehmet'); $this->assertEquals('0203', $card->getExpirationDate()); } -} \ No newline at end of file +} diff --git a/tests/Gateways/EstPostTest.php b/tests/Gateways/EstPostTest.php index bf930e5e..bea43bf3 100644 --- a/tests/Gateways/EstPostTest.php +++ b/tests/Gateways/EstPostTest.php @@ -7,6 +7,7 @@ use Mews\Pos\Factory\AccountFactory; use Mews\Pos\Factory\PosFactory; use Mews\Pos\Gateways\AbstractGateway; +use Mews\Pos\Gateways\EstPos; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Encoder\XmlEncoder; @@ -16,6 +17,9 @@ class EstPostTest extends TestCase * @var EstPosAccount */ private $account; + /** + * @var EstPos + */ private $pos; private $config; @@ -33,23 +37,23 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__ . '/../../config/pos.php'; + $this->config = require __DIR__.'/../../config/pos.php'; - $this->account = AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', 'XXXXXXX', '3d', 'VnM5WZ3sGrPusmWP', \Mews\Pos\Gateways\EstPos::LANG_TR); + $this->account = AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', 'XXXXXXX', '3d', 'VnM5WZ3sGrPusmWP', EstPos::LANG_TR); $this->card = new CreditCardEstPos('5555444433332222', '21', '12', '122', 'ahmet', 'visa'); $this->order = [ - 'id' => 'order222', - 'name' => 'siparis veren', - 'email' => 'test@test.com', - 'amount' => '100.25', + 'id' => 'order222', + 'name' => 'siparis veren', + 'email' => 'test@test.com', + 'amount' => '100.25', 'installment' => 0, - 'currency' => 'TRY', + 'currency' => 'TRY', 'success_url' => 'https://domain.com/success', - 'fail_url' => 'https://domain.com/fail_url', - 'lang' => 'tr', - 'rand' => microtime() + 'fail_url' => 'https://domain.com/fail_url', + 'lang' => 'tr', + 'rand' => microtime(), ]; $this->pos = PosFactory::createPosGateway($this->account); @@ -79,24 +83,24 @@ public function testGet3DFormWithCardData() $form = [ 'gateway' => $this->config['banks'][$this->account->getBank()]['urls']['gateway']['test'], - 'inputs' => [ - 'clientid' => $this->account->getClientId(), - 'storetype' => $this->account->getModel(), - 'hash' => $this->pos->create3DHash(), - 'cardType' => $this->card->getCardCode(), - 'pan' => $this->card->getNumber(), + 'inputs' => [ + 'clientid' => $this->account->getClientId(), + 'storetype' => $this->account->getModel(), + 'hash' => $this->pos->create3DHash(), + 'cardType' => $this->card->getCardCode(), + 'pan' => $this->card->getNumber(), 'Ecom_Payment_Card_ExpDate_Month' => $this->card->getExpireMonth(), - 'Ecom_Payment_Card_ExpDate_Year' => $this->card->getExpireYear(), - 'cv2' => $this->card->getCvv(), - 'firmaadi' => $this->order['name'], - 'Email' => $this->order['email'], - 'amount' => $this->order['amount'], - 'oid' => $this->order['id'], - 'okUrl' => $this->order['success_url'], - 'failUrl' => $this->order['fail_url'], - 'rnd' => $this->order['rand'], - 'lang' => $this->order['lang'], - 'currency' => 949, + 'Ecom_Payment_Card_ExpDate_Year' => $this->card->getExpireYear(), + 'cv2' => $this->card->getCvv(), + 'firmaadi' => $this->order['name'], + 'Email' => $this->order['email'], + 'amount' => $this->order['amount'], + 'oid' => $this->order['id'], + 'okUrl' => $this->order['success_url'], + 'failUrl' => $this->order['fail_url'], + 'rnd' => $this->order['rand'], + 'lang' => $this->order['lang'], + 'currency' => 949, ], ]; $this->assertEquals($form, $this->pos->get3DFormData()); @@ -108,19 +112,19 @@ public function testGet3DFormWithoutCardData() $form = [ 'gateway' => $this->config['banks'][$this->account->getBank()]['urls']['gateway']['test'], - 'inputs' => [ - 'clientid' => $this->account->getClientId(), + 'inputs' => [ + 'clientid' => $this->account->getClientId(), 'storetype' => $this->account->getModel(), - 'hash' => $this->pos->create3DHash(), - 'firmaadi' => $this->order['name'], - 'Email' => $this->order['email'], - 'amount' => $this->order['amount'], - 'oid' => $this->order['id'], - 'okUrl' => $this->order['success_url'], - 'failUrl' => $this->order['fail_url'], - 'rnd' => $this->order['rand'], - 'lang' => $this->order['lang'], - 'currency' => 949, + 'hash' => $this->pos->create3DHash(), + 'firmaadi' => $this->order['name'], + 'Email' => $this->order['email'], + 'amount' => $this->order['amount'], + 'oid' => $this->order['id'], + 'okUrl' => $this->order['success_url'], + 'failUrl' => $this->order['fail_url'], + 'rnd' => $this->order['rand'], + 'lang' => $this->order['lang'], + 'currency' => 949, ], ]; $this->assertEquals($form, $this->pos->get3DFormData()); @@ -129,19 +133,19 @@ public function testGet3DFormWithoutCardData() public function testCheck3DHash() { $data = [ - "md" => "478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568", - "cavv" => "BwAQAhIYRwEAABWGABhHEE6v5IU=", - "AuthCode" => "", - "oid" => "880", - "mdStatus" => "4", - "eci" => "06", - "clientid" => "400902568", - "rnd" => "hDx50d0cq7u1vbpWQMae", + "md" => "478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568", + "cavv" => "BwAQAhIYRwEAABWGABhHEE6v5IU=", + "AuthCode" => "", + "oid" => "880", + "mdStatus" => "4", + "eci" => "06", + "clientid" => "400902568", + "rnd" => "hDx50d0cq7u1vbpWQMae", "ProcReturnCode" => "N7", - "Response" => "Declined", - "HASH" => "D+B5fFWXEWFqVSkwotyuTPUW800=", - "HASHPARAMS" => "clientid:oid:AuthCode:ProcReturnCode:Response:mdStatus:cavv:eci:md:rnd:", - "HASHPARAMSVAL" => "400902568880N7Declined4BwAQAhIYRwEAABWGABhHEE6v5IU=06478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568hDx50d0cq7u1vbpWQMae", + "Response" => "Declined", + "HASH" => "D+B5fFWXEWFqVSkwotyuTPUW800=", + "HASHPARAMS" => "clientid:oid:AuthCode:ProcReturnCode:Response:mdStatus:cavv:eci:md:rnd:", + "HASHPARAMSVAL" => "400902568880N7Declined4BwAQAhIYRwEAABWGABhHEE6v5IU=06478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568hDx50d0cq7u1vbpWQMae", ]; $this->assertTrue($this->pos->check3DHash($data)); @@ -153,18 +157,21 @@ public function testCheck3DHash() public function testCreateRegularPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'email' => 'samp@iexample.com', - 'name' => 'john doe', - 'user_id' => '1535', - 'ip' => '192.168.1.0', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', + 'id' => '2020110828BC', + 'email' => 'samp@iexample.com', + 'name' => 'john doe', + 'user_id' => '1535', + 'ip' => '192.168.1.0', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', ]; $card = new CreditCardEstPos('5555444433332222', '22', '01', '123', 'ahmet'); + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_PAY, $card); @@ -179,16 +186,19 @@ public function testCreateRegularPaymentXML() public function testCreateRegularPostXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', ]; + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_POST_PAY); $actualXML = $pos->createRegularPostXML(); $actualData = $this->xmlDecoder->decode($actualXML, 'xml'); - $expectedData = $this->getSampleRegularPostXMLData($pos->getOrder(), $pos->getAccount()); + $expectedData = $this->getSampleRegularPostXMLData($pos->getOrder(), $pos->getAccount()); $this->assertEquals($expectedData, $actualData); //$this->assertEquals([], $actualData); } @@ -197,24 +207,27 @@ public function testCreate3DPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'email' => 'samp@iexample.com', - 'name' => 'john doe', - 'user_id' => '1535', - 'ip' => '192.168.1.0', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', - 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'id' => '2020110828BC', + 'email' => 'samp@iexample.com', + 'name' => 'john doe', + 'user_id' => '1535', + 'ip' => '192.168.1.0', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', + 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', ]; $responseData = [ - 'md' => '1', - 'xid' => '100000005xid', - 'eci' => '100000005eci', + 'md' => '1', + 'xid' => '100000005xid', + 'eci' => '100000005eci', 'cavv' => 'cavv', ]; + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_PAY); @@ -229,9 +242,12 @@ public function testCreate3DPaymentXML() public function testCreateStatusXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', ]; + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_STATUS); @@ -247,9 +263,12 @@ public function testCreateStatusXML() public function testCreateCancelXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', ]; + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_CANCEL); @@ -264,10 +283,13 @@ public function testCreateCancelXML() public function testCreateRefundXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 50 + 'id' => '2020110828BC', + 'amount' => 50, ]; + /** + * @var EstPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_REFUND); @@ -280,41 +302,41 @@ public function testCreateRefundXML() } /** - * @param $order + * @param $order * @param CreditCardEstPos $card - * @param EstPosAccount $account + * @param EstPosAccount $account * * @return array */ private function getSampleRegularPaymentXMLData($order, $card, $account) { return [ - 'Name' => $account->getUsername(), - 'Password' => $account->getPassword(), - 'ClientId' => $account->getClientId(), - 'Type' => 'Auth', + 'Name' => $account->getUsername(), + 'Password' => $account->getPassword(), + 'ClientId' => $account->getClientId(), + 'Type' => 'Auth', 'IPAddress' => $order->ip, - 'Email' => $order->email, - 'OrderId' => $order->id, - 'UserId' => isset($order->user_id) ? $order->user_id : null, - 'Total' => $order->amount, - 'Currency' => $order->currency, - 'Taksit' => $order->installment, - 'CardType' => $card->getType(), - 'Number' => $card->getNumber(), - 'Expires' => $card->getExpirationDate(), - 'Cvv2Val' => $card->getCvv(), - 'Mode' => 'P', - 'GroupId' => '', - 'TransId' => '', - 'BillTo' => [ + 'Email' => $order->email, + 'OrderId' => $order->id, + 'UserId' => isset($order->user_id) ? $order->user_id : null, + 'Total' => $order->amount, + 'Currency' => $order->currency, + 'Taksit' => $order->installment, + 'CardType' => $card->getType(), + 'Number' => $card->getNumber(), + 'Expires' => $card->getExpirationDate(), + 'Cvv2Val' => $card->getCvv(), + 'Mode' => 'P', + 'GroupId' => '', + 'TransId' => '', + 'BillTo' => [ 'Name' => $order->name ? $order->name : null, ], ]; } /** - * @param $order + * @param $order * @param EstPosAccount $account * * @return array @@ -322,56 +344,57 @@ private function getSampleRegularPaymentXMLData($order, $card, $account) private function getSampleRegularPostXMLData($order, $account) { return [ - 'Name' => $account->getUsername(), + 'Name' => $account->getUsername(), 'Password' => $account->getPassword(), 'ClientId' => $account->getClientId(), - 'Type' => 'PostAuth', - 'OrderId' => $order->id, + 'Type' => 'PostAuth', + 'OrderId' => $order->id, ]; } /** - * @param $order + * @param $order * @param EstPosAccount $account - * @param array $responseData + * @param array $responseData * * @return array */ private function getSample3DPaymentXMLData($order, $account, array $responseData) { $requestData = [ - 'Name' => $account->getUsername(), - 'Password' => $account->getPassword(), - 'ClientId' => $account->getClientId(), - 'Type' => 'Auth', - 'IPAddress' => $order->ip, - 'Email' => $order->email, - 'OrderId' => $order->id, - 'UserId' => isset($order->user_id) ? $order->user_id : null, - 'Total' => $order->amount, - 'Currency' => $order->currency, - 'Taksit' => $order->installment, - 'Number' => $responseData['md'], - 'Expires' => '', - 'Cvv2Val' => '', - 'PayerTxnId' => $responseData['xid'], - 'PayerSecurityLevel' => $responseData['eci'], + 'Name' => $account->getUsername(), + 'Password' => $account->getPassword(), + 'ClientId' => $account->getClientId(), + 'Type' => 'Auth', + 'IPAddress' => $order->ip, + 'Email' => $order->email, + 'OrderId' => $order->id, + 'UserId' => isset($order->user_id) ? $order->user_id : null, + 'Total' => $order->amount, + 'Currency' => $order->currency, + 'Taksit' => $order->installment, + 'Number' => $responseData['md'], + 'Expires' => '', + 'Cvv2Val' => '', + 'PayerTxnId' => $responseData['xid'], + 'PayerSecurityLevel' => $responseData['eci'], 'PayerAuthenticationCode' => $responseData['cavv'], - 'CardholderPresentCode' => '13', - 'Mode' => 'P', - 'GroupId' => '', - 'TransId' => '', + 'CardholderPresentCode' => '13', + 'Mode' => 'P', + 'GroupId' => '', + 'TransId' => '', ]; if (isset($order->name)) { $requestData['BillTo'] = [ 'Name' => $order->name, ]; } + return $requestData; } /** - * @param $order + * @param $order * @param EstPosAccount $account * * @return array @@ -379,18 +402,18 @@ private function getSample3DPaymentXMLData($order, $account, array $responseData private function getSampleStatusXMLData($order, $account) { return [ - 'Name' => $account->getUsername(), + 'Name' => $account->getUsername(), 'Password' => $account->getPassword(), 'ClientId' => $account->getClientId(), - 'OrderId' => $order->id, - 'Extra' => [ + 'OrderId' => $order->id, + 'Extra' => [ 'ORDERSTATUS' => 'QUERY', ], ]; } /** - * @param $order + * @param $order * @param EstPosAccount $account * * @return array @@ -398,16 +421,16 @@ private function getSampleStatusXMLData($order, $account) private function getSampleCancelXMLData($order, $account) { return [ - 'Name' => $account->getUsername(), + 'Name' => $account->getUsername(), 'Password' => $account->getPassword(), 'ClientId' => $account->getClientId(), - 'OrderId' => $order->id, - 'Type' => 'Void', + 'OrderId' => $order->id, + 'Type' => 'Void', ]; } /** - * @param $order + * @param $order * @param EstPosAccount $account * * @return array @@ -415,11 +438,11 @@ private function getSampleCancelXMLData($order, $account) private function getSampleRefundXMLData($order, $account) { $data = [ - 'Name' => $account->getUsername(), + 'Name' => $account->getUsername(), 'Password' => $account->getPassword(), 'ClientId' => $account->getClientId(), - 'OrderId' => $order->id, - 'Type' => 'Credit', + 'OrderId' => $order->id, + 'Type' => 'Credit', ]; if ($order->amount) { diff --git a/tests/Gateways/GarantiPosTest.php b/tests/Gateways/GarantiPosTest.php index 251eb386..d9c08abe 100644 --- a/tests/Gateways/GarantiPosTest.php +++ b/tests/Gateways/GarantiPosTest.php @@ -37,24 +37,24 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__ . '/../../config/pos.php'; + $this->config = require __DIR__.'/../../config/pos.php'; $this->account = AccountFactory::createGarantiPosAccount('garanti', '7000679', 'PROVAUT', '123qweASD/', '30691298', '3d', '12345678', 'PROVRFN', '123qweASD/'); $this->card = new CreditCardGarantiPos('5555444433332222', '21', '12', '122'); $this->order = [ - 'id' => 'order222', - 'name' => 'siparis veren', - 'email' => 'test@test.com', - 'amount' => '100.25', + 'id' => 'order222', + 'name' => 'siparis veren', + 'email' => 'test@test.com', + 'amount' => '100.25', 'installment' => 0, - 'currency' => 'TRY', + 'currency' => 'TRY', 'success_url' => 'https://domain.com/success', - 'fail_url' => 'https://domain.com/fail_url', - 'lang' => 'tr', - 'rand' => microtime(), - 'ip' => '156.155.154.153', + 'fail_url' => 'https://domain.com/fail_url', + 'lang' => 'tr', + 'rand' => microtime(), + 'ip' => '156.155.154.153', ]; $this->pos = PosFactory::createPosGateway($this->account); @@ -151,18 +151,21 @@ public function testGet3DFormWithoutCardData() public function testCreateRegularPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'email' => 'samp@iexample.com', - 'name' => 'john doe', - 'user_id' => '1535', - 'ip' => '192.168.1.0', - 'amount' => 100.01, - 'installment' => 0, - 'currency' => 'TRY', + 'id' => '2020110828BC', + 'email' => 'samp@iexample.com', + 'name' => 'john doe', + 'user_id' => '1535', + 'ip' => '192.168.1.0', + 'amount' => 100.01, + 'installment' => 0, + 'currency' => 'TRY', ]; $card = new CreditCardGarantiPos('5555444433332222', '22', '01', '123', 'ahmet'); + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_PAY, $card); @@ -177,14 +180,17 @@ public function testCreateRegularPaymentXML() public function testCreateRegularPostXML() { $order = [ - 'id' => '2020110828BC', - 'ref_ret_num' => '831803579226', - 'currency' => 'TRY', - 'amount' => 100.01, - 'email' => 'samp@iexample.com', - 'ip' => '192.168.1.0', + 'id' => '2020110828BC', + 'ref_ret_num' => '831803579226', + 'currency' => 'TRY', + 'amount' => 100.01, + 'email' => 'samp@iexample.com', + 'ip' => '192.168.1.0', ]; + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_POST_PAY); @@ -192,37 +198,40 @@ public function testCreateRegularPostXML() $actualXML = $pos->createRegularPostXML(); $actualData = $this->xmlDecoder->decode($actualXML, 'xml'); - $expectedData = $this->getSampleRegularPostXMLData($pos->getOrder(), $pos->getAccount()); + $expectedData = $this->getSampleRegularPostXMLData($pos->getOrder(), $pos->getAccount()); $this->assertEquals($expectedData, $actualData); } public function testCreate3DPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'email' => 'samp@iexample.com', - 'name' => 'john doe', - 'user_id' => '1535', - 'ip' => '192.168.1.0', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', - 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'id' => '2020110828BC', + 'email' => 'samp@iexample.com', + 'name' => 'john doe', + 'user_id' => '1535', + 'ip' => '192.168.1.0', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', + 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', ]; $responseData = [ - 'orderid' => '2020110828BC', - 'md' => '1', - 'xid' => '100000005xid', - 'eci' => '100000005eci', - 'cavv' => 'cavv', - 'txncurrencycode' => 'txncurrencycode', - 'txnamount' => 'txnamount', - 'txntype' => 'txntype', - 'customeripaddress' => 'customeripaddress', + 'orderid' => '2020110828BC', + 'md' => '1', + 'xid' => '100000005xid', + 'eci' => '100000005eci', + 'cavv' => 'cavv', + 'txncurrencycode' => 'txncurrencycode', + 'txnamount' => 'txnamount', + 'txntype' => 'txntype', + 'customeripaddress' => 'customeripaddress', 'customeremailaddress' => 'customeremailaddress', ]; + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_PAY); @@ -237,10 +246,13 @@ public function testCreate3DPaymentXML() public function testCreateStatusXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', 'currency' => 'TRY', ]; + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_STATUS); @@ -256,12 +268,15 @@ public function testCreateStatusXML() public function testCreateCancelXML() { $order = [ - 'id' => '2020110828BC', - 'currency' => 'TRY', - 'amount' => 10.01, - 'ref_ret_num' => '831803579226', + 'id' => '2020110828BC', + 'currency' => 'TRY', + 'amount' => 10.01, + 'ref_ret_num' => '831803579226', ]; + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_CANCEL); @@ -276,12 +291,15 @@ public function testCreateCancelXML() public function testCreateRefundXML() { $order = [ - 'id' => '2020110828BC', - 'currency' => 'TRY', - 'amount' => 10.01, - 'ref_ret_num' => '831803579226', + 'id' => '2020110828BC', + 'currency' => 'TRY', + 'amount' => 10.01, + 'ref_ret_num' => '831803579226', ]; + /** + * @var GarantiPos $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->setTestMode(true); $pos->prepare($order, AbstractGateway::TX_REFUND); @@ -295,52 +313,52 @@ public function testCreateRefundXML() } /** - * @param $order + * @param $order * @param CreditCardGarantiPos $card - * @param GarantiPosAccount $account + * @param GarantiPosAccount $account * * @return array */ private function getSampleRegularPaymentXMLData($order, $card, $account) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'Terminal' => [ - 'ProvUserID' => $account->getUsername(), - 'UserID' => $account->getUsername(), - 'HashData' => 'F0641E566B7B98260FD1608D1DF81E8D55461877', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getTerminalId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'Terminal' => [ + 'ProvUserID' => $account->getUsername(), + 'UserID' => $account->getUsername(), + 'HashData' => 'F0641E566B7B98260FD1608D1DF81E8D55461877', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getTerminalId(), ], - 'Customer' => [ - 'IPAddress' => $order->ip, - 'EmailAddress' => $order->email, + 'Customer' => [ + 'IPAddress' => $order->ip, + 'EmailAddress' => $order->email, ], - 'Card' => [ - 'Number' => $card->getNumber(), - 'ExpireDate' => $card->getExpirationDate(), - 'CVV2' => $card->getCvv(), + 'Card' => [ + 'Number' => $card->getNumber(), + 'ExpireDate' => $card->getExpirationDate(), + 'CVV2' => $card->getCvv(), ], - 'Order' => [ - 'OrderID' => $order->id, - 'GroupID' => '', - 'AddressList' => [ - 'Address' => [ - 'Type' => 'S', - 'Name' => $order->name, - 'LastName' => '', - 'Company' => '', - 'Text' => '', - 'District' => '', - 'City' => '', - 'PostalCode' => '', - 'Country' => '', - 'PhoneNumber' => '', + 'Order' => [ + 'OrderID' => $order->id, + 'GroupID' => '', + 'AddressList' => [ + 'Address' => [ + 'Type' => 'S', + 'Name' => $order->name, + 'LastName' => '', + 'Company' => '', + 'Text' => '', + 'District' => '', + 'City' => '', + 'PostalCode' => '', + 'Country' => '', + 'PhoneNumber' => '', ], ], ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => 'sales', 'InstallmentCnt' => $order->installment, 'Amount' => $order->amount, @@ -354,7 +372,7 @@ private function getSampleRegularPaymentXMLData($order, $card, $account) } /** - * @param $order + * @param $order * @param GarantiPosAccount $account * * @return array @@ -362,23 +380,23 @@ private function getSampleRegularPaymentXMLData($order, $card, $account) private function getSampleRegularPostXMLData($order, $account) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'Terminal' => [ - 'ProvUserID' => $account->getUsername(), - 'UserID' => $account->getUsername(), - 'HashData' => '7598B3D1A15C45095CD139E9CFD780B050D1C4AA', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getClientId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'Terminal' => [ + 'ProvUserID' => $account->getUsername(), + 'UserID' => $account->getUsername(), + 'HashData' => '7598B3D1A15C45095CD139E9CFD780B050D1C4AA', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getClientId(), ], - 'Customer' => [ - 'IPAddress' => $order->ip, - 'EmailAddress' => $order->email, + 'Customer' => [ + 'IPAddress' => $order->ip, + 'EmailAddress' => $order->email, ], - 'Order' => [ - 'OrderID' => $order->id, + 'Order' => [ + 'OrderID' => $order->id, ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => 'postauth', 'Amount' => $order->amount, 'CurrencyCode' => $order->currency, @@ -388,53 +406,53 @@ private function getSampleRegularPostXMLData($order, $account) } /** - * @param $order + * @param $order * @param GarantiPosAccount $account - * @param array $responseData + * @param array $responseData * * @return array */ private function getSample3DPaymentXMLData($order, $account, array $responseData) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $account->getUsername(), - 'UserID' => $account->getUsername(), - 'HashData' => '7598B3D1A15C45095CD139E9CFD780B050D1C4AA', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getClientId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $account->getUsername(), + 'UserID' => $account->getUsername(), + 'HashData' => '7598B3D1A15C45095CD139E9CFD780B050D1C4AA', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getClientId(), ], - 'Customer' => [ - 'IPAddress' => $responseData['customeripaddress'], - 'EmailAddress' => $responseData['customeremailaddress'], + 'Customer' => [ + 'IPAddress' => $responseData['customeripaddress'], + 'EmailAddress' => $responseData['customeremailaddress'], ], - 'Card' => [ - 'Number' => '', - 'ExpireDate' => '', - 'CVV2' => '', + 'Card' => [ + 'Number' => '', + 'ExpireDate' => '', + 'CVV2' => '', ], - 'Order' => [ - 'OrderID' => $responseData['orderid'], - 'GroupID' => '', - 'AddressList' => [ - 'Address' => [ - 'Type' => 'B', - 'Name' => $order->name, - 'LastName' => '', - 'Company' => '', - 'Text' => '', - 'District' => '', - 'City' => '', - 'PostalCode' => '', - 'Country' => '', - 'PhoneNumber' => '', + 'Order' => [ + 'OrderID' => $responseData['orderid'], + 'GroupID' => '', + 'AddressList' => [ + 'Address' => [ + 'Type' => 'B', + 'Name' => $order->name, + 'LastName' => '', + 'Company' => '', + 'Text' => '', + 'District' => '', + 'City' => '', + 'PostalCode' => '', + 'Country' => '', + 'PhoneNumber' => '', ], ], ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => $responseData['txntype'], 'InstallmentCnt' => $order->installment, 'Amount' => $responseData['txnamount'], @@ -442,17 +460,17 @@ private function getSample3DPaymentXMLData($order, $account, array $responseData 'CardholderPresentCode' => '13', 'MotoInd' => 'N', 'Secure3D' => [ - 'AuthenticationCode' => $responseData['cavv'], - 'SecurityLevel' => $responseData['eci'], - 'TxnID' => $responseData['xid'], - 'Md' => $responseData['md'], + 'AuthenticationCode' => $responseData['cavv'], + 'SecurityLevel' => $responseData['eci'], + 'TxnID' => $responseData['xid'], + 'Md' => $responseData['md'], ], ], ]; } /** - * @param $order + * @param $order * @param GarantiPosAccount $account * * @return array @@ -460,30 +478,30 @@ private function getSample3DPaymentXMLData($order, $account, array $responseData private function getSampleStatusXMLData($order, $account) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $account->getUsername(), - 'UserID' => $account->getUsername(), - 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getClientId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $account->getUsername(), + 'UserID' => $account->getUsername(), + 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getClientId(), ], - 'Customer' => [ - 'IPAddress' => $order->ip, - 'EmailAddress' => $order->email, + 'Customer' => [ + 'IPAddress' => $order->ip, + 'EmailAddress' => $order->email, ], - 'Order' => [ - 'OrderID' => $order->id, - 'GroupID' => '', + 'Order' => [ + 'OrderID' => $order->id, + 'GroupID' => '', ], - 'Card' => [ - 'Number' => '', - 'ExpireDate' => '', - 'CVV2' => '', + 'Card' => [ + 'Number' => '', + 'ExpireDate' => '', + 'CVV2' => '', ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => 'orderinq', 'InstallmentCnt' => '', 'Amount' => $order->amount, @@ -495,7 +513,7 @@ private function getSampleStatusXMLData($order, $account) } /** - * @param $order + * @param $order * @param GarantiPosAccount $account * * @return array @@ -503,25 +521,25 @@ private function getSampleStatusXMLData($order, $account) private function getSampleCancelXMLData($order, $account) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $account->getRefundUsername(), - 'UserID' => $account->getRefundUsername(), - 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getClientId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $account->getRefundUsername(), + 'UserID' => $account->getRefundUsername(), + 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getClientId(), ], - 'Customer' => [ - 'IPAddress' => $order->ip, - 'EmailAddress' => $order->email, + 'Customer' => [ + 'IPAddress' => $order->ip, + 'EmailAddress' => $order->email, ], - 'Order' => [ - 'OrderID' => $order->id, - 'GroupID' => '', + 'Order' => [ + 'OrderID' => $order->id, + 'GroupID' => '', ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => 'void', 'InstallmentCnt' => $order->installment, 'Amount' => $order->amount, @@ -535,7 +553,7 @@ private function getSampleCancelXMLData($order, $account) } /** - * @param $order + * @param $order * @param GarantiPosAccount $account * * @return array @@ -543,25 +561,25 @@ private function getSampleCancelXMLData($order, $account) private function getSampleRefundXMLData($order, $account) { return [ - 'Mode' => 'TEST', - 'Version' => GarantiPos::API_VERSION, - 'ChannelCode' => '', - 'Terminal' => [ - 'ProvUserID' => $account->getRefundUsername(), - 'UserID' => $account->getRefundUsername(), - 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', - 'ID' => $account->getTerminalId(), - 'MerchantID' => $account->getClientId(), + 'Mode' => 'TEST', + 'Version' => GarantiPos::API_VERSION, + 'ChannelCode' => '', + 'Terminal' => [ + 'ProvUserID' => $account->getRefundUsername(), + 'UserID' => $account->getRefundUsername(), + 'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04', + 'ID' => $account->getTerminalId(), + 'MerchantID' => $account->getClientId(), ], - 'Customer' => [ - 'IPAddress' => $order->ip, - 'EmailAddress' => $order->email, + 'Customer' => [ + 'IPAddress' => $order->ip, + 'EmailAddress' => $order->email, ], - 'Order' => [ - 'OrderID' => $order->id, - 'GroupID' => '', + 'Order' => [ + 'OrderID' => $order->id, + 'GroupID' => '', ], - 'Transaction' => [ + 'Transaction' => [ 'Type' => 'refund', 'InstallmentCnt' => '', 'Amount' => $order->amount, diff --git a/tests/Gateways/PayForTest.php b/tests/Gateways/PayForTest.php index cd400d9a..5ed4257e 100644 --- a/tests/Gateways/PayForTest.php +++ b/tests/Gateways/PayForTest.php @@ -41,24 +41,24 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__ . '/../../config/pos.php'; + $this->config = require __DIR__.'/../../config/pos.php'; $this->threeDAccount = AccountFactory::createPayForAccount('qnbfinansbank-payfor', '085300000009704', 'QNB_API_KULLANICI_3DPAY', 'UcBN0', '3d', '12345678'); $this->card = new CreditCardPayFor('5555444433332222', '22', '01', '123', 'ahmet'); $this->order = [ - 'id' => '2020110828BC', - 'email' => 'mail@customer.com', // optional - 'name' => 'John Doe', // optional - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', - 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'rand' => '0.43625700 1604831630', - 'hash' => 'zmSUxYPhmCj7QOzqpk/28LuE1Oc=', - 'lang' => PayForPos::LANG_TR, + 'id' => '2020110828BC', + 'email' => 'mail@customer.com', // optional + 'name' => 'John Doe', // optional + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', + 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'rand' => '0.43625700 1604831630', + 'hash' => 'zmSUxYPhmCj7QOzqpk/28LuE1Oc=', + 'lang' => PayForPos::LANG_TR, ]; $this->pos = PosFactory::createPosGateway($this->threeDAccount); @@ -99,26 +99,26 @@ public function testGet3DFormDataWithCard() $order = $this->pos->getOrder(); $form = [ 'gateway' => $this->config['banks'][$this->threeDAccount->getBank()]['urls']['gateway']['test'], - 'inputs' => [ - 'MbrId' => PayForPos::MBR_ID, - 'MerchantID' => $this->threeDAccount->getClientId(), - 'UserCode' => $this->threeDAccount->getUsername(), - 'OrderId' => $order->id, - 'Lang' => $order->lang, - 'SecureType' => '3DModel', - 'TxnType' => 'Auth', - 'PurchAmount' => $order->amount, + 'inputs' => [ + 'MbrId' => PayForPos::MBR_ID, + 'MerchantID' => $this->threeDAccount->getClientId(), + 'UserCode' => $this->threeDAccount->getUsername(), + 'OrderId' => $order->id, + 'Lang' => $order->lang, + 'SecureType' => '3DModel', + 'TxnType' => 'Auth', + 'PurchAmount' => $order->amount, 'InstallmentCount' => $order->installment, - 'Currency' => $order->currency, - 'OkUrl' => $order->success_url, - 'FailUrl' => $order->fail_url, - 'Rnd' => $order->rand, - 'Hash' => $this->pos->create3DHash(), - 'CardHolderName' => 'ahmet', - 'Pan' => '5555444433332222', - 'Expiry' => '0122', - 'Cvv2' => '123', - ] + 'Currency' => $order->currency, + 'OkUrl' => $order->success_url, + 'FailUrl' => $order->fail_url, + 'Rnd' => $order->rand, + 'Hash' => $this->pos->create3DHash(), + 'CardHolderName' => 'ahmet', + 'Pan' => '5555444433332222', + 'Expiry' => '0122', + 'Cvv2' => '123', + ], ]; $this->assertEquals($form, $this->pos->get3DFormData()); } @@ -129,22 +129,22 @@ public function testGet3DFormDataWithoutCard() $order = $this->pos->getOrder(); $form = [ 'gateway' => $this->config['banks'][$this->threeDAccount->getBank()]['urls']['gateway']['test'], - 'inputs' => [ - 'MbrId' => PayForPos::MBR_ID, - 'MerchantID' => $this->threeDAccount->getClientId(), - 'UserCode' => $this->threeDAccount->getUsername(), - 'OrderId' => $order->id, - 'Lang' => $order->lang, - 'SecureType' => '3DModel', - 'TxnType' => 'Auth', - 'PurchAmount' => $order->amount, + 'inputs' => [ + 'MbrId' => PayForPos::MBR_ID, + 'MerchantID' => $this->threeDAccount->getClientId(), + 'UserCode' => $this->threeDAccount->getUsername(), + 'OrderId' => $order->id, + 'Lang' => $order->lang, + 'SecureType' => '3DModel', + 'TxnType' => 'Auth', + 'PurchAmount' => $order->amount, 'InstallmentCount' => $order->installment, - 'Currency' => $order->currency, - 'OkUrl' => $order->success_url, - 'FailUrl' => $order->fail_url, - 'Rnd' => $order->rand, - 'Hash' => $this->pos->create3DHash(), - ] + 'Currency' => $order->currency, + 'OkUrl' => $order->success_url, + 'FailUrl' => $order->fail_url, + 'Rnd' => $order->rand, + 'Hash' => $this->pos->create3DHash(), + ], ]; $this->assertEquals($form, $this->pos->get3DFormData()); } @@ -152,12 +152,12 @@ public function testGet3DFormDataWithoutCard() public function testCreate3DHash() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'rand' => '0.43625700 1604831630', + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '0', + 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', + 'rand' => '0.43625700 1604831630', ]; $hash = 'zmSUxYPhmCj7QOzqpk/28LuE1Oc='; $this->pos->prepare($order, AbstractGateway::TX_PAY); @@ -167,12 +167,12 @@ public function testCreate3DHash() public function testCheck3DHash() { $data = [ - "OrderId" => '2020110828BC', - "AuthCode" => "", - "3DStatus" => "1", + "OrderId" => '2020110828BC', + "AuthCode" => "", + "3DStatus" => "1", "ProcReturnCode" => "V033", - "ResponseRnd" => "PF637404392360825218", - "ResponseHash" => "ogupUOYY6vQ4+opqDqgLk3DLK7I=", + "ResponseRnd" => "PF637404392360825218", + "ResponseHash" => "ogupUOYY6vQ4+opqDqgLk3DLK7I=", ]; $this->assertTrue($this->pos->check3DHash($data)); @@ -185,14 +185,17 @@ public function testCreateRegularPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', - 'lang' => PayForPos::LANG_TR, + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', + 'lang' => PayForPos::LANG_TR, ]; $card = new CreditCardPayFor('5555444433332222', '22', '01', '123', 'ahmet'); + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_PAY, $card); @@ -206,13 +209,16 @@ public function testCreateRegularPaymentXML() public function testCreateRegularPostXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', - 'lang' => PayForPos::LANG_TR, + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', + 'lang' => PayForPos::LANG_TR, ]; + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_POST_PAY); @@ -227,10 +233,13 @@ public function testCreate3DPaymentXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', ]; $responseData = ['RequestGuid' => '1000000057437884']; + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_PAY); @@ -244,9 +253,12 @@ public function testCreate3DPaymentXML() public function testCreateStatusXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', ]; + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_STATUS); @@ -260,10 +272,13 @@ public function testCreateStatusXML() public function testCreateCancelXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', 'currency' => 'TRY', ]; + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_CANCEL); @@ -277,11 +292,14 @@ public function testCreateCancelXML() public function testCreateRefundXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', 'currency' => 'TRY', - 'amount' => 10.1, + 'amount' => 10.1, ]; + /** + * @var PayForPos $pos + */ $pos = PosFactory::createPosGateway($this->threeDAccount); $pos->prepare($order, AbstractGateway::TX_REFUND); @@ -293,36 +311,36 @@ public function testCreateRefundXML() } /** - * @param $order + * @param $order * @param AbstractCreditCard $card - * @param PayForAccount $account + * @param PayForAccount $account * * @return array */ private function getSampleRegularPaymentXMLData($order, $card, $account) { return [ - 'MbrId' => PayForPos::MBR_ID, - 'MerchantId' => $account->getClientId(), - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), - 'MOTO' => PayForPos::MOTO, - 'OrderId' => $order->id, - 'SecureType' => 'NonSecure', - 'TxnType' => 'Auth', - 'PurchAmount' => $order->amount, - 'Currency' => $order->currency, + 'MbrId' => PayForPos::MBR_ID, + 'MerchantId' => $account->getClientId(), + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), + 'MOTO' => PayForPos::MOTO, + 'OrderId' => $order->id, + 'SecureType' => 'NonSecure', + 'TxnType' => 'Auth', + 'PurchAmount' => $order->amount, + 'Currency' => $order->currency, 'InstallmentCount' => $order->installment, - 'Lang' => 'tr', - 'CardHolderName' => $card->getHolderName(), - 'Pan' => $card->getNumber(), - 'Expiry' => $card->getExpirationDate(), - 'Cvv2' => $card->getCvv() + 'Lang' => 'tr', + 'CardHolderName' => $card->getHolderName(), + 'Pan' => $card->getNumber(), + 'Expiry' => $card->getExpirationDate(), + 'Cvv2' => $card->getCvv(), ]; } /** - * @param $order + * @param $order * @param PayForAccount $account * * @return array @@ -330,23 +348,23 @@ private function getSampleRegularPaymentXMLData($order, $card, $account) private function getSampleRegularPostXMLData($order, $account) { return [ - 'MbrId' => PayForPos::MBR_ID, - 'MerchantId' => $account->getClientId(), - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), - 'OrgOrderId' => $order->id, - 'SecureType' => 'NonSecure', - 'TxnType' => 'PostAuth', + 'MbrId' => PayForPos::MBR_ID, + 'MerchantId' => $account->getClientId(), + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), + 'OrgOrderId' => $order->id, + 'SecureType' => 'NonSecure', + 'TxnType' => 'PostAuth', 'PurchAmount' => $order->amount, - 'Currency' => $order->currency, - 'Lang' => 'tr', + 'Currency' => $order->currency, + 'Lang' => 'tr', ]; } /** - * @param $order + * @param $order * @param PayForAccount $account - * @param array $responseData + * @param array $responseData * * @return array */ @@ -354,15 +372,15 @@ private function getSample3DPaymentXMLData($order, $account, array $responseData { return [ 'RequestGuid' => $responseData['RequestGuid'], - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), - 'OrderId' => $order->id, - 'SecureType' => '3DModelPayment', + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), + 'OrderId' => $order->id, + 'SecureType' => '3DModelPayment', ]; } /** - * @param $order + * @param $order * @param PayForAccount $account * * @return array @@ -370,19 +388,19 @@ private function getSample3DPaymentXMLData($order, $account, array $responseData private function getSampleStatusXMLData($order, $account) { return [ - 'MbrId' => PayForPos::MBR_ID, + 'MbrId' => PayForPos::MBR_ID, 'MerchantId' => $account->getClientId(), - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), 'OrgOrderId' => $order->id, 'SecureType' => 'Inquiry', - 'Lang' => 'tr', - 'TxnType' => 'OrderInquiry', + 'Lang' => 'tr', + 'TxnType' => 'OrderInquiry', ]; } /** - * @param $order + * @param $order * @param PayForAccount $account * * @return array @@ -390,20 +408,20 @@ private function getSampleStatusXMLData($order, $account) private function getSampleCancelXMLData($order, $account) { return [ - 'MbrId' => PayForPos::MBR_ID, + 'MbrId' => PayForPos::MBR_ID, 'MerchantId' => $account->getClientId(), - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), 'OrgOrderId' => $order->id, 'SecureType' => 'NonSecure', - 'Lang' => 'tr', - 'TxnType' => 'Void', - 'Currency' => $order->currency + 'Lang' => 'tr', + 'TxnType' => 'Void', + 'Currency' => $order->currency, ]; } /** - * @param $order + * @param $order * @param PayForAccount $account * * @return array @@ -411,16 +429,16 @@ private function getSampleCancelXMLData($order, $account) private function getSampleRefundXMLData($order, $account) { return [ - 'MbrId' => PayForPos::MBR_ID, - 'MerchantId' => $account->getClientId(), - 'UserCode' => $account->getUsername(), - 'UserPass' => $account->getPassword(), - 'OrgOrderId' => $order->id, - 'SecureType' => 'NonSecure', - 'Lang' => 'tr', - 'TxnType' => 'Refund', + 'MbrId' => PayForPos::MBR_ID, + 'MerchantId' => $account->getClientId(), + 'UserCode' => $account->getUsername(), + 'UserPass' => $account->getPassword(), + 'OrgOrderId' => $order->id, + 'SecureType' => 'NonSecure', + 'Lang' => 'tr', + 'TxnType' => 'Refund', 'PurchAmount' => $order->amount, - 'Currency' => $order->currency + 'Currency' => $order->currency, ]; } } diff --git a/tests/Gateways/PosNetCryptTest.php b/tests/Gateways/PosNetCryptTest.php index 575e830a..b394fab8 100644 --- a/tests/Gateways/PosNetCryptTest.php +++ b/tests/Gateways/PosNetCryptTest.php @@ -5,7 +5,6 @@ use Mews\Pos\Gateways\PosNetCrypt; use PHPUnit\Framework\TestCase; - class PosNetCryptTest extends TestCase { private $crypt; diff --git a/tests/Gateways/PosNetTest.php b/tests/Gateways/PosNetTest.php index 45127e08..959d381f 100644 --- a/tests/Gateways/PosNetTest.php +++ b/tests/Gateways/PosNetTest.php @@ -38,23 +38,23 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__ . '/../../config/pos.php'; + $this->config = require __DIR__.'/../../config/pos.php'; $this->account = AccountFactory::createPosNetAccount('yapikredi', '6706598320', 'XXXXXX', 'XXXXXX', '67005551', '27426', '3d', '10,10,10,10,10,10,10,10'); $this->card = new CreditCardPosNet('5555444433332222', '21', '12', '122', 'ahmet'); $this->order = [ - 'id' => 'YKB_TST_190620093100_024', - 'name' => 'siparis veren', - 'email' => 'test@test.com', - 'amount' => '1.75', + 'id' => 'YKB_TST_190620093100_024', + 'name' => 'siparis veren', + 'email' => 'test@test.com', + 'amount' => '1.75', 'installment' => 0, - 'currency' => 'TL', + 'currency' => 'TL', 'success_url' => 'https://domain.com/success', - 'fail_url' => 'https://domain.com/fail_url', - 'lang' => 'tr', - 'rand' => microtime(), + 'fail_url' => 'https://domain.com/fail_url', + 'lang' => 'tr', + 'rand' => microtime(), ]; $this->pos = PosFactory::createPosGateway($this->account); @@ -77,13 +77,15 @@ public function testPrepare() $this->assertEquals($this->card, $this->pos->getCard()); } - public function testCreate3DHash(){ + public function testCreate3DHash() + { $this->pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $this->assertEquals('J/7/Xprj7F/KDf98luVfIGyUPRQzUCqGwpmvz3KT7oQ=', $this->pos->create3DHash()); } - public function testVerifyResponseMAC(){ + public function testVerifyResponseMAC() + { $newOrder = $this->order; $newOrder['id'] = '895'; @@ -97,16 +99,16 @@ public function testVerifyResponseMAC(){ $pos->prepare($newOrder, AbstractGateway::TX_PAY); $data = (object) [ - 'mdStatus' => '9', - 'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0=', + 'mdStatus' => '9', + 'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0=', ]; $this->assertTrue($pos->verifyResponseMAC($data)); $newOrder['id'] = '800'; $pos->prepare($newOrder, AbstractGateway::TX_PAY); $data = (object) [ - 'mdStatus' => '9', - 'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0=', + 'mdStatus' => '9', + 'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0=', ]; $this->assertFalse($pos->verifyResponseMAC($data)); } @@ -114,14 +116,17 @@ public function testVerifyResponseMAC(){ public function testCreateRegularPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '2', - 'currency' => 'TRY', + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '2', + 'currency' => 'TRY', ]; $card = new CreditCardPosNet('5555444433332222', '22', '01', '123', 'ahmet'); + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_PAY, $card); @@ -136,13 +141,16 @@ public function testCreateRegularPaymentXML() public function testCreateRegularPostXML() { $order = [ - 'id' => '2020110828BC', - 'host_ref_num' => '019676067890000191', - 'amount' => 10.02, - 'currency' => 'TRY', - 'installment' => '2', + 'id' => '2020110828BC', + 'host_ref_num' => '019676067890000191', + 'amount' => 10.02, + 'currency' => 'TRY', + 'installment' => '2', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_POST_PAY); @@ -158,17 +166,20 @@ public function testCreate3DPaymentXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', ]; $responseData = [ - 'BankPacket' => 'F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', + 'BankPacket' => 'F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', 'MerchantPacket' => 'E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', - 'Sign' => '9998F61E1D0C0FB6EC5203A748124F30', + 'Sign' => '9998F61E1D0C0FB6EC5203A748124F30', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_PAY); @@ -184,17 +195,20 @@ public function testCreate3DResolveMerchantDataXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => 'TRY', + 'id' => '2020110828BC', + 'amount' => 100.01, + 'installment' => '0', + 'currency' => 'TRY', ]; $responseData = [ - 'BankPacket' => 'F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', + 'BankPacket' => 'F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', 'MerchantPacket' => 'E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F309998F61E1D0C0FB6EC5203A748124F30', - 'Sign' => '9998F61E1D0C0FB6EC5203A748124F30', + 'Sign' => '9998F61E1D0C0FB6EC5203A748124F30', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_PAY); @@ -209,10 +223,13 @@ public function testCreate3DResolveMerchantDataXML() public function testCreateStatusXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', 'type' => 'status', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_STATUS); @@ -228,10 +245,13 @@ public function testCreateStatusXML() public function testCreateCancelXML() { $order = [ - 'id' => '2020110828BC', + 'id' => '2020110828BC', 'host_ref_num' => '2020110828BCNUM', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_CANCEL); @@ -246,11 +266,14 @@ public function testCreateCancelXML() public function testCreateRefundXML() { $order = [ - 'id' => '2020110828BC', - 'amount' => 50, + 'id' => '2020110828BC', + 'amount' => 50, 'currency' => 'TRY', ]; + /** + * @var PosNet $pos + */ $pos = PosFactory::createPosGateway($this->account); $pos->prepare($order, AbstractGateway::TX_REFUND); @@ -263,32 +286,32 @@ public function testCreateRefundXML() } /** - * @param $order + * @param $order * @param CreditCardPosNet $card - * @param PosNetAccount $account + * @param PosNetAccount $account * * @return array */ private function getSampleRegularPaymentXMLData($order, $card, $account) { return [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), - 'tranDateRequired' => '1', - 'sale' => [ - 'orderID' => $order->id, - 'installment' => $order->installment, - 'amount' => $order->amount, - 'currencyCode' => $order->currency, - 'ccno' => $card->getNumber(), - 'expDate' => $card->getExpirationDate(), - 'cvc' => $card->getCvv(), + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), + 'tranDateRequired' => '1', + 'sale' => [ + 'orderID' => $order->id, + 'installment' => $order->installment, + 'amount' => $order->amount, + 'currencyCode' => $order->currency, + 'ccno' => $card->getNumber(), + 'expDate' => $card->getExpirationDate(), + 'cvc' => $card->getCvv(), ], ]; } /** - * @param $order + * @param $order * @param PosNetAccount $account * * @return array @@ -296,61 +319,61 @@ private function getSampleRegularPaymentXMLData($order, $card, $account) private function getSampleRegularPostXMLData($order, $account) { return [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), - 'tranDateRequired' => '1', - 'capt' => [ - 'hostLogKey' => $order->host_ref_num, - 'amount' => $order->amount, - 'currencyCode' => $order->currency, - 'installment' => $order->installment, + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), + 'tranDateRequired' => '1', + 'capt' => [ + 'hostLogKey' => $order->host_ref_num, + 'amount' => $order->amount, + 'currencyCode' => $order->currency, + 'installment' => $order->installment, ], ]; } /** * @param PosNetAccount $account - * @param array $responseData + * @param array $responseData * * @return array */ private function getSample3DPaymentXMLData($account, array $responseData) { return [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), 'oosTranData' => [ - 'bankData' => $responseData['BankPacket'], - 'merchantData' => $responseData['MerchantPacket'], - 'sign' => $responseData['Sign'], - 'wpAmount' => 0, - 'mac' => 'oE7zwV87uOc2DFpGPlr4jQRQ0z9LsxGw56c7vaiZkTo=', + 'bankData' => $responseData['BankPacket'], + 'merchantData' => $responseData['MerchantPacket'], + 'sign' => $responseData['Sign'], + 'wpAmount' => 0, + 'mac' => 'oE7zwV87uOc2DFpGPlr4jQRQ0z9LsxGw56c7vaiZkTo=', ], ]; } /** * @param PosNetAccount $account - * @param array $responseData + * @param array $responseData * * @return array */ private function getSampleResolveMerchantDataXMLData($account, array $responseData) { return [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), 'oosResolveMerchantData' => [ - 'bankData' => $responseData['BankPacket'], - 'merchantData' => $responseData['MerchantPacket'], - 'sign' => $responseData['Sign'], - 'mac' => 'oE7zwV87uOc2DFpGPlr4jQRQ0z9LsxGw56c7vaiZkTo=', + 'bankData' => $responseData['BankPacket'], + 'merchantData' => $responseData['MerchantPacket'], + 'sign' => $responseData['Sign'], + 'mac' => 'oE7zwV87uOc2DFpGPlr4jQRQ0z9LsxGw56c7vaiZkTo=', ], ]; } /** - * @param $order + * @param $order * @param PosNetAccount $account * * @return array @@ -358,16 +381,16 @@ private function getSampleResolveMerchantDataXMLData($account, array $responseDa private function getSampleStatusXMLData($order, $account) { return [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), 'agreement' => [ - 'orderID' => $order->id, + 'orderID' => $order->id, ], ]; } /** - * @param $order + * @param $order * @param PosNetAccount $account * * @return array @@ -375,11 +398,11 @@ private function getSampleStatusXMLData($order, $account) private function getSampleCancelXMLData($order, $account) { $requestData = [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), - 'tranDateRequired' => '1', - 'reverse' => [ - 'transaction' => 'sale', + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), + 'tranDateRequired' => '1', + 'reverse' => [ + 'transaction' => 'sale', ], ]; @@ -389,11 +412,12 @@ private function getSampleCancelXMLData($order, $account) } else { $requestData['reverse']['orderID'] = PosNet::mapOrderIdToPrefixedOrderId($order->id, $account->getModel()); } + return $requestData; } /** - * @param $order + * @param $order * @param PosNetAccount $account * * @return array @@ -401,12 +425,12 @@ private function getSampleCancelXMLData($order, $account) private function getSampleRefundXMLData($order, $account) { $requestData = [ - 'mid' => $account->getClientId(), - 'tid' => $account->getTerminalId(), - 'tranDateRequired' => '1', - 'return' => [ - 'amount' => $order->amount, - 'currencyCode' => $order->currency, + 'mid' => $account->getClientId(), + 'tid' => $account->getTerminalId(), + 'tranDateRequired' => '1', + 'return' => [ + 'amount' => $order->amount, + 'currencyCode' => $order->currency, ], ];