Shippable Orders not showing when creating payment links

I have the code below that I am using to build out an ecommerce website. Fulfillment Recipient and Address are hard coded for testing purposes.

The payment link is created successfully and does show up in the Transactions section of the Square Dashboard. Problem is that the order does not show up in the Orders section of the Square Dashboard. Please advise what may be wrong and why is the order information not showing up on the Dashboard?

Also, if the user enters their shipping information on the payment link page, is it not added to the order?

$client = new SquareClient([
    'accessToken' => 'REDACTED',
    // 'accessToken' => getenv('SQUARE_ACCESS_TOKEN'),
    'environment' => Environment::SANDBOX,
]);
$locationId = "REDACTED";
$postCheckoutUrl = 'http://127.0.0.1:8080/c2.php';
$merchantEmail = "[email protected]";

$json = $_POST['cartContents'];
$cartContents = json_decode($json);

$lineItems = array();
foreach ($cartContents as $item) {
    $basePriceMoney = new \Square\Models\Money();

    $amount = $item->price * 100;
    $basePriceMoney->setAmount($amount);
    $basePriceMoney->setCurrency('USD');

    $orderLineItem = new \Square\Models\OrderLineItem($item->quantity);
    $orderLineItem->setUid($item->id);
    $orderLineItem->setName($item->name);
    $orderLineItem->setNote($item->description);
    $orderLineItem->setItemType(OrderLineItemItemType::ITEM);
    $orderLineItem->setBasePriceMoney($basePriceMoney);

    array_push($lineItems, $orderLineItem);
}

$fulfillmentAddress = new \Square\Models\Address();
$fulfillmentAddress->setAddressLine1("123 Main Street");
$fulfillmentAddress->setLocality("Anywhere");
$fulfillmentAddress->setAdministrativeDistrictLevel1("Alabama");
$fulfillmentAddress->setPostalCode("44234");
$fulfillmentAddress->setCountry("US");

$fulfillmentRecipient = new FulfillmentRecipient();
$fulfillmentRecipient->setDisplayName("John Doe");
$fulfillmentRecipient->setAddress($fulfillmentAddress);
$fulfillmentRecipient->setPhoneNumber("555-555-5555");

$shipment_details = new FulfillmentShipmentDetails();
$shipment_details->setRecipient($fulfillmentRecipient);

$fulfillment = new Fulfillment();
$fulfillment->setType(OrderFulfillmentType::SHIPMENT);
$fulfillment->setShipmentDetails($shipment_details);
$fulfillment->setState(OrderFulfillmentState::PROPOSED);
$fulfillments = [$fulfillment];

$orderSource = new OrderSource();
$orderSource->setName("website");

$order = new \Square\Models\Order($locationId);
$order->setLineItems($lineItems);
$order->setFulfillments($fulfillments);
$order->setSource($orderSource);

$checkout_options = new \Square\Models\CheckoutOptions();
$checkout_options->setAllowTipping(false);
$checkout_options->setRedirectUrl($postCheckoutUrl);
$checkout_options->setAskForShippingAddress(true);
$checkout_options->setEnableCoupon(true);
$checkout_options->setMerchantSupportEmail($merchantEmail);
$checkout_options->setEnableCoupon(true);

$paymentLink = new \Square\Models\CreatePaymentLinkRequest();
$idempotencyKey = uniqid();
$paymentLink->setIdempotencyKey($idempotencyKey);
$paymentLink->setOrder($order);
$paymentLink->setCheckoutOptions($checkout_options);

$createPaymentLinkResponse = $client->getCheckoutApi()->createPaymentLink($paymentLink);

if ($createPaymentLinkResponse->isSuccess()) {
    $result = $createPaymentLinkResponse->getResult();
    header("Location: " . $result->getPaymentLink()->getUrl());
} else {
    $errors = $createPaymentLinkResponse->getErrors();
    echo "Unexpected error occurred";
    error_log(print_r($errors));
}
exit();

Orders and payments will show in the Dashboard once they’re fully paid for. Any payment link that’s created with the API with a fulfillment will need to be paid for before it’s visible in the Square Seller Dashboard. :slightly_smiling_face:

The test payment is showing up in the Transactions section on the Square Dashboard, but it is not showing up under Orders even with the fulfillment information entered.

Thus asking if the code I have provided is correct or is there something missing? If i am not able to show the client the orders with the fulfillment entered, then the API will not serve the needs the client has.

What’s the order_id with a fulfillment that’s not showing in the Dashboard. :slightly_smiling_face:

9a5SjCbpfXdEwRCiglWtZ5g4FgXZY and DbU0RgrG9zFlI0fsZG8tHgsc36EZY are the order IDs in the Sandbox environment that are not showing in the dashboard.

@Bryan-Square any update on this?

Looking at the Sandbox Seller Dashboard I see order DbU0RgrG9zFlI0fsZG8tHgsc36EZY in the orders section of the Dashboard. For 9a5SjCbpfXdEwRCiglWtZ5g4FgXZY its not paid for which is why its not showing in the Seller Dashboard. :slightly_smiling_face: