Skip to content

Commit 16bbfd9

Browse files
committed
feat: add shipping preference option to RestPurchaseRequest
1 parent dbd8508 commit 16bbfd9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Message/RestPurchaseRequest.php

+31
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,41 @@
223223
*/
224224
class RestPurchaseRequest extends RestAuthorizeRequest
225225
{
226+
const SHIPPING_PREFERENCE_NO_SHIPPING = 'NO_SHIPPING';
227+
const SHIPPING_PREFERENCE_GET_FROM_FILE = 'GET_FROM_FILE';
228+
const SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS= 'SET_PROVIDED_ADDRESS';
229+
226230
public function getData()
227231
{
228232
$data = parent::getData();
229233
$data['intent'] = 'sale';
234+
$data['application_context']['shipping_preference'] = $this->getShippingPreference();
230235
return $data;
231236
}
237+
238+
public function getShippingPreference()
239+
{
240+
return $this->getParameter('shippingPreference');
241+
}
242+
243+
/**
244+
* Set the shipping preference
245+
*
246+
* Supported values:
247+
* 'NO_SHIPPING': redacts shipping address fields from the PayPal pages.
248+
* Recommended value to use for digital goods.
249+
* 'GET_FROM_FILE': Get the shipping address selected by the buyer on PayPal pages.
250+
* 'SET_PROVIDED_ADDRESS' (not yet fully supported by the library since shipping address can't be provided):
251+
* Use the address provided by the merchant. Buyer is not able to change the address on the PayPal pages.
252+
* If merchant doesn't pass an address, buyer has the option to choose the address on PayPal pages.
253+
*
254+
* @param string $value
255+
* @return bool.
256+
* @link https://developer.paypal.com/docs/api/orders/#definition-application_context
257+
* @link https://www.paypalobjects.com/api/checkout.js
258+
*/
259+
public function setShippingPreference($value)
260+
{
261+
return $this->setParameter('shippingPreference', $value);
262+
}
232263
}

0 commit comments

Comments
 (0)