I’m currently using square/connect-php-sdk createOrder to create a Square Order.
$api_config = new SquareConnectConfiguration(); $api_config->setAccessToken($access_token); $api_config->setHost($host); $api_client = new SquareConnectApiClient($api_config); $apiInstance = new SquareConnectApiOrdersApi($api_client); $orderRequest = new SquareConnectModelCreateOrderRequest(); $orderRequest->setIdempotencyKey(uniqid()); $order = new SquareConnectModelOrder(); $money = new SquareConnectModelMoney(); $money->setAmount(intval(500)) ->setCurrency("USD"); $line_item = new SquareConnectModelOrderLineItem(); $line_item->setCatalogObjectId(<square item id>) ->setQuantity("1") ->setBasePriceMoney($money); $line_items[] = $line_item; $order->setLineItems($line_items); $orderRequest->setOrder($order); $result = $apiInstance->createOrder($location_id, $orderRequest);
This returns an Order ID (along with other order data) which I store locally. I then process a credit card using the Square Payment Form: https://developer.squareup.com/docs/payment-form/payment-form-walkthrough
This gives me a nonce which I then send with the Order ID and the price.
$apiInstance = new SquareConnectApiPaymentsApi($api_client); $paymentRequest = new SquareConnectModelCreatePaymentRequest(); $paymentRequest->setIdempotencyKey(uniqid()); $paymentRequest->setLocationId($location_id); $money = new SquareConnectModelMoney(); $money->setAmount(intval($total_cost)) ->setCurrency("USD"); $paymentRequest->setAmountMoney($money); $paymentRequest->setOrderId($sq_order_id); $paymentRequest->setSourceId($nonce); $result = $apiInstance->createPayment($paymentRequest);
This gives me a Payment ID (along with other payment data). On the Square Dashboard, I am able to see the transaction in the Transactions section, but the Orders section of the dashboard is empty.
My question is How do I get it to show in the Orders section?
Advertisement
Answer
In order for the order to show up in your dashboard you need to do two things:
1. Pay for the order (it sounds like you did this part)
2. Include a fulfillments
parameter in the CreateOrder
request: https://developer.squareup.com/docs/orders-api/order-ahead-usecase#add-fulfillment-information-to-make-a-pickup-order