Skip to main content

In-App Purchase

IAP

These endpoints facilitate the validation of purchases made through Google and Apple platforms. Adjustments can be made to the descriptions or details based on specific requirements or additional functionalities.

info

Base Endpoint: api/v1/iap

Available Endpoints

1. Validate Google Purchase

  • Method & Path: POST /validate/google
  • **Description:**This endpoint validates a Google in-app purchase (IAP) for a specific item.
  • Headers:
    • Authorization: Bearer token for user authentication.
  • Request Body:
    • shopItemId: Unique Identifier of shopItem that is to be purchased
    • product: Unique Identifier of product from google play
    • token:Receipt token of paument.
  • Response Body:
    • id: Unique identifier shopItem.
    • shopCategoryId: Unique identifier of shop category.
    • name: Name of shop Item.
    • thumbnail: Thumbnail of shop item.
    • IsIAP: Boolean that determines if the shop item is IAP item or not.
    • price: Cost of shop Item.
    • productId: Identifier of product.
    • spentItem: In case of IAP spend Item is empty array.
    • receiveItem: array of Item to be received.
      • id: Unique identifier of Recieved item.
      • itemId: Unique identifier of inventory item.
      • quantity: Quantity of item to be received.
      • shopItemId: Determined that the item is associated to which shop item.

cURL Command

curl --request POST \
--url https://api.yarsaplay.com/api/v1/iap/validate/google \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json'

Response Body

{
"id": "<uuid>",
"isIAP": "<boolean>",
"name": "<string>",
"price": "<number>",
"productId": "<string,null>",
"receiveItem": [
{
"id": "<uuid>",
"itemId": "<uuid>",
"quantity": "<number>",
"shopItemId": "<uuid>"
},
{
"id": "<uuid>",
"itemId": "<uuid>",
"quantity": "<number>",
"shopItemId": "<uuid>"
}
],
"shopCategoryId": "<uuid>",
"spendItem": [
{
"id": "<uuid>",
"itemId": "<uuid>",
"quantity": "<number>",
"shopItemId": "<uuid>"
},
{
"id": "<uuid>",
"itemId": "<uuid>",
"quantity": "<number>",
"shopItemId": "<uuid>"
}
],
"thumbnail": {
"description": "<string,null>",
"id": "<uuid>",
"name": "<string>",
"uri": "<uri>"
}
}

2. Validate Apple Purchase

  • Method & Path: POST /apple
  • **Description:**This endpoint validates an Apple in-app purchase (IAP) for a specific item.
  • Headers:
    • Authorization: Bearer token for user authentication.
  • Request Body:
    • ShopItemId: Unique Identifier of shopItem that is to be purchased
    • receipt: Receipt token of payment.
  • Response Body:
    • quantity: Quantity associated with the item.
    • product_id: Identifier of the product.
    • transaction_id: Unique identifier for the transaction.
    • original_transaction_id: Original unique identifier for the transaction.
    • purchase_date: Date of the purchase.
    • purchase_date_ms: Milliseconds timestamp of the purchase date.
    • purchase_date_pst: Purchase date in Pacific Standard Time (PST).
    • original_purchase_date: Original date of the purchase.
    • original_purchase_date_ms: Milliseconds timestamp of the original purchase date.
    • original_purchase_date_pst: Original purchase date in Pacific Standard Time (PST).
    • is_trial_period: Indicates if the transaction is associated with a trial period.
    • in_app_ownership_type: Type of ownership for in-app purchases.
    • expires_date: Expiry date of the purchased item (if applicable).
    • expires_date_ms: Milliseconds timestamp of the expiry date (if applicable).
    • expires_date_pst: Expiry date in Pacific Standard Time (PST) (if applicable).
    • web_order_line_item_id: Web order line item identifier (if applicable).
    • is_in_intro_offer_period: Indicates if the transaction is in an introductory offer period (if applicable).
    • subscription_group_identifier: Identifier for the subscription group (if applicable).

cURL Command

curl --request POST \
--url https://api.yarsaplay.com/api/v1/iap/validate/apple \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json'

Response Body

[
{
"expires_date": "<string>",
"expires_date_ms": "<string>",
"expires_date_pst": "<string>",
"in_app_ownership_type": "<string>",
"is_in_intro_offer_period": "<string>",
"is_trial_period": "<string>",
"original_purchase_date": "<string>",
"original_purchase_date_ms": "<string>",
"original_purchase_date_pst": "<string>",
"original_transaction_id": "<string>",
"product_id": "<string>",
"purchase_date": "<string>",
"purchase_date_ms": "<string>",
"purchase_date_pst": "<string>",
"quantity": "<string>",
"subscription_group_identifier": "<string>",
"transaction_id": "<string>",
"web_order_line_item_id": "<string>"
},
{
"expires_date": "<string>",
"expires_date_ms": "<string>",
"expires_date_pst": "<string>",
"in_app_ownership_type": "<string>",
"is_in_intro_offer_period": "<string>",
"is_trial_period": "<string>",
"original_purchase_date": "<string>",
"original_purchase_date_ms": "<string>",
"original_purchase_date_pst": "<string>",
"original_transaction_id": "<string>",
"product_id": "<string>",
"purchase_date": "<string>",
"purchase_date_ms": "<string>",
"purchase_date_pst": "<string>",
"quantity": "<string>",
"subscription_group_identifier": "<string>",
"transaction_id": "<string>",
"web_order_line_item_id": "<string>"
}
]