Skip to main content

Buy Store Bundle

This method initiates a transaction to purchase a specific bundle from your reward store. Upon successful initiation, it returns a unique transaction ID, which can be used to track the status and progress of the transaction.

Endpoint

POST /v1/store/buy

Request Body

ParameterTypeRequiredDescription
playerIdstringYesUnique identifier for the player
referenceIdstringYesUnique identifier for the store bundle (bundle UID)

Example Request

{
"referenceId": "{{bundleID}}",
"playerId": "{{playerID}}"
}

Response

Success Response

{
"code": 200,
"message": "Purchase successful",
"data": {
"transactionId": "tx-f4a7c1b9-3e5d",
"playerId": "{{playerID}}",
"bundleId": "{{bundleID}}",
"status": "completed"
}
}

Error Response

{
"code": 4003,
"message": "Insufficient funds"
}

Request Example

curl -X POST https://api.rapidmule.com/v1/store/buy \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"referenceId": "{{bundleID}}",
"playerId": "{{playerID}}"
}'

Use Cases

  • Store Purchase Flow: Complete purchase flow with inventory checks and error handling
  • Stock Validation: Check bundle stock availability before initiating purchase
  • Transaction Tracking: Track purchases using transaction IDs for auditing and support

Error Codes

CodeDescriptionResolution
1001Payload is nullCheck request body
1002Invalid PlayerVerify playerId exists
4001Invalid AuthKeyVerify API key
4003Insufficient fundsPlayer doesn't have enough currency
9008Bundle does not existUse valid bundleId
9009Bundle out of stockCheck stock availability

Best Practices

  1. Pre-purchase Validation: Always check player's currency and bundle availability before purchase
  2. Error Handling: Implement comprehensive error handling for all failure scenarios
  3. Transaction Logging: Store transaction IDs for auditing and support purposes
  4. UI Feedback: Provide clear feedback to users about purchase success or failure
  5. Inventory Refresh: Refresh player inventory after successful purchase
Important

This endpoint deducts currency from the player's inventory. Ensure proper validation before calling to prevent accidental purchases.

Related Endpoints