Home / Scripts & Code / PHP Scripts / Payment
Bitcoin Cash Receive Payments - CoinPayments APIBitcoin Cash Receive Payments - CoinPayments API
Accept BCH Bitcoin Cash payments on your website via the coinpayments API v1. This is an easy way to get up and running in no timeHome / Scripts & Code / PHP Scripts / Payment
Bitcoin Cash Receive Payments - CoinPayments API
Accept BCH Bitcoin Cash payments on your website via the coinpayments API v1. This is an easy way...3 Support questions or comments
Please login or create an account to post a question or comment.
-
Aug 23, 2018hello sir,
u make tooo dogecoin payment script for pnp ? -
Aug 24, 2018gabisajr AuthorI do have a script hasn't been uploaded as yet to Accept Dogecoin payments
-
Aug 24, 2018u have discord easy for chat
add me Crackerz#7674 -
Aug 27, 2018gabisajr AuthorJust added you
-
Mar 18, 2018Hello,
Found useful, going to purchase, need to clear some points.
1. Why BCH only I think I can accept any of available coins on coinpayment. - View 5 more replies
-
Mar 18, 2018gabisajr AuthorNo this script is not yet on envato
-
Mar 18, 2018gabisajr AuthorVISA credit card payments might need some authorization or business validation, please check that with the coinpayments support team
-
Mar 18, 2018No, you didn't get it, I tried to make payment for script with my visa credit card but codester gives me error 2 times.
-
Mar 16, 2018silasogar2 PurchasedHELLO, I JUST PROCURED YOUR API, PLEASE, I HAVE CHALLENGE NAVIGATING THROUGH THE CALLBACK IPN SUCCESSFULLY, CAN YOU KINDLY ASSIST PLEASE
IN THIS FUNCTION, ITS WHERE I DISPLAY THE ADDRESS TO MAKE PAYMENT TO
public function payto(){
if($this->input->post()){
extract($this->input->post());
$data['cur'] = $currency;
$da = $this->getDepositAddress('BTC';
$data['address'] = $this->getDepositAddress('BTC';
$data['title'] = 'Make payment';
//IN THIS VIEW FILE, I WANT TO ABLE TO DISPLAY THE AMOUNT, THE CURRENCY THE USER HAD SELECTED(E.G BTC) AND THE GENERATED BITCOIN OR ETH ADDRESS THE API MUST HAVE GENERATED FOR THE USER
$this->load->view('payto',$data);
}else{
redirect('invest/makepayment';
}
}
THIS FUNCTION GETS THE ADDRESS TO PAY TO
public function getDepositAddress($cur)
{
$data = $this->coinpayments_api_call('get_deposit_address', ['currency' => $cur]);
//return $data['result'] ;
return $data['result']['address'];
}
THIS IS THE FUNCTION I USE TO CREATE TRANSACTION
public function CreateTransactionSimple($amount, $currency1, $currency2, $address='', $ipn_url='', $buyer_email='' {
$req = array(
'amount' => $amount,
'currency1' => $currency1,
'currency2' => $currency2,
'address' => $address,
'ipn_url' => 'https://nitrowealthfund.com/ajax/activate_investment/',
'buyer_email' => $buyer_email,
);
return $this->coinpayments_api_call('create_transaction', $req);
}
THIS IS THE COINPAYMENT API
function coinpayments_api_call($cmd, $req = array()) {
// Fill these in from your API Keys page
$public_key = '888';
$private_key = '888';
// Set the API command and required fields
$req['version'] = 1;
$req['cmd'] = $cmd;
$req['key'] = $public_key;
$req['format'] = 'json'; //supported values are json and xml
// Generate the query string
$post_data = http_build_query($req, '', '&';
// Calculate the HMAC signature on the POST data
$hmac = hash_hmac('sha512', $post_data, $private_key);
// Create cURL handle and initialize (if needed)
static $ch = NULL;
if ($ch === NULL) {
$ch = curl_init('https://www.coinpayments.net/api.php';
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('HMAC: '.$hmac));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// Execute the call and close cURL handle
$data = curl_exec($ch);
// Parse and return data if successful.
if ($data !== FALSE) {
if (PHP_INT_SIZE < 8 && version_compare(PHP_VERSION, '5.4.0' >= 0) {
// We are on 32-bit PHP, so use the bigint as string option. If you are using any API calls with Satoshis it is highly NOT recommended to use 32-bit PHP
$dec = json_decode($data, TRUE, 512, JSON_BIGINT_AS_STRING);
} else {
$dec = json_decode($data, TRUE);
}
if ($dec !== NULL && count($dec)) {
return $dec;
} else {
// If you are using PHP 5.5.0 or higher you can use json_last_error_msg() for a better error message
return array('error' => 'Unable to parse JSON result ('.json_last_error().'';
}
} else {
return array('error' => 'cURL error: '.curl_error($ch));
}
}
- View 2 more replies
-
Mar 16, 2018gabisajr AuthorYour file has too much new code with is beyond the scope of the script, and your own app codebase, I would suggest you do one thing at a time, get the Wallet address & qrcode from coinpayments, print/display to the user ... then you can add all your code as per your application requirements
-
Mar 18, 2018Hello,
Found useful, going to purchase, need to clear some points.
1. Why BCH only I think I can accept any of available coins on coinpayment.
-
Mar 18, 2018gabisajr AuthorHi, I just made it centric to BCH however you can accept all *listed cryptos supported by coinpayments*
Information
Category | Scripts & Code / PHP Scripts / Payment |
First release | 29 November 2017 |
Last update | 29 November 2017 |
Software version | PHP 7.0, PHP 7.1, PHP 7.4, PHP 5.x, PHP 5.0, PHP 5.1, PHP 5.2, PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6 |
Files included | .php, .css, .html |
Tags | php, bitcoin, API, cryptocurrency, coins, payments, bitcoincash, coinpayments |