question

Ghalib Soomro avatar image
Ghalib Soomro asked ·

Payments with order type

how can we get order types while fetching payments using REST API
PaymentsREST API
3 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Do you mean to fetch payments made against orders with a specific order type (for example, all payments made on "to go" or "dine in" orders) or are you trying to just fetch a single payment and get the order type of the order the payment was made on?

0 Likes 0 · ·
and please guide me how can i get order types while fetching all payments.... i want to get order types in payments query ....
0 Likes 0 · ·

1 Answer

zgreathouse avatar image
zgreathouse answered ·
On this endpoint you need to also the pass in the actually orderType.id
(You can review our docs on utilizing filters here)

For example:
{baseUrl}/v3/merchants/{merchantId}/payments?expand=lineItemPayments&filter=orderType.id={orderTypeId)

If you are having trouble finding the orderTypes's id, use the following endpoint to view your different orderTypes (each object includes their id):
{baseUrl}/v3/merchants/{merchantId}/order_types

A solution to what you are looking to accomplish may be to fetch orders of a specific orderType and to expand the orderType and payments fields. This way you can get both payment and order data. See example endpoint below:
<em>{baseUrl}/v3/merchants/{merchantId}/orders?filter=orderType={orderTypeId}&expand=orderType,payments</em>

(To your question regarding getting the orderType when fetching payments:
There is no orderType field on a payment object, so this information cannot be fetched with the payments endpoint. That information belongs to the order the payment was made against. You can get the orderType, by fetching the order the payment belongs to. Each payment has an Order field which houses the reference ID to fetch the order.)
Share
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community