Apple Create Payment API

Process Apple In-App Purchase receipts to validate and activate subscriptions purchased through the App Store

In-App Purchase

Apple Create Payment API

Validate Apple In-App Purchase receipts from iOS devices. Process subscriptions purchased through the App Store and activate user access automatically.

iOS Native

Seamless integration with Apple's StoreKit framework.

Receipt Validation

Server-side validation ensures purchase authenticity.

Auto Activation

Subscriptions activated immediately upon validation.


Endpoint Overview

MUTATION/graphql

Validate an Apple In-App Purchase receipt and activate the corresponding subscription or purchase. Receipt is validated with Apple's servers.

Authentication:Bearer Token

Request Parameters

receiptStringRequired

The Base64-encoded App Store receipt data obtained from the StoreKit transaction.


GraphQL Mutation

mutation appleCreatePayment($receipt: String) {
  appleCreatePayment(receipt: $receipt)
}

Variables:

{
  "receipt": "MIIbngYJKoZIhvcNAQcCoIIbj..."
}

HTTP Request:

curl -X POST https://api.orbnet.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "query": "mutation appleCreatePayment($receipt: String) { appleCreatePayment(receipt: $receipt) }",
    "variables": {
      "receipt": "MIIbngYJKoZIhvcNAQcCoIIbj..."
    }
  }'

Response

200Receipt Validated Successfully
{
  "data": {
    "appleCreatePayment": true
  }
}
400Invalid Receipt
{
  "errors": [
    {
      "message": "Receipt validation failed",
      "path": ["appleCreatePayment"],
      "extensions": {
        "code": "INVALID_RECEIPT",
        "appleStatus": 21002
      }
    }
  ],
  "data": null
}

iOS Integration Flow

1

Configure StoreKit

Set up your In-App Purchase products in App Store Connect and implement StoreKit in your iOS app.

2

User Makes Purchase

User initiates purchase through StoreKit. Apple handles payment processing.

3

Receive Receipt

After successful purchase, obtain the receipt from the app bundle.

4

Validate Receipt

Send the receipt to this API for server-side validation with Apple.

5

Activate Subscription

On successful validation, user's subscription is activated automatically.


iOS Code Example

import StoreKit

class PurchaseManager {

    func validateReceipt() {
        guard let receiptURL = Bundle.main.appStoreReceiptURL,
              let receiptData = try? Data(contentsOf: receiptURL) else {
            print("No receipt found")
            return
        }

        let receiptString = receiptData.base64EncodedString()

        // Send to your backend
        sendReceiptToBackend(receipt: receiptString)
    }

    func sendReceiptToBackend(receipt: String) {
        let url = URL(string: "https://api.yourapp.com/validate-apple-receipt")!
        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

        let body = ["receipt": receipt]
        request.httpBody = try? JSONEncoder().encode(body)

        URLSession.shared.dataTask(with: request) { data, response, error in
            // Handle response
        }.resume()
    }
}

Apple Receipt Status Codes

0 - Valid

Receipt is valid and subscription has been activated.

21002 - Malformed

Receipt data is malformed or corrupted.

21003 - Unauthenticated

Receipt could not be authenticated.

21004 - Wrong Secret

Shared secret doesn't match. Contact support.

21005 - Server Unavailable

Apple's receipt server is temporarily unavailable.

21006 - Subscription Expired

Receipt is valid but subscription has expired.


Best Practices

Server-Side Validation

Always validate receipts server-side. Never trust client-side validation alone.

Store Receipt

Cache the receipt locally and re-validate on app launch to handle subscription renewals.

Handle Sandbox

During development, receipts are validated against Apple's sandbox environment.

Subscription Monitoring

Implement App Store Server Notifications to track subscription status changes.



App Store Connect Setup

Ensure your In-App Purchase products are properly configured in App Store Connect and your app's StoreKit configuration before implementing this API.

iOS In-App Purchases

Monetize your iOS app with Apple In-App Purchases. Validate receipts server-side for secure, reliable subscription management.

View Stripe Integration