subscriptionBillingAttempt
Returns a SubscriptionBillingAttempt by ID.
Anchor to Possible returnsPossible returns
- Anchor to SubscriptionBillingAttemptSubscription•
Billing Attempt A record of an execution of the subscription billing process. Billing attempts use idempotency keys to avoid duplicate order creation. A successful billing attempt will create an order.
- completed
At •DateTime The date and time when the billing attempt was completed.
- created
At •Datenon-nullTime! The date and time when the billing attempt was created.
- id•ID!non-null
A globally-unique ID.
- idempotency
Key •String!non-null A unique key generated by the client to avoid duplicate payments.
- next
Action •Url URL The URL where the customer needs to be redirected so they can complete the 3D Secure payment flow.
- order•Order
The result of this billing attempt if completed successfully.
- origin
Time •DateTime The date and time used to calculate fulfillment intervals for a billing attempt that successfully completed after the current anchor date. To prevent fulfillment from being pushed to the next anchor date, this field can override the billing attempt date.
- ready•Boolean!non-null
Whether the billing attempt is still processing.
- subscription
Contract •Subscriptionnon-nullContract! The subscription contract.
- error
Code •SubscriptionBilling Attempt Error Code A code corresponding to a payment error during processing.
- error
Message •String A message describing a payment error during processing.
- completed
Query for a subscription billing attempt
query findBillingAttempt($subscriptionBillingAttempt: ID!) {
subscriptionBillingAttempt(id: $subscriptionBillingAttempt) {
id
nextActionUrl
idempotencyKey
ready
order {
id
}
subscriptionContract {
id
}
errorMessage
errorCode
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query findBillingAttempt($subscriptionBillingAttempt: ID!) { subscriptionBillingAttempt(id: $subscriptionBillingAttempt) { id nextActionUrl idempotencyKey ready order { id } subscriptionContract { id } errorMessage errorCode } }",
"variables": {
"subscriptionBillingAttempt": "gid://shopify/SubscriptionBillingAttempt/693432112"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query findBillingAttempt($subscriptionBillingAttempt: ID!) {
subscriptionBillingAttempt(id: $subscriptionBillingAttempt) {
id
nextActionUrl
idempotencyKey
ready
order {
id
}
subscriptionContract {
id
}
errorMessage
errorCode
}
}`,
{
variables: {
"subscriptionBillingAttempt": "gid://shopify/SubscriptionBillingAttempt/693432112"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query findBillingAttempt($subscriptionBillingAttempt: ID!) {
subscriptionBillingAttempt(id: $subscriptionBillingAttempt) {
id
nextActionUrl
idempotencyKey
ready
order {
id
}
subscriptionContract {
id
}
errorMessage
errorCode
}
}`,
"variables": {
"subscriptionBillingAttempt": "gid://shopify/SubscriptionBillingAttempt/693432112"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query findBillingAttempt($subscriptionBillingAttempt: ID!) {
subscriptionBillingAttempt(id: $subscriptionBillingAttempt) {
id
nextActionUrl
idempotencyKey
ready
order {
id
}
subscriptionContract {
id
}
errorMessage
errorCode
}
}
QUERY
variables = {
"subscriptionBillingAttempt": "gid://shopify/SubscriptionBillingAttempt/693432112"
}
response = client.query(query: query, variables: variables)