PHP code example of chronon / stripe
1. Go to this page and download the library: Download chronon/stripe library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chronon / stripe example snippets
App::import('Vendor', array('file' => 'autoload'));
CakePlugin::load('Stripe');
CakePlugin::loadAll();
Configure::write('Stripe.TestSecret', 'yourStripeTestingAPIKeyHere');
Configure::write('Stripe.LiveSecret', 'yourStripeLiveAPIKeyHere');
Configure::write('Stripe.mode', 'Test');
Configure::write('Stripe.currency', 'usd');
Configure::write('Stripe.fields', array(
'stripe_id' => 'id',
'stripe_last4' => array('card' => 'last4'),
'stripe_address_zip_check' => array('card' => 'address_zip_check'),
'stripe_cvc_check' => array('card' => 'cvc_check'),
'stripe_amount' => 'amount'
));
CakeLog::config('stripe', array(
'engine' => 'FileLog',
'types' => array('info', 'error'),
'scopes' => array('stripe'),
'file' => 'stripe',
));
public $components = array(
'Stripe.Stripe'
);
$data = array(
'amount' => '7.59',
'stripeToken' => 'tok_0NAEASV7h0m7ny', // either the token
'stripeCustomer' => 'cus_2x62nI9WxHsL37' // or the customer id, not both.
);
$data = array(
'amount' => '7.59',
'stripeToken' => 'tok_0NAEASV7h0m7ny',
'description' => 'Casi Robot - [email protected] '
);
$result = $this->Stripe->charge($data);
$result = array(
'stripe_id' => 'ch_0NXLLCydWzSIeE'
);
$result = array(
'stripe_id' => 'ch_0NXLLCydWzSIeE',
'stripe_last4' => '4242',
'stripe_address_zip_check' => 'pass',
'stripe_cvc_check' => 'pass',
'stripe_amount' => 769
);
$data = array(
'stripeToken' => 'tok_0NAEASV7h0m7ny',
'description' => 'Casi Robot - [email protected] '
);
$result = $this->Stripe->customerCreate($data);
$result = array(
'stripe_id' => 'cus_2x62nI9WxHsL37'
);
$data = array(
'stripeToken' => 'tok_0NAEASV7h0m7ny',
'description' => 'Casi Robot',
'email' => '[email protected] ',
'plan' => 'Silver Plan Deluxe'
);
$result = $this->Stripe->customerCreate($data);
$customer = $this->Stripe->customerRetrieve('cus_2x62nI9WxHsL37');
$customer = $this->Stripe->customerRetrieve('cus_2x62nI9WxHsL37');
$customer->email = '[email protected] ';
$customer->save();
$customer = $this->Stripe->customerRetrieve('cus_2x62nI9WxHsL37');
$chargeData = array(
'amount' => '14.69',
'stripeCustomer' => $customer['stripe_id']
);
$charge = $this->Stripe->charge($chargeData);
$customer = $this->Stripe->customerRetrieve('cus_2x62nI9WxHsL37');
$customer->card = $this->request->data['stripeToken'];
$customer->save();