Purchases
Buyer-side purchase management. Requires authentication.
GET /purchases
List purchases and active subscriptions for the authenticated buyer email.
curl https://api.paylinks.ro/api/v1/purchases \
-H "Authorization: Bearer YOUR_TOKEN"
Response (200):
{
"items": [
{
"id": "sub_123456",
"payLinkId": "cm7v4r7mn0003gk2s1aq0m9f8",
"payLinkName": "Premium Course",
"sellerId": "cm7v3k5h300001z3s4b2n7q9d",
"succeededAt": "2026-02-16T14:30:00.000Z",
"productName": "Premium Course",
"productCoverImageUrl": "https://cdn.paylinks.ro/...",
"serviceType": "DIGITAL_PRODUCT",
"assets": [
{ "key": "uploads/products/course.pdf", "name": "course.pdf" }
],
"type": "subscription",
"subscriptionStatus": "ACTIVE",
"subscriptionInterval": "month",
"currentPeriodEnd": "2026-03-16T14:30:00.000Z",
"cancelAtPeriodEnd": false,
"amount": 9900,
"currency": "RON"
},
{
"id": "tx_123456",
"payLinkId": "cm7v4r7mn0003gk2s1aq0m9f8",
"payLinkName": "Premium Course",
"sellerId": "cm7v3k5h300001z3s4b2n7q9d",
"succeededAt": "2026-02-10T11:00:00.000Z",
"productName": "Premium Course",
"productCoverImageUrl": "https://cdn.paylinks.ro/...",
"serviceType": "DIGITAL_PRODUCT",
"assets": [
{ "key": "uploads/products/course.pdf", "name": "course.pdf" }
],
"type": "purchase",
"amount": 9900,
"currency": "RON"
}
]
}
POST /purchases/presign
Get a presigned URL for a purchased digital asset.
curl -X POST https://api.paylinks.ro/api/v1/purchases/presign \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"payLinkId": "cm7v4r7mn0003gk2s1aq0m9f8",
"key": "uploads/products/course.pdf"
}'
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
payLinkId | string | Yes | PayLink ID that owns the digital product |
key | string | Yes | Exact R2 object key of the purchased asset |
Response (200):
{
"url": "https://files.paylinks.ro/..."
}
Response (404): Purchase/asset not found for this buyer.
POST /purchases/cancel-subscription
Cancel a buyer subscription at period end.
curl -X POST https://api.paylinks.ro/api/v1/purchases/cancel-subscription \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"subscriptionId":"sub_123456"}'
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
subscriptionId | string | Yes | Subscription ID |
Response (200):
{
"success": true,
"message": "Subscription will be canceled at the end of the current billing period"
}
Response (404): Subscription not found or does not belong to requester.