Litepay.ch class for our Merchant & Payment API
Introduction
To successfully use this class, you need to import it in your project & call it. If you want to use our Bitcoin Payment Merchant API, you will need to Register for Merchant account and create a VENDOR ID.
EXPLANATION
Our api requires some info from you, to be able to generate a address for your payment;
$method - Use 'btc'
/ 'ltc'
/ 'zec'
/ 'bch'
/ 'xmr'
as a value for parameter method, based on entered value a Bitcoin
, Litecoin
, Zcash
, Bitcoin Cash
, Monero
address will be generated
$receiving_address - Your Receiving Bitcoin
/ Litecoin
/ Zcash
/ Bitcoin Cash
, Monero
Address (Where you would like the payment to be forwarded)
$callback_url - The callback URL to be notified when a payment is received. Remember to URL Encode the callback URL when calling the create method. The domain must be valid, or else your request will be denied.
EXAMPLE
Payment API: Creating invoice
include('litepay_ch.php'); //in your file
$litepay = new litepay('api'); //using payment API
$_secret = 'my_secret_passphrase';
$invoice_id = '123_order_number';
$callback_url = 'https://your_domain.com/callbacks/litepay/callback.php?id='.$invoice_id.'&secret='.$_secret;
$method = 'btc';
$return_address = '1BDesouFJaHyr7DejtGrq7K14D5gSbS4DT';
$parameters = array(
'address'=>$return_address,
'method'=>$method,
'callback'=> urlencode($callback_url)
);
$new_address = $litepay->receive($parameters);
if($new_address->status == "success") {
$address = $new_address->address;
}
Payment API: Checking address
include('litepay_ch.php'); //in your file
$litepay = new litepay('api'); //using payment API
$method = 'btc';
$parameters = array(
'address'=>$generated_address, //the one we generated
'method'=>$method
);
$check_address = $litepay->check($parameters);
if($new_address->status == "success") {
$address = $check_address->address;
$amount => $check_address->amount;
$confirmations => $check_address->confirmations;
$txids => $check_address->txids;
}
https://github.com/litepaych/litepay/tree/master/examples/regular_api
Merchant API: 1. Go to Litepay payment merchant and register for a merchant 2. Go to Vendor & create a vendor id, you will receive the necessary information in the email you used to register.
Then use them like we are showing below.
include('litepay_ch.php');
$litepay = new litepay('merchant'); //using Merchant API
$invoice_id = 22;
//always have a valid domain in callback/return
$callback_url = 'https://domain.com/callback_url.php?invoice='.$invoice_id;
$return_url = 'https://domain.com/success.php';
$parameters = array(
'vendor' => 'VENDOR_ID',
'invoice' => $invoice_id,
'secret' => 'PASSPHRASE',
'currency' => 'USD',
'email' => urlencode('user@email'),
'price' => '2',
'callbackUrl' => urlencode($callback_url),
'returnUrl' => urlencode($return_url)
);
$data = $litepay->merchant($parameters);
if ($data->status == 'success') {
header("Location: $data->url");
} else {
print $data->message;
}
https://github.com/litepaych/litepay/tree/master/examples/merchant