Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

When testing the Billing API how can I test the payment without having to add a real credit card?

When testing the Billing API how can I test the payment without having to add a real credit card?

nick_el
Shopify Partner
4 0 1

Hello, I'm working with the Billing API on a development store. I'm passing {test: true} to the GraphQL AppPurchaseOneTimeCreate mutation, but the payment confirmation screen URL (`confirmationUrl`) that is returned requires me to enter a real credit card. How can I test the payment without having to add a real credit card?

nick_el_0-1661733954242.png

 

CleanShot 2022-08-29 at 09.42.45@2x.png

CleanShot 2022-08-29 at 09.41.44@2x.png

Replies 9 (9)

kevnob
Shopify Staff
11 3 3

Hi @nick_el,

 

Thanks for your post! 

 

The recommended method for testing your app's billing system, I would refer to the developer document on testing your apps billing system by using a development store for testing.

 

You can also refer to the REST and GraphQL on how to complete these tests. 

 

I hope that helps! 

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

nick_el
Shopify Partner
4 0 1

Thank you, but the document states

 

To have your app create a test charge, you can change your app's charge requests to include "test": true. This will create a test charge when you install the app so that you don't incur a real charge on your account.

 

I'm already passing `{test: true}` (see screenshot) and I am already working on a development store. There is still a screen popping up asking me to enter a credit card. I tried with a real card and then it says "The shop cannot accept the provided charge.".

 

Any ideas?

 

EDIT: I'm creating a charge inside of my app, whereas the document appears to talk about charging at the time of app installation. I'm confused, how can an app charge something before it's installed?

nick_el
Shopify Partner
4 0 1

@kevnob just following up to see if you could help with my last comment. Thank you!

StoreContrl_Adm
Shopify Partner
3 0 2

Hi Nick,

 

Dit you find a solution for this? We discover the exact same issue where we already send test=true with our call

clemen
Shopify Partner
1 0 0

Hi @StoreContrl_Adm & @nick_el,


I'm facing the same issue, set `test` flag as `true` and confirmation page shows the `test` banner but it has the `approve` button disabled, were you guys able to find a solution for this issue?

 

Thanks

nick_el
Shopify Partner
4 0 1

I didn't sorry. I suggest asking in the Slack channel.

StoreContrl_Adm
Shopify Partner
3 0 2

You can try this way with outting the test flag inside the query. That was the working code for us.

 

$data = array(
"query" => 'mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, test: true, trialDays: 30, lineItems: $lineItems) { userErrors { field message } appSubscription { id } confirmationUrl } }',
"variables" => array(
"name" => 'TEST',
"returnUrl" => '',
"trialDays" => "30",
"lineItems" => array(
"plan" => array(
"appRecurringPricingDetails" => array(
"price" => array(
"amount" => '',
"currencyCode" => "USD",
),
"interval" => $period,
)
)
)
)
);
$shopify_api->shopify_call('/admin/api/2023-04/graphql.json', $data, 'POST', array("Content-Type: application/json"));
Growthfamily
Shopify Partner
33 1 4

That work for me!  👆

Discover My Stories: Embed social-style video stories on product pages

If you find my reply helpful, please hit Like and Mark as Solution

david1542
Shopify Partner
2 0 2

Hi everyone, I'm just writing it here in case anyone would need it.

 

My problem was that I was not changing the query itself and including the test there. You have to change the GraphQL query AND include "test": true in your variables.

 

My query looks like this:

{
"query": "mutation AppSubscriptionCreate($test: Boolean!, $name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(test: $test, name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } appSubscription { id } confirmationUrl } }",
 "variables": {
    "name": "My subscription",
    "returnUrl": "http://localhost:3000",
    "test": true,
    "lineItems": [
      {
        "plan": {
          "appRecurringPricingDetails": {
            "price": {
              "amount": 10.0,
              "currencyCode": "USD"
            },
            "interval": "EVERY_30_DAYS"
          }
        }
      }
    ]
  }
}