Bitcoin Payments

Blockain Receive Payments Simplified

Using this script will help you get started with ease and receive bitcoin payments from users/members at no extra processing costs like most gateway apps charge you. First you need to obtain a APIKEY from blockchain use it in your server or with your host.

Test Bitcoin Receive Payments

Request a Blockchain APIKEY

Heads Up! Due to the high traffic in this script demo, I had decided to limit calls to the blockchain API (All examples are using the same invoice ID) - for the process (The video demo shows the process)

What is bitcoin

A type of digital currency in which encryption techniques are used to regulate the generation of units of currency and verify the transfer of funds, operating independently of a central bank.

Satoshi to BTC

This conversion is simply if you already have worked with the BTC>Satoshi. To convert Satoshis to BTC simply Satoshi * 100000000

Blockain Request an apikey

NB : when requesting an APIKEY I would suggest you avoid free Email providers like (gmail.com/outlook.com/live.com/yahoo.com) on your request, The best is to request via your "youremail@yourdomain.com" email.

BTC to Satoshi

Workign with bitcoin BTC is important for you to know and under how many satoshi are in the amount of BTC being processed for calculation reason. BTC>Satoshi simply BTC / 100000000

Converting from your Local currency to Bitcoin

the response from convert can either be TRUE/FALSE | $convert['status'] (True means the amount was converted, False meaning there was an error/issue 'reason like not a supported currency or your call server IP being blocked') | $convert['response'] - carries amount convert - on error carries blockchain call reponse message

      
        function convert_amount_to_btc($currency_from,$amount,$api_code)
        {
            $url = "https://blockchain.info/tobtc?api_code=".$api_code."& currency=".$currency_from."&value=".$amount;
            try 
            {
                $ch = curl_init();
                curl_setopt ($ch, CURLOPT_URL, $url);
                curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
                curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
                curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
                $rawdata = curl_exec($ch);
                curl_close($ch);
                if(is_numeric($rawdata)){
                  return array('status' => TRUE,'response' => $rawdata);
                }else{
                    return array('status' => FALSE,'response' => $rawdata);
                }
            } 
            catch (Exception $e){
                return array('status' => FALSE,'response' => $e->Message());
            }
        }
      
    
      
        $app_currency = "USD"; //App Local Currency - please always refer to the blockain docs for supported currencies
        //BELOW AMOUNT IS CONVERTED FROM USD TO BTC 
        $usd_amount = "28";//USD
        $convert = convert_amount_to_btc($app_currency,$usd_amount,$app_api_key); //the response from convert can either be TRUE/FALSE | 
        // $convert['status'] 
        // $convert['response'] - carries amount convert - on error carries blockchain call reponse message
        if((bool)$convert['status']){
          $amount = $convert['response'];//Amount converted from fiat currency to BTC
        }else{
          //here for error purposes it up to your App what to do
          //your can display a message or ask the user to try again
        }