Skip to content

Commit

Permalink
Issue #9 Remove PEDNING from the "successful" final payment state.
Browse files Browse the repository at this point in the history
A test has been added for this too.
  • Loading branch information
judgej committed Jul 21, 2017
1 parent 0089d05 commit cb5f36c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Message/CheckoutPageComplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
34 changes: 34 additions & 0 deletions tests/Message/CheckoutPageCompleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit cb5f36c

Please sign in to comment.