From 11d9a0d5a73aa3fcd4561a73caf49b24256334f5 Mon Sep 17 00:00:00 2001 From: jlttt Date: Wed, 15 Nov 2017 14:02:13 +0100 Subject: [PATCH 1/3] add shipping preference options to RestPurchaseRequest --- src/Message/RestPurchaseRequest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Message/RestPurchaseRequest.php b/src/Message/RestPurchaseRequest.php index 75b0100..adb295a 100644 --- a/src/Message/RestPurchaseRequest.php +++ b/src/Message/RestPurchaseRequest.php @@ -227,6 +227,17 @@ 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'); + } + + public function setShippingPreference($value) + { + return $this->setParameter('shippingPreference', $value); + } } From b9a681ff483adc24f074118e94dea10fd38dd624 Mon Sep 17 00:00:00 2001 From: jlttt Date: Wed, 7 Feb 2018 21:36:50 +0100 Subject: [PATCH 2/3] add comments on supported shipping preference values --- src/Message/RestPurchaseRequest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Message/RestPurchaseRequest.php b/src/Message/RestPurchaseRequest.php index adb295a..0a263b4 100644 --- a/src/Message/RestPurchaseRequest.php +++ b/src/Message/RestPurchaseRequest.php @@ -236,6 +236,22 @@ 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); From 456f758e010468a544e23a0dbec3eb5294d3f36f Mon Sep 17 00:00:00 2001 From: jlttt Date: Wed, 7 Feb 2018 22:58:11 +0100 Subject: [PATCH 3/3] add shipping preference constant --- src/Message/RestPurchaseRequest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Message/RestPurchaseRequest.php b/src/Message/RestPurchaseRequest.php index 0a263b4..6f12d29 100644 --- a/src/Message/RestPurchaseRequest.php +++ b/src/Message/RestPurchaseRequest.php @@ -223,6 +223,10 @@ */ 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();