Connect your own Shopify store to KDPika licensing through a verified, durable backend. This does not add a processor to KDPika platform subscriptions.
What you will learn
- Configure native notifications and approved product/plan mappings.
- Issue once after confirmed payment, then handle supported lifecycle changes.
- Deliver a saved key privately and test without exposing buyer/card data.
Prerequisites
- Complete the Sandbox quickstart and store service setup.
- Use your own provider merchant account and private backend credentials; never KDPika's platform billing credentials.
- Have a product-scoped Sandbox management key with licenses:read and licenses:write.
- Configure one eligible quantity-one line. Mixed baskets, multi-seat quantities and partial refunds need an explicitly reviewed policy.
Configure the provider
- Configure an app for your own development shop and a server-only Admin API token. Request order access and the product/customer field access needed by the query; protected customer data approval may be required for email/name. Do not request unrelated write permissions.
- Pin API version 2026-10. Register orders/paid, refunds/create and orders/cancelled webhook subscriptions for your own HTTPS /provider-event endpoint.
- Set KDP_STORE_API_KEY to the app's private Admin token and KDP_STORE_WEBHOOK_SECRET to that app's client secret. The token and secret must belong to the same app/shop.
- Set provider/source to shopify, shop_domain to the exact lowercase YOUR_SHOP.myshopify.com domain and seller_id to a stable private merchant reference.
- Map exact gid://shopify/ProductVariant/ IDs in offer_map. Enable Test payments in the development shop and start with KDPika Sandbox.
- Use the complete Node ingress linked below in front of the shared PHP service, or route Shopify directly to the PHP endpoint. Never expose the Admin token in a storefront, theme or distributed app.
Verify before granting access
X-Shopify-Hmac-Sha256 is base64 HMAC-SHA256 over raw bytes. The endpoint additionally pins X-Shopify-Shop-Domain and allows only the registered topics. The delivery ID deduplicates the inbox; the order ID deduplicates issuance across deliveries. Admin GraphQL queries the pinned shop, refuses errors/missing protected data and checks Order.test against the configured environment.
Provider verification, receipt and fulfillment are separate. HTTP 202 only means the authenticated notification was saved. A buyer redirect or successful browser message never creates a license. Only the backend worker can authorize the scoped licensing write after current provider reads.
Event and lifecycle mapping
| Notification | Confirmed evidence | Licensing decision |
|---|---|---|
| orders/paid | Current order PAID, not cancelled; one quantity-one mapped variant; no additional line page | Issue once using the authenticated order email. |
| refunds/create | Refund ID is on that current order and displayFinancialStatus is REFUNDED | Revoke the existing order license. A partial refund requires review. |
| orders/cancelled | Current cancelledAt is present | Record cancellation intent without treating it as a confirmed refund. |
The exact Admin GraphQL query was validated against Shopify 2026-10's schema; this is not a query executed against an installed merchant account. Order access scopes have alternatives depending on the application type. Check the fields actually authorized for your installation; missing email must hold fulfillment, not silently choose another recipient. Historical orders beyond ordinary access windows may need separately approved order access.
This guide covers orders and refunds, not Shopify selling-plan subscription contracts. A new recurring order is an independent order here; automatic renewal of the original KDPika entitlement requires an authoritative subscription-contract adapter that is not supplied. Do not claim that every app's subscription lifecycle or every multi-item cart is covered.
Server examples and deployment
The PHP application contains the native verification, provider API reads, durable ledger and licensing worker. Optional Node/Python examples are complete raw-body ingress servers with an explicit PHP service dependency, not independent native payment workers. The PHP shared-hosting path needs neither Node nor a long-running process.
- Download all exact sources and check the SHA-256 manifest.
- Follow the shared setup without changing the provider/module source or putting private config under a web root.
- Set config.json provider/merchant/mode and offer_map; set fulfillment.json source to the identical provider string and map the approved internal offer to your product plan.
- Run the private work cron, inspect its aggregate states, and then run the separate mail cron. Keep both ledgers/backups persistent.
- Configure SMTP delivery for your own sender. It reuses the encrypted saved key; it never creates another license to resend.
Complete provider module
This exact module is loaded by the shared normalizer. It depends on the complete native authentication and HTTP client and durable service source. It is not a standalone copy/paste webhook endpoint.
<?php
declare(strict_types=1);
// Complete provider module for StoreNormalizer; loaded by normalize.php.
// Requires the shared service/archive, not a standalone payment endpoint.
trait StoreShopifyNormalizer
{
private function shopify(array $event, array $headers): array
{
$topic = storeHeader($headers, 'x-shopify-topic');
$orderId = $topic === 'refunds/create' ? ($event['order_id'] ?? null) : ($event['id'] ?? null);
$query = 'query LicenseOrder($id:ID!){order(id:$id){id email test cancelledAt displayFinancialStatus lineItems(first:2){nodes{id quantity variant{id}} pageInfo{hasNextPage}} refunds{id} customer{firstName lastName}}}';
$result = ($this->api)('POST', '/admin/api/2026-10/graphql.json', ['query' => $query, 'variables' => ['id' => 'gid://shopify/Order/' . rawurldecode($this->ref($orderId))]]);
storeRequire(empty($result['errors']) && is_array($result['data']['order'] ?? null), 'ORDER_NOT_CONFIRMED');
$order = $result['data']['order']; $this->mode(isset($order['test']) ? !$order['test'] : null);
$id = (string) $orderId;
if ($topic === 'refunds/create') {
$refundId = 'gid://shopify/Refund/' . rawurldecode($this->ref($event['id'] ?? null));
storeRequire(in_array($refundId, array_column($order['refunds'] ?? [], 'id'), true) && ($order['displayFinancialStatus'] ?? '') === 'REFUNDED', 'PARTIAL_OR_UNKNOWN_REFUND_REQUIRES_REVIEW');
return [$this->negative($id, $refundId, 'refunded')];
}
if ($topic === 'orders/cancelled') {
storeRequire(!empty($order['cancelledAt']), 'CANCELLATION_NOT_CONFIRMED');
return [$this->negative($id, 'cancel:' . $id, 'cancelled')];
}
storeRequire(($order['displayFinancialStatus'] ?? '') === 'PAID' && empty($order['cancelledAt']) && ($order['lineItems']['pageInfo']['hasNextPage'] ?? true) === false, 'ORDER_NOT_CURRENTLY_PAID');
$line = $this->one($order['lineItems']['nodes'] ?? []);
$variant = (string) ($line['variant']['id'] ?? '');
$customer = $order['customer'] ?? [];
return [$this->paid($id, $id, $variant, (string) ($order['email'] ?? ''), trim(($customer['firstName'] ?? '') . ' ' . ($customer['lastName'] ?? '')), false)];
}
}
Test in Sandbox
- Confirm invalid/missing proof cannot issue, and no key or API credential appears in the HTTP reply.
- Complete one permitted Test purchase in your merchant account. Confirm the provider delivery, then run work and verify one DONE issue and a saved encrypted key.
- Deliver to your verified test inbox and activate that key with the same buyer email and Sandbox App ID. Test a mismatched email too.
- Redeliver the same event and overlapping supported paid events. Confirm no second key and no additional renewal days for the same paid receipt.
- For supported subscriptions, test initial payment, another confirmed paid period, current failure/recovery and cancellation. Verify cancellation does not remove already-paid time.
- Test a supported full refund and any exposed dispute lifecycle. Check revoked/suspended state in KDPika; never simulate a refund only by editing the browser return URL.
- Test stale events and a missing initial mapping. Unknown, partial or unsupported cases must be held for review, not silently fulfilled.
Expected result: one authorized initial license, one additive extension per supported new paid receipt, no duplicate grant, no access from an unverified event, and a private delivery record. Renewal adds your mapped integer days, not an exact calendar-period-end update.
Verification boundary
The exact source was executed through local HTTP ingress and explicit synthetic provider-schema API fixtures, with real isolated KDPika Sandbox issuance, activation and supported lifecycle writes. Fixture signatures use local test secrets, not a provider's private signing infrastructure. No real Shopify account purchase is claimed. Your account's permissions, actual delivery format, TLS, provider checkout and email inbox still need the procedure above before Live use. Native WordPress/merchant account execution was unavailable in this documentation environment; this is the explicit contract-test boundary, not recorded-payment evidence.
Go-live checklist
- Review the unsupported boundaries above; do not sell a lifecycle this adapter does not implement.
- Complete your provider account verification and real Test delivery procedure; check merchant, recipient, item and mode.
- Use a separate Live config/state and scoped Live KDPika key; set KDP_CONFIRM_LIVE only after review. Never turn existing Sandbox ledgers into Live by editing their binding.
- Replace provider credentials/destination secret with the matching Live account values. Do not reuse example placeholders.
- Remove every loopback test override, use verified HTTPS and keep credentials and SQLite/encryption backups outside all web roots.
- Monitor private REVIEW/IN_FLIGHT and mail failures. A missing acknowledgement is not proof a write or email did not happen; reconcile before retrying.
- Retain business-effect identities to prevent reissuance. Apply your documented retention, refund, support and key-redelivery policies.
Common mistakes
- Shipping a server management key inside an application or theme.
- Issuing from a redirect, subscription-created event or unverified notification.
- Granting both initial checkout and initial recurring invoice independently.
- Deleting the durable ledger or creating a new effect ID after a timeout.
- Treating a saved key or SMTP acceptance as confirmed inbox delivery.
Official sources
Reviewed for this reference on 18 October 2026. Provider documentation can change independently; check your pinned API and account before upgrading.
Expected result
Only a confirmed provider purchase authorizes a licensing effect. A durable HTTP receipt, completed licensing operation and SMTP acceptance are separate outcomes. Inspect aggregate worker states and verify the resulting license with the same buyer email; no full key appears in public replies.
Security notes
Use least-privilege private provider and product-scoped licensing credentials, verified HTTPS, owner-only persistent state and separate secrets per account/environment. Never trust browser payment claims. Preserve held operations after an unknown result and reconcile before another write; exactly-once behavior across systems is not guaranteed.
Troubleshooting
For a receipt refusal check raw-byte preservation, the matching endpoint secret/account/mode, server clock where applicable and the private bootstrap layout. For REVIEW/IN_FLIGHT inspect provider state, safe private error codes and the licensing ledger before retrying. Missing permissions, recipient data or an initial mapping are not successful payments. For mail verify the separate SMTP ledger and provider delivery evidence. Do not post raw events, keys or SQLite files publicly.
Next steps
Run the selected provider Sandbox procedure, then test private key email delivery. Review supported recipe limitations before enabling Live.