* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @copyright PayPal */ namespace PaypalAddons\services\Builder; class OrderPatchBody extends OrderCreateBody { public function build() { $body = []; $currency = $this->getCurrency(); $productItmes = $this->getProductItems($currency); $wrappingItems = $this->getWrappingItems($currency); $items = array_merge($productItmes, $wrappingItems); $shippingInfo = $this->getShippingInfo(); $body[] = [ 'op' => 'replace', 'path' => '/purchase_units/@reference_id==\'default\'', 'value' => [ 'amount' => $this->getAmount($currency), 'items' => $items, 'custom_id' => $this->getCustomId(), ], ]; if (false === empty($shippingInfo)) { $body[0]['value']['shipping'] = $shippingInfo; } return $body; } }