An order represents a payment between two or more parties. and inorder to create a new order we must send an OrderCreateRequest to PayPal API.
usePayPal\Checkout\Requests\OrderCreateRequest;usePayPal\Checkout\Orders\AmountBreakdown;usePayPal\Checkout\Orders\Item;usePayPal\Checkout\Orders\Order;usePayPal\Checkout\Orders\PurchaseUnit;// Create a purchase unit with the total amount$purchase_unit =newPurchaseUnit(AmountBreakdown::of('200.00','USD'));// Create & add item to purchase unit$purchase_unit->addItem(Item::make('Item 1','100.00','USD',1));$purchase_unit->addItem(Item::make('Item 2','100.00','USD',1));// Create a new order with intent to capture a payment$order = (newOrder())->addPurchaseUnit($purchase_unit);// Send request to PayPal$response = $client->send(newOrderCreateRequest($order));// Get results$result =json_decode($response->getBody()->getContents());
A successful request returns the HTTP 201 Created status code and a JSON response body that includes by default a minimal response with the ID, status, and HATEOAS links.