Symfony2-條帶整合示例
下載 Stripe API 庫並將其放在供應商資料夾中
來源:[ https://github.com/stripe/stripe-php] [1 ]
在控制器中包含庫
use Stripe\BalanceTransaction;
use Stripe\Charge;
use Stripe\Stripe;
require_once('../vendor/stripe/init.php');
設定條帶鍵
\Stripe\Stripe::setApiKey('stripe_secret_key');
呼叫交易的收費功能
$card = array(
'number' =>'cardccn',
'cvc' =>'cardcvc',
'exp_month' => 'expMonth',
'exp_year' => 'expYear',
);
$charge = Charge::create(
array(
'amount' => ('amount') * 100, // Amount will store in cent in Stripe Account
'currency' => 'usd',
'card' => $card,
'description' => '$data['description',
'receipt_email'=>'receipt_email'
)
);
得到充電的細節
$data = Charge::retrieve('ch_%');