Pre-authorization

Overview

The first step of integrating with the User Wallet Payments method requires the user to pre-authorize AEON Pay to link their wallet and specify an authorization amount.


Pre-authorization Example

This section provides a frontend example for managing USDT authorization on the BSC network.

You can download the pre-authorization demo Click Here.

Main Features

  • Connect or disconnect MetaMask wallet
  • Authorize USDT spending limit to a specified address
  • Check the current USDT allowance
  • Revoke authorization

Merchant Integration

Merchants should implement pre-authorization using the following parameters.

Key Variables

  • usdtAddress: The USDT contract address on the BSC network
  • spender: The address to which USDT spending is authorized, e.g., 0x8A86bEB8fD4CAd14baDa4531082a1E2207aFC51b
  • usdtABI: A simplified ABI containing the approve and allowance methods

Main Methods

  • connectWallet(): Connects to the MetaMask wallet and stores the address.
  • disconnectWallet(): Disconnects the wallet and clears the saved address.
  • onWalletConnected(): Displays the wallet address, relevant buttons, and checks the current allowance.
  • approveUSDT(): Accepts user input for the amount and calls the approve method to authorize spending.
  • checkAllowance(): Calls the allowance method to check and display the current authorization.
  • revokeAllowance(): Revokes the authorization by calling approve(spender, 0).
  • setLoading(isLoading, buttonId): Controls the loading state of the specified button.

User Steps

  1. Install MetaMask and connect to the BSC mainnet.
  2. Open the page and click Connect Wallet.
  3. Enter the authorization amount and click Approve.
  4. Click Check Allowance to view the current authorization status.
  5. Click Revoke Authorization to cancel the authorization.