Last active
August 29, 2015 14:12
-
-
Save yazinsai/20993e22a7f257557115 to your computer and use it in GitHub Desktop.
Create and charge a customer using pure PHP (for Alexey)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Step 1: Create a customer from the card details | |
require_once("vendor/autoload.php"); | |
White::setApiKey("test_sec_k_886a1e89b2c0abce479bf"); // Secret key | |
$customer = White_Customer::create(array( | |
'name' => "John Doe", | |
'description' => "Amember customer", | |
'email' => "john.doe@example.com", | |
'card' => array( | |
'number' => "4242424242424242", | |
'exp_month' => 12, | |
'exp_year' => 2015, | |
'cvc' => '123' | |
) | |
)); | |
$id = $customer->id; // Store this for later billing | |
# Step 2: Bill at a later time | |
$charge = White_Charge::create(array( | |
"amount" => 1000, // = $10.00 | |
"currency" => "USD", | |
"customer_id" => $id, | |
"description" => "Charge for monthly plan" | |
)); | |
var_export($charge); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few things have changed with the release of the new API:
card
parameter is no longer nested in the token request$customer->id
instead of$customer->tag
amount=1000
is interpreted as$10.00
)