skip to Main Content

shopify payment api I have implemented this api for my app and done payment successfully In response i get charge_id in a url as query string

but I done know how to cross check this charge id after payment done successfully

I want to check this charge_id with the help of api. shopify confirm me again this charge_id we got this amount of payment.

api code

curl -X POST https://syzb.myshopify.com/admin/api/2022-07/graphql.json -H 'Content-Type: application/json' -H 'X-Shopify-Access-Token: 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' -d '{
  "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": {
  "test": true, 
    "name": "Premium +",
    "returnUrl": "https://example.com/payment-success/?org=329BFBC5745344B58F321A1B842B73F8",
    "lineItems": [
      {
        "plan": {
          "appRecurringPricingDetails": {
            "price": {
              "amount": 99.50,
              "currencyCode": "USD"
            },
            "interval": "EVERY_30_DAYS"
          }
        }
      },
      {
        "plan": {
          "appUsagePricingDetails": {
            "terms": "Testing",
            "cappedAmount": {
              "amount": 10.25,
              "currencyCode": "USD"
            }
          }
        }
      }
    ]
  }
}'

2

Answers


  1. Chosen as BEST ANSWER

    curl -X GET "https://your-development-store.myshopify.com/admin/api/2022-07/recurring_application_charges/455696195.json"
    -H "X-Shopify-Access-Token: {access_token}"

    https://shopify.dev/api/admin-rest/2022-07/resources/recurringapplicationcharge#get-recurring-application-charges-recurring-application-charge-id


  2. Have a look the official Shopify documentation!

    Curl the resource with:

    curl -X GET "https://your-development-store.myshopify.com/admin/api/2022-10/recurring_application_charges/<charge_id>.json" 
    -H "X-Shopify-Access-Token: {access_token}"
    
    

    Your response will be something like this:

    HTTP/1.1 200 OK
    {
      "recurring_application_charge": {
        "id": 455696195,
        "name": "Super Mega Plan",
        "api_client_id": 755357713,
        "price": "15.00",
        "status": "pending",
        "return_url": "http://yourapp.example.org",
        "billing_on": "2022-10-03",
        "created_at": "2022-10-03T12:44:45-04:00",
        "updated_at": "2022-10-03T12:44:45-04:00",
        "test": null,
        "activated_on": null,
        "cancelled_on": null,
        "trial_days": 0,
        "trial_ends_on": null,
        "decorated_return_url": "http://yourapp.example.org?charge_id=455696195",
        "confirmation_url": "https://jsmith.myshopify.com/admin/charges/755357713/455696195/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBENfKRs6EmF1dG9fYWN0aXZhdGVU--b5f90d04779cc5242b396e4054f2e650c5dace1c"
      }
    }
    

    What you need to check if a payment has been successful is the status value:

    • pending: The recurring charge is pending.
    • accepted: Removed in version 2021-01. The recurring charge has been accepted. As of API version 2021-01, when a merchant accepts a charge, the charge immediately transitions from pending to active.
    • active: The recurring charge is activated. This is the only status that actually causes a merchant to be charged. As of API version 2021-01, when a merchant accepts a charge, the charge immediately transitions from pending to active.
    • declined: The recurring charge has been declined.
    • expired: The recurring charge was not accepted within 2 days of being created.
    • frozen: The recurring charge is on hold due to a shop subscription non-payment. The charge will re-activate once subscription payments resume.
    • cancelled: The developer cancelled the charge.

    I hope this can help you!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search