> For the complete documentation index, see [llms.txt](https://docs.foloosi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.foloosi.com/client-side-integrations/javascript-integration-1/sample-integrations.md).

# Sample integrations

## Sample Integrations

### [Popup payment](/payment-methods/popup-payment-method.md) method sample code

Just paste the code below inside the body tag and enter your valid data to start using Popup Payment Method

{% code lineNumbers="true" %}

```php
<!DOCTYPE html>
<html>
    <head>
    <title>Payment</title>
        <meta charset="utf-8"/>
    </head>
    <body>
        <?php
            $curl = curl_init();
            curl_setopt_array($curl, array(
                CURLOPT_URL => "https://api.foloosi.com/aggregatorapi/web/initialize-setup",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 30,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "POST",
                CURLOPT_POSTFIELDS => "transaction_amount=1&currency=AED&customer_address=Address&customer_city=Dubai&billing_country=ARE&billing_state=Dubai&billing_postal_code=000000&customer_name=Test&customer_email=test%40email.com&customer_mobile=9876543210&optional1=#ord_no1&optional2=#ord_ref1&optional3=#ord_ref1",
                CURLOPT_HTTPHEADER => array(
                    'content-type: application/x-www-form-urlencoded',
                    'merchant_key: YOUR_MERCHANT_KEY'
                ),
            ));
            $response = curl_exec($curl);
            $err = curl_error($curl);
            curl_close($curl);
            if ($err) {
                echo "cURL Error #:" . $err;
            } else {
                $responseData = json_decode($response,true);
                $reference_token = $responseData['data']['reference_token'];
            }
        ?>
        <script type="text/javascript" src="https://www.foloosi.com/js/foloosipay.v2.js"></script> 
        <script type="text/javascript">
            var reference_token = "<?= $reference_token; ?>";
            var options = {
                "reference_token" : reference_token, 
                "merchant_key" : "YOUR_MERCHANT_KEY"
            }
            var fp1 = new Foloosipay(options);
            fp1.open();
            foloosiHandler(response, function (e) {
                if(e.data.status == 'success'){
                    console.log(e.data)
                }
                if(e.data.status == 'error'){
                    console.log(e.data)
                }
                if(e.data.status == 'closed'){
                    console.log(e.data)
                }
            }); 
        </script>
    </body>
</html>
```

{% endcode %}

### [Hosting payment](/payment-methods/hosting-payment-method.md) method sample code

Just paste the code below inside the body tag and enter your valid data to start using Redirect Payment Method

{% code lineNumbers="true" %}

```php
<!DOCTYPE html>
<html>
    <head>
    <title>Payment</title>
        <meta charset="utf-8"/>
    </head>
    <body>
        <?php
            $site_return_url = urlencode("YOUR_REDIRECTION_SITE_URL")
            $curl = curl_init();
            curl_setopt_array($curl, array(
                CURLOPT_URL => "https://api.foloosi.com/aggregatorapi/web/initialize-setup",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 30,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "POST",
                CURLOPT_POSTFIELDS => "transaction_amount=1&currency=AED&customer_address=Address&customer_city=Dubai&billing_country=ARE&billing_state=Dubai&billing_postal_code=000000&customer_name=Test&customer_email=test%40email.com&customer_mobile=9876543210&site_return_url=".$site_return_url,
                CURLOPT_HTTPHEADER => array(
                    'content-type: application/x-www-form-urlencoded',
                    'merchant_key: YOUR_MERCHANT_KEY'
                ),
            ));
            $response = curl_exec($curl);
            $err = curl_error($curl);
            curl_close($curl);
            if ($err) {
                echo "cURL Error #:" . $err;
            } else {
                $responseData = json_decode($response,true);
                $reference_token = $responseData['data']['reference_token'];
            }
        ?>
        <script type="text/javascript" src="https://www.foloosi.com/js/foloosipay.v2.js"></script> 
        <script type="text/javascript">
            var reference_token = "<?= $reference_token; ?>";
            var options = {
                "reference_token" : reference_token, 
                "merchant_key" : "YOUR_MERCHANT_KEY",
                "redirect" : true
            }
            var fp1 = new Foloosipay(options);
            fp1.open();
            
        </script>
    </body>
</html>
```

{% endcode %}

**Note :**&#x20;

&#x20;    **Apple Pay and Samsung pay options are available only for Hosting Payment Method.**&#x20;

&#x20;    **Site must be https with proper SSL certificate.**

### Support

Visit <https://www.foloosi.com> for support requests or email to <tech@foloosi.com>.

## Developed by

Foloosi Technologies Pvt Ltd.

## License

Copyrights (c) 2025 Foloosi
