TypeScript
Description
Only registered partners can use this feature. Unregistered partners may test on the testnet using the secret key provided in the sample code.
This is a feature required to build the point payment system. Please create a wallet to be used for payments, and provide its address to the loyalty system operations team.
Please create a wallet to be used with this feature and provide the wallet address to the loyalty system operations team.
For the testnet, the wallet's secret key to be used is: 0xa0dcffca22f13363ab5d109f3a51ca99754cff4ce4c71dccc0c5df7f6492beee
For the mainnet, create a wallet independently and deliver only its public address to the operations team.
Development and Operation
Follow the steps below to proceed:
Development and Testing:
First, install the user app and set the network to testnet.
Review the test code and implement the necessary features. When creating PaymentClient, use the wallet's private key: 0xa0dcffca22f13363ab5d109f3a51ca99754cff4ce4c71dccc0c5df7f6492beee (for testnet).
Note: Testnet store IDs begin with “0x0003”.
Switching to Mainnet:
Generate a new wallet and use its private key to create PaymentClient. You may use a wallet generated using MetaMask.
Send the wallet address created in step 1 to the KIOS operations team.
Cautions:
Both testnet and mainnet are always active, so ensure the system can handle both networks in the future.
If the store ID of the POS or KIOSK starts with "0x0003", use testnet information for PaymentClient. If the store ID starts with "0x0004", use mainnet information.
SMS functionality is available only in Korea.
SDK
Sample Code

1. Define the private keys for a wallet by network
Please use the registered value for the test net, generate the key to be used on the main net, and pass only the address to the KIOS operation team
// Key required to store purchase data
// ---------------------------------------------------------------------------------------
const keysForPayment: Map<number, string> = new Map([
[NetWorkType.acc_testnet, "0x8acceea5937a8e4bb07abc93a1374264dd9bd2fc384c979717936efe63367276"],
[NetWorkType.acc_mainnet, "0x0000000000000000000000000000000000000000000000000000000000000000"],
[NetWorkType.kios_testnet, "0xa0dcffca22f13363ab5d109f3a51ca99754cff4ce4c71dccc0c5df7f6492beee"],
[NetWorkType.kios_mainnet, "0x0000000000000000000000000000000000000000000000000000000000000000"],
[NetWorkType.localhost, "0x2c93e943c0d7f6f1a42f53e116c52c40fe5c1b428506dc04b290f2a77580a342"],
]);
// ---------------------------------------------------------------------------------------
2. To determine the type of network
The type of network is determined by the shopID.
// ---------------------------------------------------------------------------------------
// Shop ID of the KIOSK
const shopId = "0x0003be96d74202df38fd21462ffcef10dfe0fcbd7caa3947689a3903e8b6b874";
// Select a network, select a network according to the Shop ID
const network = CommonUtils.getNetWorkType(shopId);
3. Creating a Client
const paymentClient = new PaymentClient(network, keysForPayment.get(network) || "");
4. Implementing a PaymentEventListener
This is the part that implements logic when an event that occurs in the point payment process is received.
class PaymentEventListener implements ITaskEventListener {
public onNewPaymentEvent(type: string, code: number, message: string, sequence: bigint, data: IPaymentTaskItem) {
console.log(`type: ${type.toString()}`);
console.log(`code: ${code.toString()}`);
console.log(`message: ${message}`);
console.log(`sequence: ${sequence.toString()}`);
console.log(`data: ${JSON.stringify(data)}`);
}
public onNewShopEvent(type: string, code: number, message: string, sequence: bigint, data: IShopTaskItem) {
console.log(`type: ${type.toString()}`);
console.log(`code: ${code.toString()}`);
console.log(`message: ${message}`);
console.log(`sequence: ${sequence.toString()}`);
console.log(`data: ${JSON.stringify(data)}`);
}
}
5. Creating a TaskEventCollector
This is all about collecting events that occur during the point payment process.
const eventCollector = new TaskEventCollector(paymentClient, new PaymentEventListener());
6. Starting Event Collector
await eventCollector.start();
7. Starting New Payment
const purchaseId = "P1000000000000";
const paymentItem = await paymentClient.openNewPayment(
purchaseId, // 구매 아이디
temporaryAccount, // 키오스로 부터 전달받은 사용자의 임시주소
BOACoin.make(1000).value, // 결제할 금액
"krw", // 결제할 금액의 환률 심벌
shopId, // 상점 아이디
terminalID // 키오스크의 아이디 (공백이어도 무관)
);
8. Stopping New Payment
const res = await paymentClient.closeNewPayment(paymentItem.paymentId, true);
9. Starting Cancel Payment
const res = await paymentClient.openCancelPayment(paymentItem.paymentId, terminalID);
10. Stopping Cancel Payment
const res = await paymentClient.closeCancelPayment(paymentItem.paymentId, true);
11. Stopping Event Collector
await eventCollector.stop();
Last updated