From cb5f36cc8a9af16833f0397b823d587db3acb168 Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Fri, 21 Jul 2017 17:17:03 +0100 Subject: [PATCH] Issue #9 Remove PEDNING from the "successful" final payment state. A test has been added for this too. --- src/Message/CheckoutPageComplete.php | 4 +-- tests/Message/CheckoutPageCompleteTest.php | 34 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Message/CheckoutPageComplete.php b/src/Message/CheckoutPageComplete.php index 933f8fa..3db079e 100644 --- a/src/Message/CheckoutPageComplete.php +++ b/src/Message/CheckoutPageComplete.php @@ -229,10 +229,10 @@ public function isSuccessful() $paymentState = $this->getPaymentState(); - // There are four payment states. Two are successful. + // There are four payment states. + // Only "SUCCESS" indicates the transaction is successful AND complete. return ( $paymentState === AbstractResponse::PAYMENT_STATE_SUCCESS - || $paymentState === AbstractResponse::PAYMENT_STATE_PENDING ); } diff --git a/tests/Message/CheckoutPageCompleteTest.php b/tests/Message/CheckoutPageCompleteTest.php index aec4197..53949cf 100644 --- a/tests/Message/CheckoutPageCompleteTest.php +++ b/tests/Message/CheckoutPageCompleteTest.php @@ -99,4 +99,38 @@ public function testTimeout() $this->assertTrue($request->isValid()); $this->assertFalse($request->isSuccessful()); } + + public function testPending() + { + $httpRequest = $this->getHttpRequest(); + + $httpRequest->initialize( + array(), // GET + array( // POST + 'paymentType' => 'PAYPAL', + 'financialInstitution' => 'PayPal', + 'language' => 'de', + 'paymentState' => 'PENDING', + 'omnipay_transactionId' => '2147500162', + 'responseFingerprintOrder' => 'paymentType,financialInstitution,language,paymentState,omnipay_transactionId,secret,responseFingerprintOrder', + 'responseFingerprint' => 'ebf04ba2e87dd12c03eb889e523e453ae1db8ffd9fd3b5b6ca7c9f5c61763afc28f3eb318c009e0e193b2d3f5b655e3333247094ee86c0d531235f4661b19a51', + ) + ); + + $request = new CheckoutPageComplete($this->getHttpClient(), $httpRequest); + + // This secret is needed to validate the transaction. + $request->setSecret('DP4TMTPQQWFJW34647RM798E9A5X7E8ATP462Z4VGZK53YEJ3JWXS98B9P4F'); + + $this->assertTrue($request->isValid()); + $this->assertFalse($request->isSuccessful()); + + // Sending the request will get the same object back, and so we will have the + // same success result. + + $response = $request->send(); + + $this->assertTrue($request->isValid()); + $this->assertFalse($request->isSuccessful()); + } }