Java
Description
Only registered partners can use this feature. Anyone who have not yet registered can test on the testnet using the private key provided in the sample code.
The shop that acts as an agent for store settlements is known as the settlement-shop. This SDK provides the features needed for the settlement-shop. First, the settlement-shop must secure its store ID by installing the store app and registering the addresses of the settlement agent and the withdrawal agent in the app. The wallet private key for the settlement agent is managed by the development team, while the wallet private key for the withdrawal agent is managed by the accounting team. Owners of the settlement shop-can set up these two addresses.
Development and Operation
Follow the steps below to proceed:
Development and Testing:
Install the store app and set the network to TestNet. Choose to import your wallet during installation and use the following private key: 0xd72fb7fe49fd18f92481cbee186050816631391b4a25d579b7cff7efdf7099d3 Select the store ID: 0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86 (this store ID is already registered).
Review the test code and implement the necessary functions.
When creating the SettlementClient for the owner of the settlement shop, use the private key: 0xd72fb7fe49fd18f92481cbee186050816631391b4a25d579b7cff7ef7ef7ef7f7099d3 and use the Store ID: 0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86
When creating the SettlementClient for the Settlement Agent, use the private key: 0x70438bc3ed02b5e4b76d496625cb7c06d6bf4362295b16fdfe91a046d4586c with the store ID: 0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86
When creating the SettlementClient for the Withdrawal Agent, use the private key: 0x44868157d6d3524eb64c6ae41ee6c879d03c19a357ddb038fefea30e23cbab with the store ID: 0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86
Note: On TestNet, the store ID starts with “0x0003”.
Switching to Mainnet
Owners of settlement shops install store app. Owners of settlement-shops must back up their account information in a secure place.
A settlement agent generates a private key for a wallet. You can use the private key for Metamask. Pass the address to the owner of a settlement shop.
The withdrawal agent installs the user app. Pass the address to the owner of the settlement-shop.
The owner of the settlement app registers the address of the settlement agent and the address of the withdrawal agent in the app.
The owner of the settlement-shop will forward the wallet address to the ACC operations team.
Caution
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 SettlementClient. If the store ID starts with "0x0004", use mainnet information.
SMS functionality is available only in Korea.
Links
Sample Code
1. Create Client for settlement-shop
var refundAgentPrivateKey = "0x70438bc3ed02b5e4b76d496625cb7c06d6b7bf4362295b16fdfe91a046d4586c";
var managerShopId = "0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86";
var refundAgent = new SettlementClient(network, refundAgentPrivateKey, managerShopId);
2. Create Client for refund agent
This agent accumulates the settlement of all registered shops into the settlement of the settlement-shop, and exchanges the settlement for tokens.
var refundAgentPrivateKey = "0x70438bc3ed02b5e4b76d496625cb7c06d6b7bf4362295b16fdfe91a046d4586c";
var managerShopId = "0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86";
var refundAgent = new SettlementClient(network, refundAgentPrivateKey, managerShopId);
3. Create Client for withdrawal agent
This agent is authorized to perform the function of withdrawing tokens to the main chain.
var withdrawalAgentPrivateKey = "0x44868157d6d3524beb64c6ae41ee6c879d03c19a357dadb038fefea30e23cbab"
var managerShopId = "0x000108bde9ef98803841f22e8bc577a69fc47913914a8f5fa60e016aaa74bc86"
var withdrawalAgent = new SettlementClient(network, withdrawalAgentPrivateKey, managerShopId);
4. Register the refund agent
This can only be registered by the owner of the settlement-shop.
settlementClientForManager.setAgentOfRefund(refundAgent.getAddress());
5. Register the withdrawal agent
This can only be registered by the owner of the settlement-shop.
settlementClientForManager.setAgentOfWithdrawal(withdrawalAgent.getAddress());
6. Collect Settlement Amount
You have to get the number of stores first, and if the number of stores is too high, you have to do it several times. The maximum number of stores that can be processed at once is 10.
var count = refundAgent.getSettlementClientLength();
var clients = refundAgent.getSettlementClientList(0, count);
refundAgent.collectSettlementAmountMultiClient(clients);
7. Refund Settlement Amount
Exchange the settlement amount into tokens.
var refundableData = settlementClient.getRefundable();
refundAgent.refund(refundableData.refundableAmount);
8. Withdrawal token
Withdraw tokens to the main chain.
var accountOfShop = settlementClient.getAccountOfShopOwner();
var res = settlementClient.getBalanceAccount(accountOfShop);
var balanceOfToken = res.token.balance;
withdrawalAgent.withdraw(balanceOfToken);
9. Transfer of tokens
Owners of settlement-shop can transfer tokens withdrawn to the main chain from the app to other addresses
Last updated