Address

V 2.0

This function generates a unique bitcoin address to which the customer may send payments. This address works without an expiry date or transaction limit.

Contents

You can generate bitcoin addresses for one-time payments or for periodic payments as a linked bitcoin address to a user account. For example, if a customer re-uses it to buy the same product again or to top up the account balance with bitcoins.

Callback

For both wallet types, you will receive callbacks for every confirmed transaction. But the format and method are different. Please read the documentation.
HTTP and HTTPS protocol schemas in URL are required. Also, we support callback to TOR project logo network.

 

Simple requests:

{
   "callback":{                    #Callback and Callback's Data are Optional fields
      "url",
      "data":{
         "invoice_id": 1234,
         "secret": "7j0ap91o99cxj8k9",
         "data3": "text3",
		 ... #any user parameters
      }
   }
}

Code Example

Wallet ID
Callback URL KeyValue

+

{
   "callback":{
      "url" :  "http://example.com/callback"
   }
}
  
<?php
  $json_data = array (
    "callback" => array(
        'url'=> 'http://example.com/callback',
		'data'=> array (
            'invoice_id'=> "1234",
            'secret'=> "7j0ap91o99cxj8k9"
        )
    )
  );
  
  $wallet = "1aee83487b65b690305201fb4b42a081";
  $api_base = "https://apirone.com/api/v2/btc/wallet/". $wallet ."/address";
 
  $curl = curl_init($api_base);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json_data));
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  $response = curl_exec($curl);
  curl_close($curl);
 

  $decoded = json_decode($response, true);
  echo "Please send the payment to the following bitcoin address: " .
  $decoded["address"];
?>
Send request
Response from server:

JSON Schema description

Use POST string request containing the object in JSON format.

Callback URL

Callback is an array of callback URL and user's Data parameters.

Parameter Description Required
{callback:url}
string,
=< 1024 chars

Callback URL
Your server's callback URL to receive data about the payment. This must be a valid URL.

Required
{callback:data}
array

Data
The associative array is based on key-value pairs. You can use as additional identification or secure a generated bitcoin address.

For example 'secret' = '7j0ap91o99cxj8k9' or 'invoice_id'='1234'

Optional

Success Response

Success response returns four parameters in JSON format:
Parameter Description Type (length)
{address} The generated bitcoin address to receive a payment from a customer. string, 32 chars
{callback} Your server callback URL to receive data about the payment. string, max. 1024 chars
Response example:
{
   "callback":{
      "url":"http://example.com/callback",
      "data":{
         "invoice_id":1234,
         "secret":"7j0ap91o99cxj8k9"
      }
   },
   "address": "1FEGJSLDJJ6oSuJwur3fCD7TtQbYUjBV4z",
   "type": "p2sh-p2wpkh",
   "currency": "btc"
}

Error Response

Error response return messages in plain text format below:
Invalid wallet.
Too many destinations.
All destinations should be unique.
Failed to decode JSON object: Expecting value: line 1 column 64 (char 63)
Invalid callback. The callback should contain valid URL and optionally data items.