devfunkd
devfunkd

Reputation: 3234

Square Connect API - Invoice not showing up

I started developing with the Square Connect API and I am able to generate an invoice without any errors using the following code, yet the invoice never shows up when I log into the dashboard?

 var item = new CreateOrderRequestLineItem("Test 1", "1", new Money(100, Money.CurrencyEnum.CAD));

        var items = new List<CreateOrderRequestLineItem>()
        {
            item
        };

        CreateOrderRequest orderRequest = new CreateOrderRequest(NewIdempotencyKey(), null, items);

        OrdersApi ordersApi = new OrdersApi
        {
            Configuration = { AccessToken = AccessToken() }
        };

        try
        {
            var response = ordersApi.CreateOrder(LocationId(), orderRequest);
            var id = response.Order.Id;
            //result =  "Transaction complete\n" + response.ToJson();
        }
        catch (ApiException e)
        {
            Console.WriteLine(e.Message);
        }

Am I missing something here or should the invoice not show up? Basically I want my aspnet mvc web app to generate an invoice in Square that can be loaded and handled in the app.

Upvotes: 1

Views: 850

Answers (1)

sjosey
sjosey

Reputation: 1348

The Orders API creates an order that is meant to be attached to either a Charge or CreateCheckout endpoint. After that, the order_id would appear in the Transaction object (that can be retrieved either by ListTransactions or RetrieveTransaction).

If you do not pass the order_id to the Charge or CreateCheckout endpoints, it is only viewable by BatchRetrieveOrders endpoint.

Furthermore - this will not create an invoice (there is currently no Invoices API). The Orders API is intended to itemize your transactions. Without it, your transactions would just show "Custom Amount" in the dashboard, and would have no items associated with it. After creating an order, it is intended to be used immediately.

Reference: https://docs.connect.squareup.com/articles/orders-api-overview#how-to-use-it-the-orders-api-data-model

https://docs.connect.squareup.com/api/connect/v2#endpoint-createorder

Upvotes: 1

Related Questions