← Back to docs

Creating Purchases

Create a payment and get a checkout URL for the customer.

Endpoint

POST /api/purchases/create/

Request Body

FieldTypeRequiredDescription
cws_idstringYesApplication identifier
skustringYesProduct SKU
email_addressstringYes*Customer email address
google_account_idstringYes*Customer Google Account ID
major_currencystringYesPayment currency ISO code (e.g. "USD")
minor_currencystringYesProduct pricing currency ISO code (e.g. "USD")
subscription_typestringNo"MONTH" or "YEAR" — disambiguates pricing tier
success_urlstringNoURL to redirect after successful payment
cancel_urlstringNoURL to redirect if payment is cancelled
couponstringNoCoupon code

* One of email_address or google_account_id is required.

Response

{
  "id": "abc123",
  "invoice": "https://pay.with.pink/purchases/abc123/",
  "location": "https://www.paypal.com/checkoutnow?token=...",
  "status": "PENDING"
}
FieldTypeDescription
idstringPurchase identifier
invoicestringPWP invoice URL (always present, universal fallback)
locationstring | nullPayPal checkout URL, or null for free-tier products
statusstring"PENDING" or "PAID" (for $0 products)

Status Lifecycle

Free Products ($0)

Products priced at $0 are resolved immediately without a payment gateway. The response will have status: "PAID" and location: null.

Errors

StatusBodyCause
400{"error": "Missing parameter: cws_id"}Missing required field
400{"error": "Invalid subscription_type. Must be MONTH or YEAR."}Bad subscription_type
400{"error": "..."}Currency not supported for product
404{"error": "..."}Application or product not found