1. Start Purchasing
Start product purchase with UMyStoveSDKObject::StoveSDKStartPurchase.
// input parameters
// const TArray<FStoveOrderProduct> Products: Order product information
// ProductSize: number of ordered products
FStoveResult UMyStoveSDKObject::StoveSDKStartPurchase(const TArray<FStoveOrderProduct> Products, const int ProductSize)
{
/*Add the 'walkthrough' codes here.*/
FStoveResult ErrorResult = Super::StoveSDKStartPurchase(Products, ProductSize);
if (ErrorResult.Result == StovePCResult::STOVE_PC_NO_ERROR)
{
// success handling
}
return ErrorResult;
}
C++
복사
When the UMyStoveSDKObject::StoveSDKStartPurchase function is successfully processed, the OnStartPurchase callback is called.
The FStovePurchase structure passed to the callback contains meta information about product purchase.
•
FStovePurchase.TransactionMasterNo: Unique Transaction Master Number
•
FStovePurchase.TempPaymentUrl: One-time URL for payment
•
FStovePurchase.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 UMyStoveSDKObject::OnStartPurchase(FStovePurchase Purchase)
{
/*Add the 'walkthrough' codes here.*/
OnLog("[OnStartPurchase]");
OnLog(" TransactionMasterNo : %I64d", Purchase.TransactionMasterNo);
OnLog(" TempPaymentUrl : %s", *(Purchase. TempPaymentUrl));
OnLog(" PurchaseProgress : %d", Purchase. PurchaseProgress);
if (Purchase. PurchaseProgress == 1)
{
FWindowsPlatformProcess::LaunchURL(*(Purchase. TempPaymentUrl), nullptr, nullptr);
}
else if(Purchase. PurchaseProgress == 2)
{
//Process purchase completion (e.g. purchase completion message box)
}
}
C++
복사
If an error occurs while running UMyStoveSDKObject::StoveSDKStartPurchase function, the OnError callback is called. External errors can be checked through the ExternalError field of the FStoveError structure.
Normally, when the OnError callback is called for the UMyStoveSDKObject::StoveSDKStartPurchase 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. |