Creating Purchases
Create a payment and get a checkout URL for the customer.
Endpoint
POST /api/purchases/create/
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
cws_id | string | Yes | Application identifier |
sku | string | Yes | Product SKU |
email_address | string | Yes* | Customer email address |
google_account_id | string | Yes* | Customer Google Account ID |
major_currency | string | Yes | Payment currency ISO code (e.g. "USD") |
minor_currency | string | Yes | Product pricing currency ISO code (e.g. "USD") |
subscription_type | string | No | "MONTH" or "YEAR" — disambiguates pricing tier |
success_url | string | No | URL to redirect after successful payment |
cancel_url | string | No | URL to redirect if payment is cancelled |
coupon | string | No | Coupon 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"
}
| Field | Type | Description |
|---|---|---|
id | string | Purchase identifier |
invoice | string | PWP invoice URL (always present, universal fallback) |
location | string | null | PayPal checkout URL, or null for free-tier products |
status | string | "PENDING" or "PAID" (for $0 products) |
Status Lifecycle
- PENDING — awaiting customer payment
- PAID — payment captured, subscription created/extended
- CANCELLED — customer cancelled at checkout
- EXPIRED — payment window expired
Free Products ($0)
Products priced at $0 are resolved immediately without a payment gateway. The response will have status: "PAID" and location: null.
Errors
| Status | Body | Cause |
|---|---|---|
| 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 |