Skip to content

Commit 67efe5a

Browse files
committed
Merge pull request #65 from PatronBase/master
Add pending transaction support
2 parents c83e735 + 79e4270 commit 67efe5a

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

src/Message/AbstractRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
3232
{
33-
const API_VERSION = '85.0';
33+
const API_VERSION = '119.0';
3434

3535
protected $liveEndpoint = 'https://api-3t.paypal.com/nvp';
3636
protected $testEndpoint = 'https://api-3t.sandbox.paypal.com/nvp';

src/Message/Response.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public function __construct(RequestInterface $request, $data)
1616
parse_str($data, $this->data);
1717
}
1818

19+
public function isPending()
20+
{
21+
return isset($this->data['PAYMENTINFO_0_PAYMENTSTATUS'])
22+
&& $this->data['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Pending';
23+
}
24+
1925
public function isSuccessful()
2026
{
2127
return isset($this->data['ACK']) && in_array($this->data['ACK'], array('Success', 'SuccessWithWarning'));

tests/ExpressGatewayTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function testAuthorizeSuccess()
4444
$response = $this->gateway->authorize($this->options)->send();
4545

4646
$this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressAuthorizeResponse', $response);
47+
$this->assertFalse($response->isPending());
4748
$this->assertFalse($response->isSuccessful());
4849
$this->assertTrue($response->isRedirect());
4950
$this->assertEquals('https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
@@ -55,6 +56,7 @@ public function testAuthorizeFailure()
5556

5657
$response = $this->gateway->authorize($this->options)->send();
5758

59+
$this->assertFalse($response->isPending());
5860
$this->assertFalse($response->isSuccessful());
5961
$this->assertFalse($response->isRedirect());
6062
$this->assertNull($response->getTransactionReference());
@@ -68,6 +70,7 @@ public function testPurchaseSuccess()
6870
$response = $this->gateway->purchase($this->options)->send();
6971

7072
$this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressAuthorizeResponse', $response);
73+
$this->assertFalse($response->isPending());
7174
$this->assertFalse($response->isSuccessful());
7275
$this->assertTrue($response->isRedirect());
7376
$this->assertEquals('https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
@@ -79,6 +82,7 @@ public function testPurchaseFailure()
7982

8083
$response = $this->gateway->purchase($this->options)->send();
8184

85+
$this->assertFalse($response->isPending());
8286
$this->assertFalse($response->isSuccessful());
8387
$this->assertFalse($response->isRedirect());
8488
$this->assertNull($response->getTransactionReference());

tests/Message/ExpressAuthorizeResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function testExpressPurchaseSuccess()
2121
$request->shouldReceive('getTestMode')->once()->andReturn(true);
2222
$response = new ExpressAuthorizeResponse($request, $httpResponse->getBody());
2323

24+
$this->assertFalse($response->isPending());
2425
$this->assertFalse($response->isSuccessful());
2526
$this->assertSame('EC-42721413K79637829', $response->getTransactionReference());
2627
$this->assertNull($response->getMessage());
@@ -34,6 +35,7 @@ public function testExpressPurchaseFailure()
3435
$httpResponse = $this->getMockHttpResponse('ExpressPurchaseFailure.txt');
3536
$response = new ExpressAuthorizeResponse($this->getMockRequest(), $httpResponse->getBody());
3637

38+
$this->assertFalse($response->isPending());
3739
$this->assertFalse($response->isSuccessful());
3840
$this->assertNull($response->getTransactionReference());
3941
$this->assertNull($response->getTransactionReference());

tests/Message/ExpressFetchCheckoutRequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function testSendSuccess()
5454
$this->setMockHttpResponse('ExpressFetchCheckoutSuccess.txt');
5555

5656
$response = $this->request->send();
57+
$this->assertFalse($response->isPending());
5758
$this->assertTrue($response->isSuccessful());
5859
$this->assertFalse($response->isRedirect());
5960
}
@@ -63,6 +64,7 @@ public function testSendFailure()
6364
$this->setMockHttpResponse('ExpressFetchCheckoutFailure.txt');
6465

6566
$response = $this->request->send();
67+
$this->assertFalse($response->isPending());
6668
$this->assertFalse($response->isSuccessful());
6769
$this->assertFalse($response->isRedirect());
6870
$this->assertSame('The amount exceeds the maximum amount for a single transaction.', $response->getMessage());

tests/Message/ResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function testProPurchaseSuccess()
1818
$httpResponse = $this->getMockHttpResponse('ProPurchaseSuccess.txt');
1919
$response = new Response($this->getMockRequest(), $httpResponse->getBody());
2020

21+
$this->assertFalse($response->isPending());
2122
$this->assertTrue($response->isSuccessful());
2223
$this->assertSame('96U93778BD657313D', $response->getTransactionReference());
2324
$this->assertNull($response->getMessage());
@@ -28,6 +29,7 @@ public function testProPurchaseFailure()
2829
$httpResponse = $this->getMockHttpResponse('ProPurchaseFailure.txt');
2930
$response = new Response($this->getMockRequest(), $httpResponse->getBody());
3031

32+
$this->assertFalse($response->isPending());
3133
$this->assertFalse($response->isSuccessful());
3234
$this->assertNull($response->getTransactionReference());
3335
$this->assertSame('This transaction cannot be processed. Please enter a valid credit card expiration year.', $response->getMessage());

0 commit comments

Comments
 (0)