Shopify Payments Integration
Before writing code
Fetch live docs:
- Web-search
site:shopify.dev payments apps api for Payment Apps API
- Web-search
site:shopify.dev billing api app charges for app billing
- Web-search
site:shopify.dev shopify payments for Shopify Payments overview
- Web-search
site:shopify.dev payment session resolve reject for payment session flow
- Web-search
site:shopify.dev app subscription create usage record for billing mutations
Shopify Payments
Shopify's built-in payment processor (powered by Stripe):
- No third-party gateway needed
- Supports credit/debit cards, Shop Pay, Apple Pay, Google Pay
- Lower transaction fees than third-party gateways
- PCI DSS Level 1 compliant (Shopify handles compliance)
Payment Flow
Customer → Checkout → Payment Method Selection → Authorization → Capture
- Authorization happens at checkout
- Capture happens when order is fulfilled (or immediately, based on settings)
- Auto-capture can be enabled for immediate charge
Supported Payment Methods
| Method |
Details |
| Credit/Debit cards |
Visa, Mastercard, Amex, Discover |
| Shop Pay |
Shopify's accelerated checkout |
| Apple Pay |
On supported devices/browsers |
| Google Pay |
On supported devices/browsers |
| Local methods |
Varies by country (iDEAL, Bancontact, etc.) |
Fetch live docs for supported payment methods by country — availability varies by region and changes over time.
Payment Apps API
For building custom payment gateways as Shopify apps:
Payment Session Flow
1. Customer selects your payment method at checkout
2. Shopify creates payment session → calls your app's payment endpoint
3. Your app processes payment with your gateway
4. Return: RESOLVE (success) or REJECT (failure)
5. Optional: REDIRECT for additional auth (3D Secure, bank redirect)
6. Optional: CONFIRM for pending/async payments
Key Mutations
| Operation |
Mutation |
When |
| Approve payment |
paymentSessionResolve |
Payment succeeded |
| Decline payment |
paymentSessionReject |
Payment failed |
| Redirect customer |
paymentSessionRedirect |
3D Secure, bank auth |
| Confirm payment |
paymentSessionConfirm |
Async/pending payment settled |
| Approve refund |
refundSessionResolve |
Refund succeeded |
| Decline refund |
refundSessionReject |
Refund failed |
| Approve capture |
captureSessionResolve |
Manual capture succeeded |
| Decline capture |
captureSessionReject |
Manual capture failed |
| Approve void |
voidSessionResolve |
Void succeeded |
| Decline void |
voidSessionReject |
Void failed |
Fetch live docs for each session mutation's input fields and the PaymentSessionActionsRedact webhook — the API surface for payment apps is complex and version-sensitive.
Payment App Requirements
- Must handle: payments, refunds, captures, voids
- Must implement:
payments_app_configure GraphQL mutations
- Must respond within timeout (usually 5 seconds for sync, longer for async)
- Testing: use Shopify's test mode and development store
Fetch live docs: Web-search site:shopify.dev build payment extension for current extension configuration, required endpoints, and testing procedures.
Billing API
For charging merchants for your app:
Charge Types
| Type |
Mutation |
Use Case |
| Recurring |
appSubscriptionCreate |
Monthly/annual subscription |
| One-time |
appPurchaseOneTimeCreate |
One-time feature purchase |
| Usage-based |
appUsageRecordCreate |
Metered billing (per-action, per-order) |
Subscription Flow
- Create subscription with
appSubscriptionCreate → returns confirmationUrl
- Redirect merchant to
confirmationUrl
- Merchant approves charge on Shopify-hosted page
- Shopify handles billing, invoicing, and payouts to your Partner account
Usage-Based Billing Pattern
- Create a subscription plan with a usage pricing model via
appSubscriptionCreate
- As the merchant uses features, record usage with
appUsageRecordCreate
- Shopify bills the merchant at the end of the billing cycle based on recorded usage
- Capped amounts prevent unexpected charges
Fetch live docs for AppSubscriptionInput and AppUsageRecordInput fields — pricing models, trial days, currency options, and line item structures change across API versions.
Refund Processing
- Refunds issued via
refundCreate mutation (on orders)
- Payment apps handle refund sessions via
refundSessionResolve/refundSessionReject
- Can be full or partial
- Refunded to original payment method
- Refund notification sent to customer automatically
PCI Compliance
Shopify handles PCI compliance for:
- Shopify Payments (fully managed)
- Checkout-hosted payment forms
- Payment apps that use Shopify's session-based flow
Your app must:
- Never store raw card numbers, CVV, or sensitive cardholder data
- Use Shopify's payment session API (not direct card collection)
- Follow Shopify's security requirements for payment apps
- Implement HTTPS for all endpoints
Best Practices
- Recommend Shopify Payments as primary gateway (lowest fees, best integration)
- Use the Payment Apps API for custom gateways — never collect cards directly
- Implement proper error handling for payment sessions (timeouts, network errors)
- Use the Billing API for app monetization — never handle payments outside Shopify
- Test payment flows in development stores (test mode)
- Handle refunds gracefully — always confirm with
refundSessionResolve
- Implement idempotency for payment operations (use idempotency keys)
- Log payment events for debugging but never log sensitive payment data
Fetch the Shopify Payment Apps API and Billing API documentation for exact session flow, mutation inputs, testing procedures, and webhook requirements before implementing.
1---2name: shopify-payments3description: Integrate Shopify payments — Shopify Payments (Stripe-powered), Payment Apps API, payment session flow, Billing API for app charges, refund processing, and PCI compliance. Use when working with Shopify payment processing.4---56# Shopify Payments Integration78## Before writing code910**Fetch live docs**:111. Web-search `site:shopify.dev payments apps api` for Payment Apps API122. Web-search `site:shopify.dev billing api app charges` for app billing133. Web-search `site:shopify.dev shopify payments` for Shopify Payments overview144. Web-search `site:shopify.dev payment session resolve reject` for payment session flow155. Web-search `site:shopify.dev app subscription create usage record` for billing mutations1617## Shopify Payments1819Shopify's built-in payment processor (powered by Stripe):20- No third-party gateway needed21- Supports credit/debit cards, Shop Pay, Apple Pay, Google Pay22- Lower transaction fees than third-party gateways23- PCI DSS Level 1 compliant (Shopify handles compliance)2425### Payment Flow2627```28Customer → Checkout → Payment Method Selection → Authorization → Capture29```3031- Authorization happens at checkout32- Capture happens when order is fulfilled (or immediately, based on settings)33- Auto-capture can be enabled for immediate charge3435### Supported Payment Methods3637| Method | Details |38|--------|---------|39| Credit/Debit cards | Visa, Mastercard, Amex, Discover |40| Shop Pay | Shopify's accelerated checkout |41| Apple Pay | On supported devices/browsers |42| Google Pay | On supported devices/browsers |43| Local methods | Varies by country (iDEAL, Bancontact, etc.) |4445> **Fetch live docs** for supported payment methods by country — availability varies by region and changes over time.4647## Payment Apps API4849For building custom payment gateways as Shopify apps:5051### Payment Session Flow5253```541. Customer selects your payment method at checkout552. Shopify creates payment session → calls your app's payment endpoint563. Your app processes payment with your gateway574. Return: RESOLVE (success) or REJECT (failure)585. Optional: REDIRECT for additional auth (3D Secure, bank redirect)596. Optional: CONFIRM for pending/async payments60```6162### Key Mutations6364| Operation | Mutation | When |65|-----------|----------|------|66| Approve payment | `paymentSessionResolve` | Payment succeeded |67| Decline payment | `paymentSessionReject` | Payment failed |68| Redirect customer | `paymentSessionRedirect` | 3D Secure, bank auth |69| Confirm payment | `paymentSessionConfirm` | Async/pending payment settled |70| Approve refund | `refundSessionResolve` | Refund succeeded |71| Decline refund | `refundSessionReject` | Refund failed |72| Approve capture | `captureSessionResolve` | Manual capture succeeded |73| Decline capture | `captureSessionReject` | Manual capture failed |74| Approve void | `voidSessionResolve` | Void succeeded |75| Decline void | `voidSessionReject` | Void failed |7677> **Fetch live docs** for each session mutation's input fields and the `PaymentSessionActionsRedact` webhook — the API surface for payment apps is complex and version-sensitive.7879### Payment App Requirements8081- Must handle: payments, refunds, captures, voids82- Must implement: `payments_app_configure` GraphQL mutations83- Must respond within timeout (usually 5 seconds for sync, longer for async)84- Testing: use Shopify's test mode and development store8586> **Fetch live docs**: Web-search `site:shopify.dev build payment extension` for current extension configuration, required endpoints, and testing procedures.8788## Billing API8990For charging merchants for your app:9192### Charge Types9394| Type | Mutation | Use Case |95|------|----------|----------|96| Recurring | `appSubscriptionCreate` | Monthly/annual subscription |97| One-time | `appPurchaseOneTimeCreate` | One-time feature purchase |98| Usage-based | `appUsageRecordCreate` | Metered billing (per-action, per-order) |99100### Subscription Flow1011021. Create subscription with `appSubscriptionCreate` → returns `confirmationUrl`1032. Redirect merchant to `confirmationUrl`1043. Merchant approves charge on Shopify-hosted page1054. Shopify handles billing, invoicing, and payouts to your Partner account106107### Usage-Based Billing Pattern1081091. Create a subscription plan with a usage pricing model via `appSubscriptionCreate`1102. As the merchant uses features, record usage with `appUsageRecordCreate`1113. Shopify bills the merchant at the end of the billing cycle based on recorded usage1124. Capped amounts prevent unexpected charges113114> **Fetch live docs** for `AppSubscriptionInput` and `AppUsageRecordInput` fields — pricing models, trial days, currency options, and line item structures change across API versions.115116## Refund Processing117118- Refunds issued via `refundCreate` mutation (on orders)119- Payment apps handle refund sessions via `refundSessionResolve`/`refundSessionReject`120- Can be full or partial121- Refunded to original payment method122- Refund notification sent to customer automatically123124## PCI Compliance125126Shopify handles PCI compliance for:127- Shopify Payments (fully managed)128- Checkout-hosted payment forms129- Payment apps that use Shopify's session-based flow130131Your app must:132- Never store raw card numbers, CVV, or sensitive cardholder data133- Use Shopify's payment session API (not direct card collection)134- Follow Shopify's security requirements for payment apps135- Implement HTTPS for all endpoints136137## Best Practices138139- Recommend Shopify Payments as primary gateway (lowest fees, best integration)140- Use the Payment Apps API for custom gateways — never collect cards directly141- Implement proper error handling for payment sessions (timeouts, network errors)142- Use the Billing API for app monetization — never handle payments outside Shopify143- Test payment flows in development stores (test mode)144- Handle refunds gracefully — always confirm with `refundSessionResolve`145- Implement idempotency for payment operations (use idempotency keys)146- Log payment events for debugging but never log sensitive payment data147148Fetch the Shopify Payment Apps API and Billing API documentation for exact session flow, mutation inputs, testing procedures, and webhook requirements before implementing.