Skip to content

Commit 5379a83

Browse files
Add test for Refine handling of 'card' parameter to support generic integrations.
In a generic integration the card parameter might exist to hold billing address details even when the card number is not provided. We don't expect the integration to hold knowledge that 'paypal rest won't work if you pass a 'card' paramter when you are pre-authorizing a token' so we should look more deeply into the passed card parameter for the presence of the actual card fields - ie. card number, expiry ,cvv
1 parent 46e583b commit 5379a83

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/Message/RestAuthorizeRequestTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,33 @@ public function testGetDataWithoutCard()
4747
$this->assertSame('https://www.example.com/cancel', $data['redirect_urls']['cancel_url']);
4848
}
4949

50+
/**
51+
* This tests that having a card object with no card details acts as 'no card'.
52+
*
53+
* We may have a card object holding billing details but no card details. This
54+
* should be treated as a card-not-present rather than as invalid.
55+
*/
56+
public function testGetDataWitLimitedCard()
57+
{
58+
$this->request->setTransactionId('abc123');
59+
$this->request->setDescription('Sheep');
60+
$this->request->setCard(new CreditCard(['firstName' => 'Example']));
61+
62+
$data = $this->request->getData();
63+
64+
$this->assertSame('authorize', $data['intent']);
65+
$this->assertSame('paypal', $data['payer']['payment_method']);
66+
$this->assertSame('10.00', $data['transactions'][0]['amount']['total']);
67+
$this->assertSame('USD', $data['transactions'][0]['amount']['currency']);
68+
$this->assertSame('abc123 : Sheep', $data['transactions'][0]['description']);
69+
70+
// Funding instruments must not be set, otherwise paypal API will give error 500.
71+
$this->assertArrayNotHasKey('funding_instruments', $data['payer']);
72+
73+
$this->assertSame('https://www.example.com/return', $data['redirect_urls']['return_url']);
74+
$this->assertSame('https://www.example.com/cancel', $data['redirect_urls']['cancel_url']);
75+
}
76+
5077
public function testGetDataWithCard()
5178
{
5279
$card = new CreditCard($this->getValidCard());

0 commit comments

Comments
 (0)