đŸ’ĩHandling Payments

To initiate a payment with PayPangea, you can set up a button on your webpage. When this button is clicked, it will trigger the initPayment method, which is responsible for opening the PayPangea payment interface with the parameters you specify. Here's how you can do it:

<button id="buybtn" class="buybtn">Buy with PayPangea</button>

Then, add JavaScript to handle the button click and invoke the initPayment method with all available options:

var buyBtn = document.getElementById('buybtn');

buyBtn.addEventListener('click', function() {
    payPangeaWidget.initPayment({
        amount: 'AMOUNT', // The amount to be paid
        token: 'TOKEN_NAME', // The name of the token to be used for payment
        currency: 'CURRENCY', // The fiat currency equivalent if applicable
        tokenaddress: 'ACCEPTED TOKEN ADDRESS', // The blockchain address for the token
        chain: 'NAME OF CHAIN', // The blockchain network to use (e.g., Ethereum, BSC)
        title: 'TRANSACTION TITLE', // A title for the transaction
        text: 'DESCRIPTION TEXT', // A description or additional text for the transaction
        successredirectURL: 'SUCCESS_REDIRECT_URL', // URL to redirect to on successful payment
        failredirectURL: 'FAIL_REDIRECT_URL', // URL to redirect to on failed payment
        webhookURL: 'YOUR_WEBHOOK_URL', // Your server endpoint to receive callbacks
        merchantid: 'YOUR_MERCHANT_ID' // Your PayPangea merchant ID
    });
});

Options Explained:

  • amount: The total payment amount, formatted as a string.

  • token: Specifies the cryptocurrency token to be used for the payment.

  • currency: The fiat currency equivalent, useful for displaying to users.

  • tokenaddress: The address for the accepted token, necessary for blockchain transactions.

  • chain: Identifies the blockchain network (e.g., Ethereum, Binance Smart Chain).

  • title: A brief title for the payment, visible to the user.

  • text: Additional description or information about the payment.

  • successredirectURL: URL to which the user will be redirected after a successful payment.

  • failredirectURL: URL to which the user will be redirected after a failed payment.

  • webhookURL: Endpoint URL for your server to receive transaction updates via webhook.

  • merchantid: Your unique merchant ID of the payment provided by you.

These options allow for a highly customizable payment process, ensuring that you can tailor the experience to match your application's requirements and provide your users with a seamless payment experience.

Last updated