2017 © Pedro Peláez
 

library white

White makes accepting online payments in the Middle East a piece of cake

image

white/white

White makes accepting online payments in the Middle East a piece of cake

  • Friday, February 27, 2015
  • by white
  • Repository
  • 2 Watchers
  • 3 Stars
  • 70 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

White PHP

White makes accepting payments in the Middle East ridiculously easy. Sign up for an account at whitepayments.com., (*1)

Getting Started

Using White with your PHP project is simple., (*2)

If you're using Composer (and really, who isn't these days amirite?), you can simply run:, (*3)

php composer.phar require white/white

.. or add a line to your composer.json file:, (*4)

{
    "require": {
        "white/white": "*"
    }
}

Now, running php composer.phar install will pull the library directly to your local vendor folder., (*5)

Note: If you're running on a shared host, then you may need to set the allow_url_fopen flag for the php commands. For the install command, for example, this would look like php -d allow_url_fopen=On composer.phar install. The -d overrides the php.ini settings, where allow_url_fopen is usually set to Off., (*6)

Using White

You'll need an account with White if you don't already have one (grab one real quick at whitepayments.com and come right back .. we'll wait)., (*7)

Got an account? Great .. let's do this., (*8)

1. Initializing White

To get started, you'll need to initialize White with your secret API key. Here's how that looks (fear not .. we're using a test key, so no real money will be exchanging hands):, (*9)

require_once('vendor/autoload.php'); # At the top of your PHP file

# Initialize White object
White::setApiKey('test_sec_k_25dd497d7e657bb761ad6');

That's it! You probably want to do something with the White object though -- it gets really bored when it doesn't have anything to do., (*10)

Let's run a transaction, shall we., (*11)

2. Processing a transaction through White

Now, for the fun part. Here's all the code you need to process a transaction with White:, (*12)

White_Charge::create(array(
  "amount" => 10500, // AED 105.00
  "currency" => "aed",
  "card" => array(
    "number" => "4242424242424242",
    "exp_month" => 11,
    "exp_year" => 2016,
    "cvc" => "123"
  ),
  "description" => "Charge for test@example.com"
));

This transaction should be successful since we used the 4242 4242 4242 4242 test credit card. For a complete list of test cards, and their expected output you can check out this link here., (*13)

How can you tell that it was successful? Well, if no exception is raised then you're in the clear., (*14)

3. Handling Errors

Any errors that may occur during a transaction is raised as an Exception. Here's an example of how you can handle errors with White:, (*15)

try {
  // Use White's bindings...
} catch(White_Error_Banking $e) {
  // Since it's a decline, White_Error_Banking will be caught
  print('Status is:' . $e->getHttpStatus() . "\n");
  print('Code is:' . $e->getErrorCode() . "\n");
  print('Message is:' . $e->getMessage() . "\n");

} catch (White_Error_Request $e) {
  // Invalid parameters were supplied to White's API

} catch (White_Error_Authentication $e) {
  // There's a problem with that API key you provided

} catch (White_Error $e) {
  // Display a very generic error to the user, and maybe send
  // yourself an email

} catch (Exception $e) {
  // Something else happened, completely unrelated to White

}

Testing White

It's probably a good idea to run the unit tests to make sure that everything is fine and dandy. That's also simple.. just run this command from the root of your project folder:, (*16)

php vendor/bin/phpunit tests --bootstrap vendor/autoload.php

Note: you'll need to pull the development dependencies as well, using composer update --dev in order to run the test suites., (*17)

Contributing

Read our Contributing Guidelines for details, (*18)

The Versions

27/02 2015

dev-master

9999999-dev

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

27/02 2015

v2.0.3

2.0.3.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

16/02 2015

dev-add_retrieve

dev-add_retrieve

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

26/01 2015

v2.0.2

2.0.2.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

26/01 2015

v2.0.1

2.0.1.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

17/01 2015

v2.0.0

2.0.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

21/12 2014

1.4.1

1.4.1.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

16/12 2014

v1.4

1.4.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

28/11 2014

v1.3.3

1.3.3.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

28/11 2014

v1.3.2

1.3.2.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

26/10 2014

v1.3.1

1.3.1.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

26/10 2014

v1.3

1.3.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

20/10 2014

v1.2

1.2.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

28/09 2014

v1.1

1.1.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

12/09 2014

v1.0.1

1.0.1.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Requires

 

The Development Requires

10/09 2014

v1

1.0.0.0

White makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Requires

 

The Development Requires