public function createCharge($chargeAmount, $chargeCurrency, $paymentToken, $stripeAccountId = null, $applicationFee = 0, $chargeDescription = '', $chargeMetadata = [])
    {
        $chargeOptions = [
            'amount'            => $chargeAmount,
            'currency'          => $chargeCurrency,
            'source'            => $paymentToken,
            'description'       => $chargeDescription,
            'metadata'          => $chargeMetadata
        ];

        if ($applicationFee && intval($applicationFee) > 0) {
            $chargeOptions['application_fee'] = intval($applicationFee);
        }

        $connectedAccountOptions = [];

        if ($stripeAccountId) {
            $connectedAccountOptions['stripe_account'] = $stripeAccountId;
        }

        return Charge::create($chargeOptions, $connectedAccountOptions);
    }
public function createCharge($chargeAmount, $chargeCurrency, $paymentToken, $stripeAccountId = null, $applicationFee = 0, $chargeDescription = '', $chargeMetadata = [])
    {
        $chargeOptions = [
            'amount'            => $chargeAmount,
            'currency'          => $chargeCurrency,
            'source'            => $paymentToken,
            'description'       => $chargeDescription,
            'metadata'          => $chargeMetadata
        ];

        if ($applicationFee && intval($applicationFee) > 0) {
            $chargeOptions['application_fee'] = intval($applicationFee);
        }

        $connectedAccountOptions = [];

        if ($stripeAccountId) {
            $connectedAccountOptions['stripe_account'] = $stripeAccountId;
        }

        return Charge::create($chargeOptions, $connectedAccountOptions);
    }
public function createCharge ( $ chargeAmount , $ chargeCurrency , $ paymentToken , $ stripeAccountId = null , $ applicationFee = 0 , $ chargeDescription = '' , $ chargeMetadata = [ ] ) { $ chargeOptions = [ 'amount' => $ chargeAmount , 'currency' => $ chargeCurrency , 'source' => $ paymentToken , 'description' => $ chargeDescription , 'metadata' => $ chargeMetadata ] ; if ( $ applicationFee && intval ( $ applicationFee ) > 0 ) { $ chargeOptions [ 'application_fee' ] = intval ( $ applicationFee ) ; } $ connectedAccountOptions = [ ] ; if ( $ stripeAccountId ) { $ connectedAccountOptions [ 'stripe_account' ] = $ stripeAccountId ; } return Charge :: create ( $ chargeOptions , $ connectedAccountOptions ) ; }
Create a new Charge from a payment token, to an optional connected stripe account, with an optional application fee.

@throws HttpException:
- If the payment token is invalid (payment failed)

@see https://stripe.com/docs/charges

@param int    $chargeAmount: The charge amount in cents
@param string $chargeCurrency: The charge currency to use
@param string $paymentToken: The payment token returned by the payment form (Stripe.js)
@param string $stripeAccountId: The connected stripe account ID
@param int    $applicationFee: The fee taken by the platform, in cents
@param string $description: An optional charge description
@param array  $metadata: An optional array of metadatas

@return Charge
Create a new Charge from a payment token to an optional connected stripe account with an optional application fee .