コード例 #1
0
 /**
  * List all created customers
  * 
  * @return array list of customers
  * @throws White_Error_Parameters if any of the parameters is invalid
  * @throws White_Error_Authentication if the API Key is invalid
  * @throws White_Error if there is a general error in the API endpoint
  * @throws Exception for any other errors
  */
 public static function all()
 {
     $url = White::getEndPoint('customer_list');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_CAINFO, White::getCaPath());
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERPWD, White::getApiKey() . ':');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = json_decode(curl_exec($ch), true);
     // Check for errors and such.
     $info = curl_getinfo($ch);
     $errno = curl_errno($ch);
     if ($result === false || $errno != 0) {
         // Do error checking
         throw new Exception(curl_error($ch));
     } else {
         if ($info['http_code'] != 200) {
             // Got a non-200 error code.
             White::handleErrors($result, $info['http_code']);
         }
     }
     curl_close($ch);
     return $result;
 }
コード例 #2
0
 function setUp()
 {
     White::setApiKey('sk_test_1234567890abcdefghijklmnopq');
 }
コード例 #3
0
 function setUp()
 {
     White::setApiKey('sk_test_1234567890abcdefghijklmnopq');
     // Data for a successful customer
     $this->success_data = array("description" => "Test Customer", "card" => array("number" => "4242424242424242", "exp_month" => 11, "exp_year" => 2015, "cvc" => "123"));
 }
コード例 #4
0
 /**
  * @expectedException White_Error_Api
  */
 function testApiException()
 {
     White::setApiKey('sk_test_1234567890abcdefghijklmnopq');
     $data = array("amount" => 10.5, "currency" => "bhd", "card" => array("number" => "3566002020360505", "exp_month" => 12, "exp_year" => 2014, "cvc" => "123"), "description" => "Charge for test@example.com");
     White_Charge::create($data);
 }
コード例 #5
0
 function testEndPoints()
 {
     $this->assertEquals('https://api.whitepayments.com/v1/charges', White::getEndPoint('charge'));
     $this->assertEquals('https://api.whitepayments.com/v1/charges', White::getEndPoint('charge_list'));
 }
コード例 #6
0
ファイル: services.php プロジェクト: okusnadi/white
<?php

require_once "../bin/config.php";
require_once "../lib/white.php";
require_once "../vendor/autoload.php";
date_default_timezone_set($cfg['timezone']);
$mongo = new Mongo($cfg['mongoHost']);
$w = new White($mongo, $cfg);
session_start();
$sessid = session_id();
function response($arr)
{
    print json_encode($arr);
}
function responseByStatus($arr, $status, $app)
{
    $app->response->setStatus($status);
    response($arr);
}
$app = new \Slim\Slim();
$app->response()->header("Content-Type", "application/json");
$app->get('/services/load-all/:secret', function ($secret) use($cfg, $mongo, $w, $app) {
    if ($w->isValid($secret, $cfg['secret'])) {
        response(array("msg" => "All items returned successfully.", "items" => $w->getAllLists()));
    } else {
        responseByStatus(array("msg" => "Please authenticate first."), 403, $app);
    }
});
$app->get('/services/load/:list/:secret', function ($list, $secret) use($cfg, $mongo, $w, $app) {
    if ($w->isValid($secret, $cfg['secret'])) {
        response(array("msg" => "All items returned successfully.", "items" => $w->getList($list)));
コード例 #7
0
ファイル: White.php プロジェクト: khadim-raath/insatiablehair
 /**
  * sets API Key
  * 
  * @param string $apiKey API key
  */
 public static function setApiKey($apiKey)
 {
     self::$apiKey = $apiKey;
 }
コード例 #8
0
 public function set_api_key($key)
 {
     parent::setApiKey($key);
 }
コード例 #9
0
 /**
  * Generated from @assert ("a") === true.
  *
  * @covers pgn\tags\White::validate
  */
 public function testValidate9()
 {
     $this->assertSame(true, $this->object->validate("a"));
 }