Skip to content
CryptAPI's PHP library
PHP
Branch: master
Clone or download
Latest commit 328b3fb Oct 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cryptapi added `info` endpoint Oct 13, 2019
.gitignore Initial Commit Oct 10, 2019
LICENSE Initial Commit Oct 10, 2019
MANIFEST.in Initial Commit Oct 10, 2019
README.md readme updated Oct 14, 2019
composer.json small bugfixes Oct 13, 2019

README.md

CryptAPI

CryptAPI's PHP Library

Official PHP library of CryptAPI

Requirements:

PHP >= 5.5
ext-curl

Install

composer require cryptapi/php-cryptapi

on GitHubon Composer

Usage

Generating a new address

<?php
require 'vendor/autoload.php'; // Where your vendor directory is

$ca = new CryptAPI\CryptAPI($coin, $my_address, $callback_url, $parameters, $pending);
$payment_address = $ca->get_address();

Where:

$coin is the coin you wish to use, can be one of: ['btc', 'eth', 'bch', 'ltc', 'iota', 'xmr']

$my_address is your own crypto address, where your funds will be sent to

$callback_url is the URL that will be called upon payment

$parameters is any parameter you wish to send to identify the payment, such as ['order_id' => 1234]

$pending if you want to be notified of pending transactions.

$payment_address is the newly generated address, that you will show your users

Getting notified when the user pays

The URL you provided earlier will be called when a user pays, for easier processing of the request we've added the process_callback helper

<?php

require 'vendor/autoload.php'; // Where your vendor directory is

$payment_data = CryptAPI\CryptAPI::process_callback($_GET, $convert);

Where:

$convert is a boolean to whether to convert to the main coin denomination.

 

The $payment_data will be an array with the following keys:

address_in - the address generated by our service, where the funds were received

address_out - your address, where funds were sent

txid_in - the received TXID

txid_out - the sent TXID or null, in the case of a pending TX

confirmations - number of confirmations, or 0 in case of pending TX

value - the value that your customer paid

value_forwarded - the value we forwarded to you, after our fee

coin - the coin the payment was made in, one of: ['btc', 'eth', 'bch', 'ltc', 'iota', 'xmr']

pending - whether the transaction is pending, if false means it's confirmed

plus, any values set on $params when requesting the address, like the order ID.

 

From here you just need to check if the value matches your order's value.

Checking the logs of a request

<?php

require 'vendor/autoload.php'; // Where your vendor directory is

$ca = new CryptAPI\CryptAPI($coin, $my_address, $callback_url, $parameters);
$data = $ca->check_logs();

Same parameters as before, the $data returned can be checked here: https://cryptapi.io/docs/#/Bitcoin/btclogs

Help

Need help?
Contact us @ https://cryptapi.io/contact/

You can’t perform that action at this time.