1. Start Purchasing
Start purchasing a product with StovePC_StartPurchase.
// input parameters
// StovePCOrderProduct* products: Order product information
// Size: number of ordered products
StovePCResult result = StovePC_StartPurchase(products, size);
if(result == StovePCResult::STOVE_PC_NO_ERROR)
{
// handle success
}
C++
복사
When the StovePC_StartPurchase function is successfully processed, the OnStartPurchase callback is called.
The StovePCPurchase structure passed to the callback contains meta information about product purchase.
•
StovePCPurchase.TransactionMasterNo: Unique Transaction Master Number
•
StovePCPurchase.TempPaymentUrl : One-time URL for payment
•
StovePCPurchase.PurchaseProgress : Purchase progress status
◦
1: Payment in progress (page displayed in external browser or webview using TempPaymentUrl)
◦
2: Purchase complete (Payment is completed due to the purchase of a product with a selling price of 0, so it is not necessary to display the page in an external browser or webview using TempPaymentUrl) (optional)
◦
Note: PurchaseProgress 2 is only used when you have a product which is priced 0 (free)
When necessary, the game opens up the one-time payment URL through an external browser (or built-in browser).
void OnStartPurchase(StovePCPurchase purchase)
{
printf("OnStartPurchase");
printf(" - transactionMasterNo : %lld", purchase.transactionMasterNo);
printf(" - tempPaymentUrl : %s", purchase.tempPaymentUrl);
printf(" - purchaseProgress : %d", purchase.purchaseProgress);
if(purchase.purchaseProgress == 1)
{
// open external browser
ShellExecute( NULL, "open", purchase. tempPaymentUrl, NULL, NULL, SW_SHOWNORMAL);
}
else if(purchase.purchaseProgress == 2)
{
// Processing purchase completion (e.g. purchase completion message box)
}
}
C++
복사
If an error occurs while running StovePC_StartPurchase function, the OnError callback is called. External errors can be checked through the ExternalError field of the StovePCError structure.
Normally, when the OnError callback is called for the StovePC_StartPurchase function call, the game exposes a message about the failure to the game user. The table below provides a guide on what messages to display to game users.
ExternalError | Description | Message to User |
500 | Internal Server Error | Temporary error, please try again later. |
50001 | Store does not exist, or is under maintenance | The service is under maintenance. |
50002 | Product does not exist, or is unavailable for sale | This product cannot be purchased due to maintenance. |
50003 | Non-exhibited products | This product is not currently available for purchase. |
50004 | Products’ available duration is over | This product is not currently available for purchase. |
50005 | Product price is inconsistent
(check if product price is changed) | Product price information has been changed. |
50009 | Exceeds maximum amount for purchase per user | You have exceeded the maximum amount for purchase |
50010 | Exceeds the total number of sales available for purchase | No more quantities left |
50031 | Purchase quanty is “0” | Please select 1 or more quantity |
999999 | undefined error | The service is encountering unexpected error. |