diff --git a/src/Gateway.php b/src/Gateway.php index f82e988..aed2aea 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -22,7 +22,7 @@ public function getDefaultParameters() return [ 'merchantKey' => '', 'merchantCode' => '', - 'backendUrl' => '' + 'backendUrl' => '', ]; } @@ -66,4 +66,4 @@ public function completePurchase(array $parameters = array()) return $this->createRequest('\Omnipay\IPay88\Message\CompletePurchaseRequest', $parameters); } -} \ No newline at end of file +} diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index ce41efd..715e1bc 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -49,15 +49,15 @@ protected function guardParameters() protected function createSignatureFromString($fullStringToHash) { - return base64_encode($this->hex2bin(sha1($fullStringToHash))); - } - - private function hex2bin($hexSource) - { - $bin = ''; - for ($i = 0; $i < strlen($hexSource); $i = $i + 2) { - $bin .= chr(hexdec(substr($hexSource, $i, 2))); - } - return $bin; - } -} \ No newline at end of file + return hash('sha256', $fullStringToHash); + } + + // private function hex2bin($hexSource) + // { + // $bin = ''; + // for ($i = 0; $i < strlen($hexSource); $i = $i + 2) { + // $bin .= chr(hexdec(substr($hexSource, $i, 2))); + // } + // return $bin; + // } +} diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index fe510dc..771835e 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -2,12 +2,9 @@ namespace Omnipay\IPay88\Message; - -use Omnipay\Common\Currency; - class CompletePurchaseRequest extends AbstractRequest { - protected $endpoint = 'https://www.mobile88.com/epayment/enquiry.asp'; + protected $endpoint = 'https://payment.ipay88.com.my/epayment/entry.asp'; public function getData() { @@ -31,11 +28,11 @@ public function getData() public function sendData($data) { $data['ReQueryStatus'] = $this->httpClient - ->request('post', $this->endpoint.'?'.http_build_query([ + ->request('post', $this->endpoint . '?' . http_build_query([ 'MerchantCode' => $this->getMerchantCode(), 'RefNo' => $data['RefNo'], - 'Amount' => $data['Amount'] - ]), [], json_encode([])) + 'Amount' => $data['Amount'], + ]), [], json_encode([])) ->getBody() ->getContents(); diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 3281c2a..5c9f869 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -2,7 +2,6 @@ namespace Omnipay\IPay88\Message; - class PurchaseRequest extends AbstractRequest { public function getData() @@ -21,6 +20,7 @@ public function getData() 'UserContact' => $this->getCard()->getNumber(), 'Remark' => '', 'Lang' => '', + 'SignatureType' => 'SHA256', 'Signature' => $this->signature( $this->getMerchantKey(), $this->getMerchantCode(), @@ -47,4 +47,4 @@ private function signature($merchantKey, $merchantCode, $refNo, $amount, $curren return $this->createSignatureFromString(implode('', $paramsInArray)); } -} \ No newline at end of file +} diff --git a/src/Message/PurchaseResponse.php b/src/Message/PurchaseResponse.php index 3321bfe..f8c6659 100644 --- a/src/Message/PurchaseResponse.php +++ b/src/Message/PurchaseResponse.php @@ -2,12 +2,11 @@ namespace Omnipay\IPay88\Message; - use Omnipay\Common\Message\AbstractResponse; class PurchaseResponse extends AbstractResponse { - protected $endpoint = 'https://www.mobile88.com/ePayment/entry.asp'; + protected $endpoint = 'https://payment.ipay88.com.my/epayment/entry.asp'; public function getTransactionId() { @@ -44,4 +43,4 @@ public function getRedirectData() return $this->data; } -} \ No newline at end of file +}