PG payment
Hive IAP v4 supports PG payment on PC and mobile environments. In the PC environment, the payment request screen below is displayed in a new window.
Before applying PG payment, check the Hive PG payment policy and register the necessary information in the console according to the pre-work of the PG payment console guide.
PG payment features¶
The main features of Hive PG payment are as follows.
-
Hive PG payment operates based on Hive IAP v4 and PG Payment API, and is processed asynchronously through the web browser provided by the payment agency (PG).
-
The information registered in advance in the console is reflected in the product price and product information required for store configuration, and information about the product is transmitted through Hive SDK v4.
-
If a URL to receive payment results is registered in the console, the payment results are sent to that URL. Depending on the payment method, there are situations where the payment results cannot be transmitted immediately. (Example: Virtual account deposit)
-
Orders for which payment has been completed must be processed for product payment completion through the
transactionFinish(marketPid)
API. -
If you want to repurchase a product for which payment has been completed but payment completion processing has not been completed, the payment will not proceed. You can repurchase after the payment completion processing of the previously purchased product.
-
If you attempt to purchase additional products for which payment has not been completed, such as when you open multiple payment windows while payment has not been completed, only the first payment will be completed, and the remaining purchases will be automatically canceled even if they are paid.
-
Payments may be canceled at the game server's discretion even if a payment completion processing request is made.
PG payment process¶
The PG payment operation process that applies the Hive SDK is as follows.
- Call
hive.IAPV4.purchase(marketPid, iapPayload, onIAPV4PurchaseCB)
to request a purchase -
After the purchase is complete, the receipt information in the form of
bypassInfo
is sent to the game server through theonIAPV4PurchaseCB
argumentNote
Hive Starting with SDK 25.1.0, the purchase completion signal is sent from the SDK, not the IAP server.
-
Hive Proceed with receipt verification on the IAP server
Note
If you register a URL to receive the payment result in the console, you will receive a duplicate purchase completion signal from the SDK, so you must either not register a URL to receive the payment result in the console, or you must handle duplicate receipts.
- Call
hive.IAPV4.transactionFinish(marketPid)
to complete payment of the product
Multi-quantity purchase¶
Hive PG Payment supports multi-quantity purchases. By specifying the quantity when requesting a purchase, you can purchase more than one of the same in-app products in one payment.
Hive SDK calls hive.IAPV4.purchase(marketPid, iapPayload, quantity, onIAPV4PurchaseCB)
with the quantity
parameter, which allows you to specify the quantity.
Note
Multi-quantity purchases are only supported for consumable in-app products that can be repurchased. Be careful not to repeatedly purchase one-time products.
Example code for requesting a multi-quantity purchase is as follows.
API Reference: [hive .IAPV4.purchase](http://developers.withhive.com/HTML/v4_api_reference/Unity3D/group___i_a_p_v4.html#ga4f5a16cebe1b2b1fab22126faacafbec)
```cs
using hive;
String marketPid = "{YOUR_PRODUCT_MARKET_PID}";
String iapPayload = "{YOUR_CUSTOM_PAYLOAD}";
int quantity = 3;
IAPV4.purchase(marketPid, iapPayload, quantity, (ResultAPI result, IAPV4Receipt receipt) => {
if (result.isSuccess()) {
// TODO: Request verification of receipt with received receipt
}
});
```
```c++
#include "HiveIAPV4.h"
FString MarketPid = TEXT("YOUR_PRODUCT_MARKET_PID");
FString IapPayload = TEXT("YOUR_CUSTOM_PAYLOAD");
int32 Quantity = 3;
FHiveIAPV4::Purchase(MarketPid, IapPayload, Quantity, FHiveIAPV4OnPurchaseDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveIAPV4Receipt& Receipt) {
if (Result.IsSuccess()) {
// API call successful
}
}));
```
API Reference: [IAPV4 ::purchase](http://developers.withhive.com/HTML/v4_api_reference/CPP/group___i_a_p_v4.html#ga2bff8cc9d70d0a25eaddc9d45dac86b8)
```cpp
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
string marketPid = "{YOUR_PRODUCT_MARKET_PID}";
string iapPayload = "{YOUR_CUSTOM_PAYLOAD}";
int quantity = 3;
IAPV4::purchase(marketPid, iapPayload, quantity, [=](ResultAPI const & result, IAPV4Receipt const & receipt) {
if (result.isSuccess()) {
// TODO: Request verification of receipt with received receipt
}
});
```
API Reference: [com.hive.IAPV4.purchase](https://developers.withhive.com/HTML/dokka/-hive%20-s-d-k%20v4/com.hive/-i-a-p-v4/purchase.html)
```kt
import com.hive.IAPV4
import com.hive.ResultAPI
val marketPid = "{YOUR_PRODUCT_MARKET_PID}"
val iapPayload = "{YOUR_CUSTOM_PAYLOAD}"
val quantity = 3
IAPV4.purchase(marketPid, iapPayload, quantity, object : IAPV4.IAPV4PurchaseListener {
override fun onIAPV4Purchase(result: ResultAPI, iapV4Receipt: IAPV4.IAPV4Receipt?) {
if (result.isSuccess) {
// call successful
}
}
})
```
API Reference: [com .hive.IAPV4.purchase](https://developers.withhive.com/HTML/v4_api_reference/Android/group___i_a_p_v4.html#gad5e467681ef02fc2ab393bad201e617c)
```java
import com.hive.IAPV4;
import com.hive.ResultAPI;
String marketPid = "{YOUR_PRODUCT_MARKET_PID}";
String iapPayload = "{YOUR_CUSTOM_PAYLOAD}";
int quantity = 3;
IAPV4.INSTANCE.purchase(marketPid, iapPayload, quantity, (result, iapV4Receipt) -> {
if (result.isSuccess()) {
// call successful
}
});
```
API Reference: [HIVEIAPV4::purchase:additionalInfo:handler:](https://developers.withhive.com/documentation/hiveiapv4/iapv4interface/purchase(_:iappayload:handler:))
```swift
import HIVEService
let marketPid = "{YOUR_PRODUCT_MARKET_PID}"
let iapPayload = "{YOUR_CUSTOM_PAYLOAD}"
let quantity = 3
HIVEIAPV4.purchase(marketPid, iapPayload, quantity) { result, receipt in
if result.isSuccess() {
// TODO: Request verification of receipt with received receipt
}
}
```
<strong>API Reference</strong>: <a href="[cgv hive_sdk4_ios_api_ref_en]/group___i_a_p_v4.html#ga4cd19176f947717f2c7be545ed76a6e0" target="_blank" rel="noopener noreferrer">HIVEIAPV4::purchase:additionalInfo:handler:</a >
```objc
#import <HIVEService/HIVEService-Swift.h>
NSString *marketPid = @"{YOUR_PRODUCT_MARKET_PID}";
NSString *iapPayload = @"{YOUR_CUSTOM_PAYLOAD}";
NSNumber quantity = 3;
[HIVEIAPV4 purchase: marketPid iapPayload: iapPayload quantity handler: ^(HIVEResultAPI *result, HIVEIAPV4Receipt *receipt) {
if ([result isSuccess]) {
// TODO: Request verification of receipt with received receipt
}
}];
```