Register in-game payment records. Registered payments are automatically attributed to the user’s sponsored creator.
Flow
1. In-game payment complete → 2. Send payment info via API → 3. Creator attribution + settlement
Create Payment
Request
curl -X POST "https://sandbox-sdk-api.playcamp.io/v1/server/payments" \
-H "Authorization: Bearer ak_server_xxx:secret" \
-H "Content-Type: application/json" \
-d '{
"userId": "user_12345",
"transactionId": "txn_abc123",
"productId": "gem_pack_100",
"productName": "100 Gem Pack",
"amount": 9900,
"currency": "KRW",
"platform": "Android",
"distributionType": "MOBILE_STORE",
"purchasedAt": "2024-01-15T10:30:00.000Z"
}'
const payment = await server.payments.create({
userId: 'user_12345',
transactionId: 'txn_abc123',
productId: 'gem_pack_100',
productName: '100 Gem Pack',
amount: 9900,
currency: 'KRW',
platform: 'Android',
distributionType: 'MOBILE_STORE',
purchasedAt: new Date('2024-01-15T10:30:00Z'),
});
purchasedAt, _ := time.Parse(time.RFC3339, "2024-01-15T10:30:00Z")
payment, err := server.Payments.Create(ctx, playcamp.CreatePaymentParams{
UserID: "user_12345",
TransactionID: "txn_abc123",
ProductID: "gem_pack_100",
ProductName: playcamp.String("100 Gem Pack"),
Amount: 9900,
Currency: "KRW",
Platform: playcamp.PaymentPlatformAndroid,
DistributionType: playcamp.String("MOBILE_STORE"),
PurchasedAt: purchasedAt,
})
Response (201 Created)
{
"data": {
"id": 1234,
"transactionId": "txn_abc123",
"userId": "user_12345",
"productId": "gem_pack_100",
"productName": "100 Gem Pack",
"amount": 9900,
"currency": "KRW",
"platform": "Android",
"campaignId": "campaign_001",
"creatorKey": "ABC12",
"status": "COMPLETED",
"purchasedAt": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-15T10:30:05.000Z"
}
}
Required Parameters
| Field | Type | Description |
|---|
userId | string | In-game user identifier |
transactionId | string | Platform-specific unique transaction ID (for deduplication) |
productId | string | Product ID |
amount | number | Payment amount |
currency | string | Currency code (ISO 4217: USD, KRW recommended) |
platform | string | Platform (iOS, Android, Web, Roblox, Other) |
distributionType | string | Distribution type (see below) |
purchasedAt | string | Actual payment timestamp (ISO 8601) |
Distribution Type (Required)
distributionType is a required parameter when registering payments. It’s used for settlement calculation.
| Value | Description | Store Fee |
|---|
MOBILE_STORE | Mobile external store (Google Play, App Store) | 30% |
PC_STORE | PC external store (Steam, etc.) | 30% |
MOBILE_SELF_STORE | Mobile self-payment | 0% |
PC_SELF_STORE | PC self-published store | 0% |
Settlement Calculation: Net Amount = Payment Amount × (1 - Store Fee), then PlayCamp platform fee and creator fee are applied separately.Important: Specify the value matching the actual distribution channel where the payment occurred for accurate settlement.
Currency Conversion
For non-USD currencies, amount is automatically converted to USD (amountUsd field).
// KRW payment example
{ amount: 9900, currency: "KRW" }
// → amountUsd: 7.62 (auto-calculated)
Refund Payment
curl -X POST "https://sandbox-sdk-api.playcamp.io/v1/server/payments/txn_abc123/refund" \
-H "Authorization: Bearer ak_server_xxx:secret" \
-H "Content-Type: application/json" \
-d '{}'
const refund = await server.payments.refund('txn_abc123');
payment, err := server.Payments.Refund(ctx, "txn_abc123", nil)
Refunded amounts are deducted from settlement.
Error Handling
| HTTP | Code | Description |
|---|
| 400 | VALIDATION_ERROR | Missing required parameter |
| 409 | CONFLICT | Duplicate transactionId |