In App Purchase API documentation version v1
https://client-api.{environment}/api/iap/v1
Iap service handles In App purchase validation and actions from clients.
- environment: required (one of magine.com, tvoli.com - default: magine.com)
/iap/v1/users/{userId}/apple
Validate that the userId does not already have an associated Apple Master Receipt.
Validate that the userId does not already have an associated Apple Master Receipt. A Magine userId may only have one associated Apple id.
Validate that the userId does not already have an associated Apple Master Receipt. A Magine userId may only have one associated Apple id.
post /iap/v1/users/{userId}/apple/can-attach-receipt
Validate that the userId does not already have an associated Apple Master Receipt. A Magine userId may only have one associated Apple id.
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- base64Receipt: required (string)
Base 64 encoded Apple receipt
Example:
{
"base64Receipt": "3hf24nFGnwbnf9pPP2hfnwf0jf"
}
HTTP status code 204
When the receipt was validated without conflict, and a purchase can be finalized.
HTTP status code 409
When the userId already has apple receipts from another apple id
Body
Media type: application/json
Type:
{
"code": 409,
"message": "IapService:canAttachReceipt: Cannot attach apple receipt to magine id. User 2M2MUASW0ZAVVRDD2F3Z6NOLSUSR already has apple receipts from previous apple id",
"errors": []
}
get /iap/v1/users/{userId}/apple/can-attach-receipt
Validate that the userId does not already have an associated Apple Master Receipt. A Magine userId may only have one associated Apple id.
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- base64Receipt: required (string)
Base 64 encoded Apple receipt
Example:
{
"base64Receipt": "3hf24nFGnwbnf9pPP2hfnwf0jf"
}
HTTP status code 204
When the receipt was validated without conflict, and a purchase can be finalized.
HTTP status code 409
When the userId already has apple receipts from another apple id
Body
Media type: application/json
Type:
{
"code": 409,
"message": "IapService:canAttachReceipt: Cannot attach apple receipt to magine id. User 2M2MUASW0ZAVVRDD2F3Z6NOLSUSR already has apple receipts from previous apple id",
"errors": []
}
Validate Apple Receipt and provision subscription
post /iap/v1/users/{userId}/apple/handle-receipt
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- base64Receipt: required (string)
Base 64 encoded Apple receipt
Example:
{
"base64Receipt": "3hf24nFGnwbnf9pPP2hfnwf0jf"
}
HTTP status code 204
When the receipt was processed successfully.
HTTP status code 400
When the receipt data sent from the client was missing or deemed invalid by Apple servers.
HTTP status code 409
The recepit conflicts with existing recepits
Body
Media type: application/json
Type: object
Examples:
master:
{
"message":"Tried to handle Apple receipt for CY5QTKZQRTPU2CLBIL8L5SBOJUSR, but the user already has transactions from a different master receipt/different apple id",
"code":409,
"errors":[]
}
other_user:
{
"message":"Tried to handle Apple receipt for CY5QTKZQRTPU2CLBIL8L5SBOJUSR, but the receipt already belonged to another user (2HSVWH0W1W8O05P5Y3UVH83X8USR)",
"code":409,
"errors":[]
}
HTTP status code 502
Apple receipt verification servers were down.
/iap/v1/users/{userId}/google
Validate Google Receipt and provision subscription
post /iap/v1/users/{userId}/google/handle-receipt
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- receipts: required (array of GoogleReceipt)
List of json Google receipts
Items: GoogleReceipt
- orderId: required (string)
- packageName: required (string)
- productId: required (string)
- purchaseTime: required (number)
- purchaseState: required (number)
- developerPayload: required (string)
- purchaseToken: required (string)
Example:
{
"receipts": [
{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345678900000,
"purchaseState":0,
"developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
},
{
"orderId":"12999763169054705758.1371079406387617",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345618900000,
"purchaseState":0,
"developerPayload":"aGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"bojeslcdyyiapnqcynkjyyjh"
}
]
}
HTTP status code 204
When the receipt was processed successfully.
HTTP status code 400
If any error occurred
Body
Media type: application/json
Type:
{
"status": 400,
"message": "<error message>",
"errors": ["<google errors>"]
}
HTTP status code 403
Receipts developerPayload did not match user-id in request
Body
Media type: application/json
Type:
{
"status": 403,
"message": "Receipts developerPayload did not match user-id in request",
"errors": []
}
/iap/v1/users/{userId}/amazon
Validate Amazon Receipt and provision subscription
post /iap/v1/users/{userId}/amazon/handle-receipt
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- amazonUserId: required (string)
- receipts: required (array of AmazonReceipt)
List of json Amazon receipts
Items: AmazonReceipt
- amazonReceiptId: required (string)
Example:
{
"amazonUserId": "AMZ-USER-ID",
"receipts": [
{
"amazonReceiptId": "AMZ-RECEIPT-ID1"
},
{
"amazonReceiptId": "AMZ-RECEIPT-ID2"
}
]
}
/iap/v1/users/{userId}/psn
Poll Sony to get a user's purchases
post /iap/v1/users/{userId}/psn/refresh-tickets
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- authorizationCode: required (String)
- psnPlus: required (Boolean)
- apiHost: required (String)
- baseUrl: required (String)
Get a list of PSN products from Sony
post /iap/v1/users/{userId}/psn/products
URI Parameters
- userId: required (string)
Headers
- Magine-AccessToken: required (string)
A token that identifies a specific partner
Example:
25b70ae1-d2bd-4ae7-85f4-62026580c866
- Authorization: required (string)
Bearer < login token >
Example:
Bearer 4b6fbf80...
Body
Media type: application/json
Type: object
Properties- authorizationCode: required (String)
- apiHost: required (String)
- baseUrl: required (String)