A place to discuss charging merchants for your apps and services using the billing API.
Hi,
I'm attempting to create an application charge using the REST Admin API against my development store which is based in Ireland and has euro as it's currency.
The following code works in so far as it creates the charge successfully, has a working confirmation URL and will send the client back to the return URL with the correct charge ID.
const euroCurrency = await new shopify.rest.Currency({ session: session });
euroCurrency.currency = 'EUR';
const application_charge = new shopify.rest.ApplicationCharge({ session: session });
application_charge.name = `Payment for WAZP+ Invoice Number: ${invoice.invoice_number}`;
application_charge.currency = euroCurrency;
application_charge.price = invoice.total_price;
let returnURL = `${event.url.origin}/billing/return/${returnID}`;
returnURL = returnURL.replace('http://', 'https://');
application_charge.return_url = returnURL;
application_charge.test = true;
await application_charge.save({
update: true
});
Before I call application_charge.save(), the value of application_charge is: "NewResource {currency: 'EUR'}" and afterwards it updates to: "Currency {0: 'U', 1: 'S', 2: 'D'}".
I've tried setting it to just the string 'EUR' but it's also ignored and the charge comes in as USD, in the price set on the application_charge.
When I fetch the shop's resource, the listed base currency is 'EUR'.
I've attached screenshot of how the charge appears to the merchant and the development store's currency setting.
Am I not setting the currency correctly on the application_charge object before saving it? Is this functionality not supported through the REST API and I need to use GraphQL? The docs only mention GraphQL, but the rest API endpoints are there and work to a certain extent. Anyone got any experience or ideas with this?
I found a solution of sorts for my problem. I was able to get the graph QL interface to work to make a charge in EUR. The following code works, this is typescript using the node js client library:
const client = new shopify.clients.Graphql({ session });
const data = await client.query({
data: {
query: `mutation AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!, $test: Boolean) {
appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price, test: $test) {
userErrors {
field
message
}
appPurchaseOneTime {
createdAt
id
}
confirmationUrl
}
}`,
variables: {
name: `Payment for WAZP+ Invoice Number: ${invoice.invoice_number}`,
price: {
amount: invoice.total_price,
currencyCode: 'EUR'
},
returnUrl: returnURL,
test: true
}
}
});
The other gotcha you need to pass is you need to go to the partner dashboard, select your app > distribution and make it a public app. This wasn't a required step in for the REST API call to work in USD. I'll leave this as unsolved in case someone else has a solution on how to get the REST API to work with EUR currency.
Hi Barry - glad to hear you've found a partial solution, and thanks for coming back to post it!
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
Bumping into the same issues as you with getting a subscription going in EUR. No matter what I try on the REST API the currency is set to USD.
Following your "sort" of solution of going down the GraphQL route I was able to get my subscription set to EUR. Using the Remix sdk:
const store = "my-test-store";
const appName = "my-dev-app";
const cappedAmount = 100;
const terms = "My usage terms...";
const response = await this.admin.graphql(
`#graphql
mutation AppSubscriptionCreate($test: Boolean!, $trialDays: Int!, $name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
appSubscriptionCreate(test: $test, trialDays: $trialDays, name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {
userErrors {
field
message
}
appSubscription {
id
}
confirmationUrl
}
}`,
{
variables: {
test: true,
trialDays: 0,
name: "My Usage Plan",
returnUrl: `https://admin.shopify.com/store/${store}/apps/${appName}/app`,
lineItems: [
{
plan: {
appUsagePricingDetails: {
cappedAmount: {
amount: cappedAmount,
currencyCode: "EUR",
},
terms: terms,
},
},
},
],
},
},
);
const json = await response.json();