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​

A purchase is fulfilled immediately: the provision is created, the currency is charged, the bundle contents are granted, and the transaction is returned already in the Completed state.

{
"code": 200,
"data": {
"playerId": "{{playerID}}",
"provisionUid": "3753bdcd92804b20bf93039c8c3cb44f",
"cost": 50.00,
"costLabel": "Coins",
"costDeliverableUid": "41c8680620d94498b295e53e7db96045",
"status": "Completed",
"updateDate": 1784015804551,
"deliverables": [
{
"amount": 1.00,
"label": "Football Jersey",
"type": 1,
"imageName": "https://rapidmulestorage.blob.core.windows.net/images/d73830ad-d553-4871-bf3c-98839cd8c29e_jersey.png",
"details": null
}
]
}
}

Response Fields​

FieldTypeDescription
playerIdstringThe player who made the purchase
provisionUidstringUID of the provision (transaction) created — use it with the Store Transactions endpoints
costnumberAmount of currency charged
costLabelstringDisplay name of the currency spent
costDeliverableUidstringUID of the deliverable used as currency
statusstringTransaction status — a successful purchase returns Completed
updateDatelongUnix timestamp (ms) the transaction was last updated
deliverablesarrayItems granted to the player by the purchase

Error Response​

{
"code": 9001,
"data": "Insufficient funds to commit the action"
}

Request Example​

curl -X POST https://api.rapidmule.com/v1/store/buy \
-H "AuthKey: 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
9001Insufficient funds to commit the actionPlayer 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