Code Monkey home page Code Monkey logo

coinpayments-php-sdk's Introduction

#Coinpayments PHP SDK

Biblioteca para se conectar com https://www.coinpayments.net

Futuramente adicionaremos outras funções.

Instalação

Via composer:

composer require phabloraylan/coinpayments-php

Usando

Inclua o autoload em seu projeto, exemplo:

require_once __DIR__ . '/vendor/autoload.php';

Criando uma simples transação

/** Scenario: Create a simple transaction. **/

// Create a new API wrapper instance
$private_key= "";
$public_key = "";
$cps_api = new \Coinpayments\CoinpaymentsAPI($private_key, $public_key, 'json');

// Make call to API to create the transaction
try {

    $fields = [
        'amount' => 100.00,
        'currency1' => 'BRL',
        'currency2' => 'LTCT',
        'buyer_email' => '[email protected]'
    ];
    $transaction_response = $cps_api->CreateCustomTransaction($fields);
} catch (\Exception $e) {
    echo 'Error: ' . $e->getMessage();
    exit();
}

if ($transaction_response['error'] == 'ok') {
    // Success!
    $output = 'Transaction created with ID: ' . $transaction_response['result']['txn_id'] . '<br>';
    $output .= 'Amount for buyer to send: ' . $transaction_response['result']['amount'] . '<br>';
    $output .= 'Address for buyer to send to: ' . $transaction_response['result']['address'] . '<br>';
    $output .= 'Seller can view status here: ' . $transaction_response['result']['status_url'];

} else {
    // Something went wrong!
    $output = 'Error: ' . $transaction_response['error'];
}

// Output the response of the API call
echo $output;

coinpayments-php-sdk's People

Contributors

phabloraylan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.