# 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:

```html
<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:

```javascript
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
        successurl: 'SUCCESS_REDIRECT_URL', // URL to redirect to on successful payment
        failurl: 'FAIL_REDIRECT_URL', // URL to redirect to on failed payment
        webhookurl: 'YOUR_WEBHOOK_URL' // Your server endpoint to receive callbacks
    });
});
```

**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.
* **successurl**: URL to which the user will be redirected after a successful payment.
* **failurl**: URL to which the user will be redirected after a failed payment.
* **webhookurl**: Endpoint URL for your server to receive transaction updates via webhook.

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.
