SHARE
TWEET
Stripe charge creation
a guest
Sep 30th, 2015
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- public function auth($reservation_id, $token, $beneficiary_stripe_account_id, $amount_in_dollars, $is_app_fee_applied = null)
- {
- \Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY);
- $amount_in_cents = $amount_in_dollars * 100;
- $payment_details = [
- 'amount' => $amount_in_cents,
- 'currency' => 'usd',
- 'capture' => false,
- 'source' => $token,
- 'description' => 'description',
- ];
- if ($is_app_fee_applied) {
- $payment_details['application_fee'] = ceil($amount_in_cents * 0.121 - 30);
- }
- $payment_headers = [
- 'stripe_account' => $beneficiary_stripe_account_id,
- ];
- try {
- return \Stripe\Charge::create($payment_details, $payment_headers);
- }
- catch (\Stripe\Error\Card $e) {
- return $e->getJsonBody()['error']['message'];
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
