In-App Purchases
It’s a one-time payment SDK used for products completed with a single purchase, such as consumables and non-consumables. For an introduction to the service and how to set up the console, In-app Purchase introduction documentplease refer to.
Follow the sequence below for the integration flow.
Get product list —
getProductItemListRequest payment —
createOneTimePurchaseOrderRestore pending orders —
getPendingOrders,completeProductGrantCheck order status —
getCompletedOrRefundedOrdersor Order status inquiry API
IAP object
IAPis an object that contains in-app purchase-related functions.
Signature
Properties
getProductItemListtypeof getProductItemList
This is a function that retrieves the list of products that can be purchased with in-app purchases. For details, getProductItemListPlease refer to it.
createOneTimePurchaseOrdertypeof createOneTimePurchaseOrder
This is a function that requests an in-app purchase. For details, createOneTimePurchaseOrderPlease refer to it.
getPendingOrderstypeof getPendingOrders
It retrieves the list of pending orders. For details, getPendingOrders refer to the document.
getCompletedOrRefundedOrderstypeof getCompletedOrRefundedOrders
It retrieves the list of orders purchased or refunded through in-app purchases. For details, getCompletedOrRefundedOrders refer to the document.
completeProductGranttypeof completeProductGrant
It sends a message to the app that product grant processing has been completed. For details, completeProductGrant refer to the document.
View product list
SDK function: getProductItemList
getProductItemList This is a function that contains the list of products purchasable with in-app purchases. Use it to display the product list on screen.
Signature
Return value
Promise<{ products: IapProductListItem\[] } | undefined>Returns an object containing the product list. If the app version is lower than the minimum supported version (5.219.0),
undefinedis returned.
Properties
IapProductListItem
This is an object containing information about a single product that can be purchased with in-app purchases. Use it to display the product list on screen.
sku · Required ·
stringThe product's unique ID. IAP.createOneTimePurchaseOrderused when calling
productIdhas the same value as.
Example
Get purchasable in-app purchase product list
Example response
Try the sample app
apps-in-toss-examples from the repository with-in-app-purchase Download the code and try it out.
Request a one-time payment
SDK function: createOneTimePurchaseOrder
createOneTimePurchaseOrder This function opens the in-app purchase payment sheet and the user proceeds with payment. If an error occurs during payment, the app navigates to an error page depending on the error type.
Signature
Parameters
options · Required
This is a required option for in-app purchases.
params.sku · Required ·
stringThe ID of the product to order.
params.processProductGrant · Required ·
(params: { orderId: string }) => boolean | Promise<boolean>Called when actually granting the product after the order is created.
orderIdreceives it and returns whether the grant succeeded astrueorPromise<true>If granting fails, returnsfalseis returned.
onEvent · Required ·
(event: SuccessEvent) => void | Promise<void>Called when payment succeeds.
event.type · Required ·
"success"This is the event type.
"success"is returned.event.data · Required ·
IapCreateOneTimePurchaseOrderResultWhen the in-app purchase is completed, it returns the payment details and product information. You can use the returned information to display the purchased product information on screen.
event.data.orderId · Required ·
stringThis is the payment order ID. Used to query payment status after payment is completed. query the payment statuswhen needed.
event.data.displayName · Required ·
stringThe product name to display on screen.
event.data.displayAmount · Required ·
stringThe price information including the currency unit.
event.data.amount · Required ·
numberThe numeric value of the product price.
event.data.currency · Required ·
stringThe currency unit of the product price.
event.data.fraction · Required ·
numberThe value that determines how many decimal places to show when displaying the price.
event.data.miniAppIconUrl ·
string | nullURL of the mini app icon image.
onError · Required ·
(error: unknown) => void | Promise<void>Called when an error occurs during payment. You can receive the error object to log it or run recovery steps.
Error code
INVALID_PRODUCT_ID : The product ID is invalid, or the product does not exist. Please check the product ID.
Occurs when the product ID is invalid or the product does not exist.
Return value
() => void
Returns the App Bridge cleanup function. When the in-app purchase feature ends, you must call this function to release resources.
Example
Go to a specific in-app purchase order page
Try the sample app
apps-in-toss-examples from the repository with-in-app-purchase Download the code and try it out.
View pending orders
SDK function: getPendingOrders
getPendingOrders is the list of orders for which payment has been completed but the product has not yet been grantedRetrieve it and grant the product to the user. createOneTimePurchaseOrder You can query the order even if you did not receive a result after calling the function.
If the app version is lower than the minimum supported version (Android 5.234.0, iOS 5.231.0), undefinedis returned.
Signature
Return value
Promise<{ orders: Order\[] } | undefined>Returns an object containing the list of pending orders (orders). If the app version is lower than the minimum supported version (Android 5.234.0, iOS 5.231.0),
undefinedis returned.
Returned object properties
orders · Required ·
Order\[]An array of pending orders. Returns an empty array if there are no pending orders.
orders[].orderId · Required ·
stringThe order's unique ID.
orders[].sku · Required ·
stringThe unique ID of the ordered product.
orders[].paymentCompletedDate · Required ·
stringIndicates when the payment was completed.
Example
Complete product grant processing
SDK function: completeProductGrant
completeProductGrant The function that completes product grant processing for pending ordersfor pending orders. Grant the product to the user and completeProductGrant call the function to change the grant status to completed.
If the app version is lower than the minimum supported version (Android 5.231.0, iOS 5.231.0), undefinedis returned.
Signature
Parameters
{ params: { orderId: string } }
This is an object containing order information for which payment has been completed.
params.order ·
Id stringThe order's unique ID. Use it when specifying the order whose product grant should be completed.
Return value
Promise<boolean | undefined>Returns whether the product grant has been completed. If the app version is lower than the minimum supported version (Android 5.233.0, iOS 5.233.0),
undefinedis returned.
Example
View completed/refunded orders
SDK function: getCompletedOrRefundedOrders
getCompletedOrRefundedOrders It retrieves the list of orders purchased and refunded through in-app purchases. You can query orders with completed in-app purchase payment and product grant, as well as refunded orders.
Orders whose payment is complete but whose product has not yet been granted are not retrieved. getPendingOrdersThrough the function orderIdquery it and grant the product to the user, then completeProductGrantcomplete product grant processing using the function.
If the app version is lower than the minimum supported version (Android 5.231.0, iOS 5.231.0), undefinedis returned.
Signature
Return value
Promise<{ CompletedOrRefundedOrdersResult } | undefined>Returns an order list object including pagination. If the app version is lower than the minimum supported version (Android 5.231.0, iOS 5.231.0),
undefinedis returned.
Returned object properties
hasNext · Required ·
booleanIndicates whether there is a next page.
`true`If `true`, there are more orders remaining.nextKey optional ·
string | null · nullThis is the cursor key for fetching the next page. Use the
nextKeyvalue from the previous response. On the first call, omit it ornullpass it.orders · Required ·
ArrayAn array containing order information. Each element represents one order.
orders[].orderId · Required ·
stringThe order's unique ID.
Example
You can directly query in-app purchase order status via the API from the server. You can use it even if you did not receive an approval or refund response.
Content-type:
application/jsonMethod:
POSTURL:
/api-partner/v1/apps-in-toss/order/get-order-statusRequest headers
If the header is not included, all orders are returned.
In the header,
x-toss-user-keyif you include the value, only orders for that userKey are returned.Request parameters
Response
status (enum)
Response example
Before release, be sure to sandbox app environmenttest whether in-app purchases work properly. In Sandbox, no actual payment (billing) occurs, and all payments are handled as test scenarios.
1. Behavior when checking the product list in Sandbox
In the Sandbox app,
getProductItemList()when called, among the in-app purchase products registered in the console, only those with display status ONare retrieved.The list of products registered in the actual console is returned as is.
In the console, display OFFproducts are not visible in the Sandbox app either.
2. Required test scenarios
In Sandbox, you must perform the following three tests individually. Please check whether the app responds correctly in each scenario.
① Payment success test
Success callback (
event.type: success) is delivered correctly.No actual payment (billing) occurs.
In SDK 1.1.3 or later, the partner's the item delivery logic must also succeed for the final successto be treated as successful.
[Watch video](../../../../resources/development/iap/iap_sandbox_test_1.mp4)
② Payment success (server failure) test
You must test the case where payment succeeds but the partner server's delivery logic fails.
The app must support the following handling:
After delivery completion
completeProductGrantcallWhen the app is relaunched
getPendingOrdersrestore pending orders withNotify the user of delivery failure
This is a scenario that can occur frequently in production as well, so be sure to test it.
[Watch video](../../../../resources/development/iap/iap_sandbox_test_2.mp4)
③ Error test
Simulate various situations where errors occur during payment in advance.
[Watch video](../../../../resources/development/iap/iap_sandbox_test_3.mp4)
3. Test checklist
Product list display
✔️
Whether the products registered in the console are returned properly
Payment success test
✔️
event.data Processing, delivery logic, UI handling
Payment success + server delivery failure (order restoration)
✔️
Pending order restoration and re-delivery handling
Error test
✔️
Error UI, error handling, retry flow
Order status inquiry API
Recommended
Server validation and consistency checks
PURCHASED
Order completed
State where both in-app payment and item delivery are complete
PAYMENT_COMPLETED
Payment completed
In SDK 1.1.3 or later, payment is complete but item delivery failed
FAILED
Order failed
When payment fails
REFUNDED
Order refunded
When the refund is complete
ORDER_IN_PROGRESS
Order in progress
When the order has been created but payment/delivery processing is not complete
NOT_FOUND
No order
When the corresponding order number cannot be found
MINIAPP_MISMATCH
Product mismatch
When the ordered product is not a product for the app
ERROR
Internal error
When an internal system error occurs
orderId
String
Requested order number
sku
String
Ordered product ID
statusDeterminedAt
String
Order completion date/time (yyyy-MM-dd'T'HH🇲🇲ss, fixed to KST) statusis REFUNDEDIf so, refund completion date/time
status
String
Status for the order (enum)
reason
String
Description of the status
orderId
String
Y
Order number acquired after payment creation (UUID v7)
x-toss-user-key
string
N
userKey value obtained through Toss Login
Last updated
Was this helpful?