public function testCompletePurchase() { $soapResponse = PaymentStatusResponseTest::paymentStatusWithState(GopayHelper::CREATED); $this->soapClient->expects($this->once())->method('paymentStatus')->with($this->anything())->will($this->returnValue($soapResponse)); $this->getHttpRequest()->query->replace(array('targetGoId' => self::GO_ID, 'paymentSessionId' => '98765', 'orderNumber' => '111', 'encryptedSignature' => GopayHelper::getPaymentIdentitySignature(self::GO_ID, '98765', null, '111', self::SECURE_KEY))); $this->assertSame($soapResponse, $this->gateway->completePurchase(array())->send()->getData()); }
/** * Get the raw data array for this message. The format of this varies from gateway to * gateway, but will usually be either an associative array, or a SimpleXMLElement. * * @throws InvalidRequestException on signature mismatch * @return mixed */ public function getData() { $request = $this->httpRequest->query; $expectedSignature = GopayHelper::getPaymentIdentitySignature($request->get('targetGoId'), $request->get('paymentSessionId'), $request->get('parentPaymentSessionId'), $request->get('orderNumber'), $this->getSecureKey()); if ($expectedSignature != $request->get('encryptedSignature')) { throw new InvalidRequestException("Invalid response signature"); } return $request->all(); }
public function testSendSuccess() { $notificationParams = array('targetGoId' => 12345, 'paymentSessionId' => 1111, 'orderNumber' => 2222, 'encryptedSignature' => GopayHelper::getPaymentIdentitySignature(12345, 1111, null, 2222, GatewayTest::SECURE_KEY)); $paymentStatusParams = array('targetGoId' => 12345, 'paymentSessionId' => 1111, 'encryptedSignature' => GopayHelper::getPaymentSessionSignature(12345, 1111, GatewayTest::SECURE_KEY)); $paymentStatusResponse = PaymentStatusResponseTest::paymentStatusWithState(GopayHelper::CREATED); $this->getHttpRequest()->query->replace($notificationParams); $this->soapClient->expects($this->once())->method('paymentStatus')->with($paymentStatusParams)->will($this->returnValue($paymentStatusResponse)); $this->request = new CompletePurchaseRequest($this->soapClient, $this->getHttpClient(), $this->getHttpRequest()); $this->request->setGoId('12345'); $this->request->setSecureKey(GatewayTest::SECURE_KEY); $response = $this->request->send(); $this->assertSame($paymentStatusResponse, $response->getData()); }
print_r($purchaseData); $purchaseResponse = null; try { $purchaseResponse = $gateway->purchase($purchaseData)->send(); echo $gateway->getSoapClient()->__getLastRequest(); } catch (Exception $e) { echo $gateway->getSoapClient()->__getLastRequest(); throw $e; } echo "Received response:"; print_r($purchaseResponse->getData()); if (!$purchaseResponse->isSuccessful() && !$purchaseResponse->isRedirect()) { print "Response is not successful and not a redirect: " . $purchaseResponse->getMessage(); exit(1); } // Simulate notification $_GET['paymentSessionId'] = $purchaseResponse->getData()->paymentSessionId; $_GET['targetGoId'] = $purchaseResponse->getData()->targetGoId; $_GET['orderNumber'] = $purchaseResponse->getData()->orderNumber; $_GET['encryptedSignature'] = GopayHelper::getPaymentIdentitySignature($_GET['targetGoId'], $_GET['paymentSessionId'], null, $_GET['orderNumber'], $secureKey); // Recreate gateway to pick up the GET parameters $gateway = createGateway($goId, $secureKey); try { $completePurchaseResponse = $gateway->completePurchase()->send(); echo $gateway->getSoapClient()->__getLastRequest(); } catch (Exception $e) { echo $gateway->getSoapClient()->__getLastRequest(); throw $e; } echo "Received response to completePurchase (payment status):"; print_r($completePurchaseResponse->getData());