What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Admin REST API Payment Transaction currency not being set

Solved

Admin REST API Payment Transaction currency not being set

brandon_k
Shopify Partner
8 0 2
I'm creating payment transactions on orders with the admin REST API, but found that the specified currency is not going through. For example, the JSON data that I POSTed is as follows
 
{
	"transaction": {
		"currency": "CAD",
		"amount": "1.00",
		"kind": "sale",
		"source": "external"
	}
}
 
But the response, and our storefront show it as USD. A snippet of the response is as follows
{
...
		"amount": "1.00",
		"currency": "USD",
...
}
 
What can I do to allow for different currency payments to be received through a transaction?
Accepted Solution (1)

Liam
Community Manager
3108 344 895

This is an accepted solution.

Hi Brandon,

 

Which payment gateway are you using for these transactions? If you're using Shopify Payments and have enabled multiple currencies, customers can check out in their preferred currency. However, when you're creating a transaction via the Admin API, the currency should match the currency in which the order was originally placed.

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Liam
Community Manager
3108 344 895

This is an accepted solution.

Hi Brandon,

 

Which payment gateway are you using for these transactions? If you're using Shopify Payments and have enabled multiple currencies, customers can check out in their preferred currency. However, when you're creating a transaction via the Admin API, the currency should match the currency in which the order was originally placed.

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

brandon_k
Shopify Partner
8 0 2

Thanks for that info, Liam. That does help explain the situation. I'm creating the order and the payment transactions both via the Admin API. This is importing historical data and not performing "live" purchases. I guess the question now is, how can I specify the currency in the order?
I've tried various settings, and nothing seems to work. The docs for the Order resource state the `currency` field on the order is read-only, and so it seems like the only option for me is to specify that in each line item. However, when I try setting the `price_set`, that seems to be ignored. 
For example, I made an order for an item that's listed in the store for 197.00 USD, but this was purchased at a lower price in the past (93.00 USD), and the customer paid in GBP, so my (obfuscated) JSON is this:

 

{
	"order": {
		"line_items": [
			{
				"fulfillable_quantity": 1,
				"fulfillment_service": "manual",
				"price_set": {
					"shop_money": {
						"amount": "93.00",
						"currency_code": "USD"
					},
					"presentment_money": {
						"amount": "73.00",
						"currency_code": "GBP"
					}
				},
				"quantity": 1,
				"requires_shipping": false,
				"sku": "FOO-BAR",
				"variant_id": "11111111111111",
				"variant_inventory_management": "shopify",
			}
		],
		"customer": {
			"id": 9999999999999
		}
	}
}

 

 

This ends up with an order where the item's price is 197.00 USD. 

 

If I just do something simple to specify the price (ignoring currency), it works fine to override the item's price: 

 

{
	"order": {
		"line_items": [
			{
				"fulfillable_quantity": 1,
				"fulfillment_service": "manual",
				"price": "93.00",
				"quantity": 1,
				"requires_shipping": false,
				"sku": "FOO-BAR",
				"variant_id": "11111111111111",
				"variant_inventory_management": "shopify",
			}
		],
		"customer": {
			"id": 9999999999999
		}
	}
}

 

But of course then I have the problem that it's 93.00 USD and the payment transaction of 73.00 GBP comes through as 73.00 USD.

I hope that makes sense for what I'm trying to accomplish and where I need some clarification. Any assistance is greatly appreciated.

brandon_k
Shopify Partner
8 0 2

After some more searching of the forums and finding https://community.shopify.com/c/customers-discounts-and-orders/creating-an-order-in-different-curren..., I decided to try setting a value for the (supposedly read-only) "currency", and was able to get the results I'm after, so I'll just run with that and hope that the "currency" support doesn't get dropped before the data import is completed.

My sample of the order is now like this:

{
	"order": {
		"currency": "GBP",
		"line_items": [
			{
				"fulfillable_quantity": 1,
				"fulfillment_service": "manual",
				"price": "93.00",
				"quantity": 1,
				"requires_shipping": false,
				"sku": "FOO-BAR",
				"variant_id": "11111111111111",
				"variant_inventory_management": "shopify",
			}
		],
		"customer": {
			"id": 9999999999999
		}
	}
}

And then the payment works as expected to apply 1.00 GBP with the following:

{
	"transaction": {
		"amount": "1.00",
		"kind": "sale",
		"source": "external"
	}
}


Thanks for your help.