OOKKay Php Sdk
PHP SDK to OOKKay API, with this SDK you can create invoices and retrieve invoice status from out Simple Checkout System, you can make API calls when your plan have it.
Starting with us
Already have your company token?
Okay, lets proced.
If you don't have your company token, please, enter in http://ookkay.com and create your company account.
Instalation
Without Composer:
Download this repository and than just include our auto load
require_once (__DIR__ . '/res/autoload.php');
Using Composer:
Install Composer:
$ wget http://getcomposer.org/composer.phar
$ php composer.phar install
After Install:
-
Add this project in your composer.json:
"require": { "ookkay/php-sdk": "dev-master" }
-
Now tell composer to download OOKKay php-sdk by running the command:
$ php composer.phar update
How to Use:
Create a new invoice:
<?php
require_once __DIR__ . '/res/autoload.php';
use OOKKay\Checkout\Customer;
use OOKKay\Checkout\Invoice;
use OOKKay\Checkout\InvoiceItems;
use OOKKay\Checkout\Checkout;
/**
* Start the checkout with your token
*/
$checkout = new Checkout('1020304050');
/**
* Create a customer
*/
$customer = new Customer();
$customer->setName('User test');
$customer->setEmail('email@email.com');
$customer->setAddress('R do porto');
$customer->setNumber('304');
$customer->setCountry('Brasil');
$customer->setCity('Piracicaba');
$customer->setState('São Paulo');
$customer->setTaxId('13245678462');
$customer->setZip_code('456454789');
/**
* Attach invoice customer
*/
$checkout->setCustomer($customer);
/**
* Create invoice
*/
$invoice = new Invoice();
$invoice->setOrderId(22154); // Your system order id
$invoice->setCurrency('BRL'); //Only BRL avaiable in moment
$invoice->setPaymentMethod(1); // 1 Bitcoin, 2 Depósito Bancário, 5 Ethereum
/**
* Create invoice items
*/
$invoiceItem1 = new InvoiceItems();
$invoiceItem1->setName('Mouse Razer');
$invoiceItem1->setPrice(200);
$invoiceItem1->setQuantity(1);
$invoiceItem2 = new InvoiceItems();
$invoiceItem2->setName('Video card Geforce GTX 980');
$invoiceItem2->setPrice(600);
$invoiceItem2->setQuantity(1);
/**
* Attach invoice items
*/
$invoice->addItem($invoiceItem1);
$invoice->addItem($invoiceItem2);
/**
* Request checkout
*/
$checkout->createInvoice($invoice);
/**
* get the url do pay
*/
echo $checkout->getUrlToPay();
Check your invoice status:
<?php
require_once __DIR__ . '/res/autoload.php';
use OOKKay\Checkout\Invoice;
use OOKKay\Checkout\Checkout;
/**
* Start the checkout with your token
*/
$checkout = new Checkout('102030405060');
$checkout->setInvoiceToken('111111111111111111');
/**
* Attach the invoice status return to variable status
*/
$invoice = $checkout->status();
/**
* Check invoice status
*/
var_dump($invoice->data->paid); //boolean