From cf64387eb7245c7e171c48f3d84ac90cb6b70cbd Mon Sep 17 00:00:00 2001 From: Li Chuangbo Date: Mon, 10 Oct 2016 17:28:33 +1300 Subject: [PATCH] Allow pass token as param for complete purchase This enables the complete purchase request to accept a parameter `token`. It is useful when we did not receive the notifications from POLi and we can __notify__ by ourself in the crontab. $proxy->completePurchase(['token' => $token])->send(); --- src/Message/CompletePurchaseRequest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index d7aab5c..78dbe25 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -23,7 +23,12 @@ public function getData() 'authenticationCode' ); - $token = $this->httpRequest->query->get('token'); + $token = $this->getToken(); + + if (!$token) { + $token = $this->httpRequest->query->get('token'); + } + if (!$token) { //this may be a POST nudge request, so look for the token there $token = $this->httpRequest->request->get('Token'); @@ -52,4 +57,9 @@ public function sendData($data) return $this->response = new CompletePurchaseResponse($this, $httpResponse->getBody()); } + + public function getToken() + { + return $this->getParameter('token'); + } }