Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhooks plus shipping preference #4

Merged
merged 7 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Message/RestPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,41 @@
*/
class RestPurchaseRequest extends RestAuthorizeRequest
{
const SHIPPING_PREFERENCE_NO_SHIPPING = 'NO_SHIPPING';
const SHIPPING_PREFERENCE_GET_FROM_FILE = 'GET_FROM_FILE';
const SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS= 'SET_PROVIDED_ADDRESS';

public function getData()
{
$data = parent::getData();
$data['intent'] = 'sale';
$data['application_context']['shipping_preference'] = $this->getShippingPreference();
return $data;
}

public function getShippingPreference()
{
return $this->getParameter('shippingPreference');
}

/**
* Set the shipping preference
*
* Supported values:
* 'NO_SHIPPING': redacts shipping address fields from the PayPal pages.
* Recommended value to use for digital goods.
* 'GET_FROM_FILE': Get the shipping address selected by the buyer on PayPal pages.
* 'SET_PROVIDED_ADDRESS' (not yet fully supported by the library since shipping address can't be provided):
* Use the address provided by the merchant. Buyer is not able to change the address on the PayPal pages.
* If merchant doesn't pass an address, buyer has the option to choose the address on PayPal pages.
*
* @param string $value
* @return bool.
* @link https://developer.paypal.com/docs/api/orders/#definition-application_context
* @link https://www.paypalobjects.com/api/checkout.js
*/
public function setShippingPreference($value)
{
return $this->setParameter('shippingPreference', $value);
}
}
2 changes: 1 addition & 1 deletion tests/ProGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setUp()
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '12',
'expiryYear' => '2017',
'expiryYear' => '2019',
digibeuk marked this conversation as resolved.
Show resolved Hide resolved
'cvv' => '123',
)),
);
Expand Down
2 changes: 1 addition & 1 deletion tests/RestGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setUp()
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '12',
'expiryYear' => '2017',
'expiryYear' => '2019',
digibeuk marked this conversation as resolved.
Show resolved Hide resolved
'cvv' => '123',
)),
);
Expand Down