Quick guide to implement the livepay.io Widget in PHP


The Livepay Widget is an online tool which we can implement on our website so that from there they can pay us with cryptocurrencies.

The payment will be made with a transfer from your client's wallet to your wallet.

The widget is very easy to implement, it only requires some steps that will be detailed below:

    - Download the widget files from the following address:

          https://livepay.io/download/livepay_gateway.zip

    - Copy the api directory to the root of your project

    - Code that you have to manage in your controller


<?php

require_once('livepay_gateway.php');


$data = array();

$data['coin_symbol'] = 'BTC';

$data['currency_symbol'] = 'USD';

$data['amount_f'] = number_format('100', 2, '.', '');

$data['invoice_id'] = 'unique_invoice_001';

$data['fee_pay_by'] = '0';

//$data['amount_c'] = '1.30';

$data['ipn_url'] = 'https://destinationurl.com/ipn.php'; //We are going to send a callback to this URL when payment is done, refer to our IPN documentation to learn how to create it.


$apiKey = 'EVE3o-JP3al-wfHtj-8xfiJ-iUzf9';

$apiSecret = 'hNoiSzKx4ciyTuMq8rIszHJLgoOIbC==';


$response = livepay_api_call('genorderid',$data,$apiKey,$apiSecret);  

?>


<center >
<
script type="text/javascript" src="https://gw17.livepay.io/gw/paywidget/?orderId=<?php echo $response['response']['order_id']; ?>">
</
script>
</
center>


Use of the variables:

$data['coin_symbol'] The cryptocurrency symbol of the destination purse
$data['currency_symbol'] It allows us to put the equivalent in USD or EUR
$data['amount_f'] The amount to be transferred
(A) You have to keep in mind that if $data['currency_symbol'] has a value is 'USD' or 'EUR'
(B) if $ data ['currency_symbol'] has an empty value is considered the amount in cryptocurrency, this cryptocurrency would be the value of $ data ['coin_symbol']
$data['invoice_id'] It is the reference code of your transaction, it can be the number of an invoice
$data['fee_pay_by'] If the client pays our fee the value is 1, if you pay our fee the value is 0
$data['amount_c'] It is the amount in cryptocurrency
$data['ipn_url'] It is the controller of your system where the response values will be sent
Important

1. If you are paid the equivalent in USD or EUR the variables will be handled like this, example:

currency_symbol = 'USD'
amount_f = 100
coin_symbol = 'BTC'

The system will arrange to change the 100 USD to BTC

2. If they pay you in cryptocurrency the variables will be handled like this, example:

currency_symbol = ''
amount_f = 0
coin_symbol = 'BTC'
amount_c = 0.000152

Note:
We have activated the following cryptocurrencies: BTC (Bitcoin), ETH (Ethereum), LTC (Litecoin), TBTC (Bitcoin Testnet)

 

Then we include the Javascript code for the self-loading of the Widget

<center>
    <script type="text/javascript"src="https://gw17.livepay.io/gw/paywidget/?orderId=<?php echo $response['response']['order_id'];?>"></script>
</center>


The widget executes the payment, when it is loaded, it orders the API to carry out the transfer



Immediately shows us a go-ahead that means the operation was a success.




Notifications
In our livePay.io account we will receive a notification informing us that the transfer was a success and also an email.