Can't create a recurring_application_charge with unpublished app

Solved

Can't create a recurring_application_charge with unpublished app

sengming
Shopify Partner
52 1 9

Hi there,

 

I am having trouble create recurring_application_charge with an unpublished app on a development store. This is the error I get

 

It appears that this application is currently owned by a Shop. It must be migrated to the Shopify partners area before it can create charges with the API

 

What do I need to do to create a recurring_application_charge with an unpublished app on a development store? Thanks!

 

Details:

 

Request:

 

POST /admin/api/2023-07/recurring_application_charges.json HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 64
Content-Type: application/json
Host: maxim-khanate.myshopify.com:443
User-Agent: HTTPie/3.2.2


{
"recurring_application_charge": {
"name": "test",
"price": 10
}
}

 

Response

HTTP/1.1 422 Unprocessable Entity
CF-Cache-Status: DYNAMIC
CF-RAY: 81e5bfc1081f429d-EWR
Connection: keep-alive
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Frecurring_application_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=15e2a090-91da-496e-8edc-ccc898b9a037
Content-Type: application/json; charset=utf-8
Date: Mon, 30 Oct 2023 18:33:51 GMT
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}
Referrer-Policy: origin-when-cross-origin
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=pvm6S5dZYvW2at6lEz%2BgXmSPncPSP%2FE%2BjD6oql4C3MVsQ6S7xO7WjOGT5ymCUgLVptPCdaxxKvZf%2Bs3RnyR49VsrLiEnDD2OdZC8xpduiYoKitdE5x8MB0Q4bken8uCG%2BQxtmKolug2HJ112fQ%3D%3D"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Server-Timing: processing;dur=205, cfRequestDuration;dur=268.999815
Strict-Transport-Security: max-age=7889238
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Dc: gcp-us-east4,gcp-us-central1,gcp-us-central1
X-Download-Options: noopen
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: none
X-Request-ID: 15e2a090-91da-496e-8edc-ccc898b9a037
X-ShardId: 63
X-ShopId: 8819638336
X-Shopify-API-Terms: By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms
X-Shopify-API-Version: 2023-07
X-Shopify-Shop-Api-Call-Limit: 1/40
X-Shopify-Stage: production
X-Sorting-Hat-PodId: 63
X-Sorting-Hat-ShopId: 8819638336
X-Stats-ApiClientId: 68173594625
X-Stats-ApiPermissionId: 365609451584
X-Stats-UserId:
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Frecurring_application_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=15e2a090-91da-496e-8edc-ccc898b9a037
alt-svc: h3=":443"; ma=86400

{
"errors": {
"base": [
"It appears that this application is currently owned by a Shop. It must be migrated to the Shopify partners area before it can create charges with the API."
]
}
}

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 512

This is an accepted solution.

Hey @sengming

 

In order to create an application charge, your app will need to be using the public distribution type . It's not currently possible to switch an app between types, so if your app is currently a custom app, then you'll need to rebuilt it as a public draft app to be able to test the app billing on a development store. 

 

More information on our billing API documents here: https://shopify.dev/docs/apps/billing 

 

Hope that helps. 

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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 4 (4)

ShopifyDevSup
Shopify Staff
1453 238 512

This is an accepted solution.

Hey @sengming

 

In order to create an application charge, your app will need to be using the public distribution type . It's not currently possible to switch an app between types, so if your app is currently a custom app, then you'll need to rebuilt it as a public draft app to be able to test the app billing on a development store. 

 

More information on our billing API documents here: https://shopify.dev/docs/apps/billing 

 

Hope that helps. 

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

sengming
Shopify Partner
52 1 9

Thanks for the answer!

 

In that case, how should I test creating a recurring_application_charge before I make an app public?

ShopifyDevSup
Shopify Staff
1453 238 512

Hi @sengming , you can add `"test": true` in your charges to have them go through as a test. 

https://shopify.dev/docs/apps/store/review/testing#testing-your-app-s-billing-system

One thing to keep in mind is that the testing is a bit limited. You can test all of the mutations to see how they work, but billing records are not actually created for test charges so you're limited in testing recurring behaviour as well as the behaviour around proration

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

sengming
Shopify Partner
52 1 9

Thanks for the answer Kyle! Unfortunately I am getting the same error when using `"test": true`

 

"It appears that this application is currently owned by a Shop. It must be migrated to the Shopify partners area before it can create charges with the API."

 

Am I doing something wrong?

 

Here are the details

 

Request

POST /admin/api/2023-07/recurring_application_charges.json HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 78
Content-Type: application/json
Host: maxim-khanate.myshopify.com:443
User-Agent: HTTPie/3.2.2

{
    "recurring_application_charge": {
        "name": "test",
        "price": 10,
        "test": true
    }
}

Response

 

HTTP/1.1 422 Unprocessable Entity
CF-Cache-Status: DYNAMIC
CF-RAY: 81ff1bd5f8c28ce3-EWR
Connection: keep-alive
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Frecurring_application_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=a6b503fa-2054-4c11-81c6-9d631ae0f65c
Content-Type: application/json; charset=utf-8
Date: Thu, 02 Nov 2023 20:25:47 GMT
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}
Referrer-Policy: origin-when-cross-origin
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=O%2Fup1OVBAf3BfPQNMRrNdNX6J9nxGLkC0dkrjyZLFmDqGDwQetSwDCki3v9qqKOkBfN%2BBCNBNZtnya9mKY773%2BG%2Fp8PZ712csaK%2BucZIDiWUZ8jDETmnEcsIM0KSADGZtrRtBxg2%2FFGc80%2FDow%3D%3D"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Server-Timing: processing;dur=193, cfRequestDuration;dur=259.999990
Strict-Transport-Security: max-age=7889238
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Dc: gcp-us-east4,gcp-us-central1,gcp-us-central1
X-Download-Options: noopen
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: none
X-Request-ID: a6b503fa-2054-4c11-81c6-9d631ae0f65c
X-ShardId: 63
X-ShopId: 8819638336
X-Shopify-API-Terms: By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms
X-Shopify-API-Version: 2023-07
X-Shopify-Shop-Api-Call-Limit: 1/40
X-Shopify-Stage: production
X-Sorting-Hat-PodId: 63
X-Sorting-Hat-ShopId: 8819638336
X-Stats-ApiClientId: 68173594625
X-Stats-ApiPermissionId: 365609451584
X-Stats-UserId:
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Frecurring_application_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=a6b503fa-2054-4c11-81c6-9d631ae0f65c
alt-svc: h3=":443"; ma=86400

{
"errors": {
"base": [
"It appears that this application is currently owned by a Shop. It must be migrated to the Shopify partners area before it can create charges with the API."
]
}
}