public static function createOrder()
 {
     if (osc_get_preference('coinjar_sandbox', 'payment') != 1) {
         $coinjar = new CoinJar(payment_decrypt(osc_get_preference('coinjar_merchant_user', 'payment')), payment_decrypt(osc_get_preference('coinjar_merchant_password', 'payment')), payment_decrypt(osc_get_preference('coinjar_api_key', 'payment')));
     } else {
         $coinjar = new CoinJar(payment_decrypt(osc_get_preference('coinjar_sb_merchant_user', 'payment')), payment_decrypt(osc_get_preference('coinjar_sb_merchant_password', 'payment')), payment_decrypt(osc_get_preference('coinjar_sb_api_key', 'payment')), true);
     }
     $items[0]['name'] = Params::getParam('description');
     $items[0]['quantity'] = 1;
     $items[0]['amount'] = payment_get_amount(Params::getParam('itemnumber'));
     $order_json = $coinjar->createOrder($items, osc_get_preference('currency', 'payment'), Params::getParam('itemnumber'), osc_get_preference('coinjar_merchant_reference', 'payment'), osc_route_url('coinjar-notify', array('extra' => Params::getParam('extra'))), osc_route_url('coinjar-return', array('extra' => Params::getParam('extra'))), osc_route_url('coinjar-cancel', array('extra' => Params::getParam('extra'))));
     $order = json_decode($order_json);
     if (isset($order->order->uuid)) {
         echo json_encode(array('url' => $coinjar->orderPage($order->order->uuid), 'error' => 0));
     } else {
         echo json_encode(array('error' => 1, 'status' => @$order->order->status, 'msg' => @$order->order->error));
     }
 }
Example #2
0
<?php

require_once 'CoinJar.php';
require_once 'config.php';
$coinjar = new CoinJar($user, $secret, $apikey, true);
$account = $coinjar->accountInformation();
print_r($account);
$items[0]['name'] = 'Name';
$items[0]['quantity'] = 1;
$items[0]['amount'] = 2;
$order = $coinjar->createOrder($items, 'USD', 'invoice#1', 'coinjar-php', 'notify-url', 'retrn-url', 'cancel-url');
print_r($order);
//$ipn = $coinjar->simulateIPN('notify-url', 'uuid', 'amount', 'fee', 'currency', 'bitcoin_amount', 'bitcoin_address', 'merchant_reference', 'merchant_invoice');
//print_r($ipn);