Happening now! Exclusive AMA: Streamlining Fulfillment and Delivery with Shopify Experts | Ask your questions to be answered by our team!

Re: Shopify and Stripe Order ID

Shopify and Stripe Order ID

jarrydmoore
New Member
4 0 0

I'm trying to match up Shopify transactions in our Stripe account to their relevant Shopify orders.

Shopify adds the following metadata fields to the transaction in Stripe:

  • shop_id
  • shop_name
  • manual_entry
  • order_id

 

So it appears that you should be able to match the transactions between the two systems using the order ID, however the order_id data going into Stripe does not match the order ID in Shopify. They're not even I the same format. The order ID in Shopify is in the format ############# but the format in the Stripe metadata field is p.#############.1 (the numbers in between do not match the Shopify order ID).

Are these meant to be the same or am I missing something?
Replies 6 (6)

csam
Shopify Staff (Retired)
267 40 51

Hi @jarrydmoore 

 

The order IDs between the two systems are distinct. You can view the Stripe ID in the order timeline on the page for each order. This is a current limitation of the platform that we are aware of.

 

Kind Regards,

To learn more visit the Shopify Help Center or the Community Blog.

jarrydmoore
New Member
4 0 0

@csam Is there field that Shopify can return via API that will let us identify which Stripe payment it belongs to?

Obviously Shopify knows which Stripe payment belongs to each order - it needs to for refunds, etc. Surely there's a way to get this data?

GrahamS
Shopify Staff (Retired)
193 37 54

Hey @jarrydmoore ,

 

Shopify doesn't technically host gateway-side details as dedicated fields within the order or transaction json. We create ids associated with these interactions for our own use, but they are not 1:1 copies of the ids used on the payment gateway side.

 

That said, you can typically query the "receiptJson" field in graphQL to gather the gateway specific data that Shopify receives from any non-shopify payments gateway. The receiptJson field will contain the unique id associated with the transaction that's held on the gateway side. In the case of Stripe, I believe its "charge id" but it would be worth double checking by calling for that field on your shop.

 

Example:

 

query {
	orders(first: 5) {
		edges {
			node {
				id
				name
				transactions(first: 5) {
					id
					receiptJson
				}
			}
		}
	}
}

 

 

To learn more visit the Shopify Help Center or the Community Blog.

jeffthemaximum
Tourist
4 0 1

So I'm newish to Shopify, but I'm having the same issue. But, I think I may have found a working solution. I'm not sure if this is guaranteed to always work - just reporting what I noticed.

The order object I get from shopify has a checkout_id field. It has a value of aMadeUpCheckoutId, for example.


My order_id metafield I see on the stripe transaction has the format caMadeUpCheckoutId.1.

So if the shopify checkout_id field was 123def456abc, then I see an order_id metafield in stripe of c123def456abc.1

SpeakTextOnline
Tourist
5 0 1

Hi,

You can use https://SpeakTextOnline.com which provides Shopify & Stripe tool that allows to get Shopify orders IDs in Stripe payments reports.


Plus this tool has expo
rting functionality in multiple formats such PDF, CSV, etc..

 

For any questions, feel free to contact at info@speaktextonline.com

 

shopify_stripe_input.png

shopify_stripe_output.png

 

 

Thanks,
Khaled

Khaled Alam | https://linkedin.com/in/khaledalam/
email: info@speaktextonline.com
website: https://SpeakTextOnline.com

Ashish_Soni
Excursionist
18 0 2

Jarrydmoore this is how you can find a stripe charge linked with your shopify order.

 

1. Use Order Transaction API to get the payment_id (shopify payment session) from the response.

  Doc:https://shopify.dev/docs/api/admin-rest/2024-04/resources/transactions

  GET /admin/api/2023-10/orders/450789469/transactions/389404469.json

 

2. Use Stripe search charges API shown below to find charge for shopify payment session found above:

Doc: https://docs.stripe.com/api/charges/search 

Example:

const stripe = require('stripe')('sk_test_51JK0Gx...f700xnPTE3Zssk_test_51JK0GxBnP1f8jLOseMk19ol0pOnpwCJzNyQF7LTF0ou8Ugxw3UFt0DteQlboVF6e4a4bc8oOxz8JOZEx0yVvkEf700xnPTE3Zs');

 
  static searchCharge (shopPaymentSession) {
        return stripe.charges.search({
            query: `metadata['shopify_payment_session']:'gid://shopify/PaymentSession/${shopPaymentSession}'`
        });
    }
 
I have been asking both shopify and stripe support team about this but they don't have any idea but finally I had to dig deeper myself to find the solution as we have few auto workflow triggering in ou ERP for each shopify orders. Let me know if you need any help to get it implemented, I am happy to help without any charges.