Simple Payment UI

The Blockchain Platform SDK supports the simple payment UI with cryptocurrency. This simple payment UI feature is embedded in the SDK and doesn’t need any other information on UI components. It not only supports Ethereum but also ERC20 and ERC721 tokens. Below are examples of each payment sheet UI.

< Ethereum >
< ERC20 >
< ERC721 >

There are three options (Faster, Normal, Slower) of the transaction fee. Its estimated value is based on the Big Data analysis of the proxy node of Samsung. Take note that it is not estimated in real time.

Ethereum

createEthereumPaymentSheetActivityIntent creates an Intent instance for the Ethereum payment sheet activity. Optionally, you can use data and nonce parameters. If you want to get the txid for results, you should call startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract cause of critical issue or Ethereum’s own problem.

Note

The unit of value is wei.

    Intent intent = etherService
                                .createEthereumPaymentSheetActivityIntent(
                                        mContext,
                                        mConnectedWallet,
                                        ethAccount,
                                        "0xFd23eA99BB179c32e2a23545f3c99e1Cd6a3ea5e", // to address
                                        new BigInteger("123450000000000000"), // value in wei
                                        null,
                                        null
                                );
    startActivityForResult(intent, 0);

ERC20

createTokenPaymentSheetActivityIntent creates an Intent instance for the ERC20 token payment sheet activity. Optionally, you can use the data and nonce parameters. If you want to get the txid for results, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It does require the token’s contract address for payment. This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract cause of critical issue or Ethereum’s own problem.

Note

The unit of value is wei.

    Intent intent = etherService
    .createTokenPaymentSheetActivityIntent(
                                    mOwnerActivity,
                                    mConnectedWallet,
                                    tokenAccount,
                                    "0x136591d00349c210d2bea4eb861a0a811efc8b81", // to address
                                    "0xFab46E002BbF0b4509813474841E0716E6730136", // contract address
                                    new BigInteger("123450000000000000"), // value in wei
                                    null,
                                    null
    );
    startActivityForResult(intent, 0);

ERC721

There are two methods for ERC721 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md) specifying the safe/unsafe transfer feature.

createNftPaymentSheetActivityIntent and createSafeNftPaymentSheetActivityIntent creates an Intent instance for the ERC721 token payment sheet activity. Optionally, you can use the data and nonce parameters. If you want to get the txid for result, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It requires the token’s contract address and tokenId for payment. This API can be blocked with the AvailabilityException by SDK’s Availability smart contract cause of critical issue or Ethereum’s own problem.

Note

The unit of value is wei.

    Intent intent = etherService
    .createNftPaymentSheetActivityIntent(
                                    mOwnerActivity,
                                    mConnectedWallet,
                                    tokenAccount,
                                    "0x3c433a1c5e1213b38f693fe5f8abd0e992a9a461", // to address
                                    "0xc8262fdec7fd685a9a4bda5e12765b5fe00a7e6c", // contract address
                                    new BigInteger("18"), // token id
                                    null
     );
    startActivityForResult(intent, 0);

Result of payment

After completing a payment, you can get the txid from onActivityResult(int requestCode, int resultCode, Intent data). You can get the txid in the received Intent parameter with the txid key.

    @Override
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            if (requestCode == 0) {
                switch (resultCode) {
                    case Activity.RESULT_OK:
                        Log.d(TAG, "txid : " + data.getStringExtra("txid"));
                        break;
                    case Activity.RESULT_CANCELED:
                        Log.d(TAG, "user canceled");
                        break;
                }
            }
        }