application/libraries/Stripe.php
//Charge a customer on basis of customer ID
Charge a customer on basis of customer ID
Charge a customer on basis of customer ID
function charge_customer($amount, $custId, $currency='USD'){
        $amount = round($amount,2); 
        try{
            $charge = Stripe\Charge::create(array(
                        "amount" => $amount, 
                        "currency" => $currency,
                        "customer" => $custId
                    ));
            $var = $charge->balance_transaction;
            if(!isset($charge->balance_transaction))
                return array('status'=>false,'message'=>'Something went wrong');
            return array('status'=>true,'message'=>'Transaction completed successfully', 'data'=>$charge); 
        }catch(Exception $e){
            $message = $e->getMessage();
            return array('status'=>false,'message'=>$message);
        }
    }
function charge_customer ( $ amount , $ custId , $ currency = 'USD' ) { $ amount = round ( $ amount , 2 ) ; try { $ charge = Stripe \ Charge :: create ( array ( " amount " => $ amount , " currency " => $ currency , " customer " => $ custId ) ) ; $ var = $ charge -> balance_transaction ; if ( ! isset ( $ charge -> balance_transaction ) ) return array ( 'status' => false , 'message' => 'Something went wrong' ) ; return array ( 'status' => true , 'message' => 'Transaction completed successfully' , 'data' => $ charge ) ; } catch ( Exception $ e ) { $ message = $ e -> getMessage ( ) ; return array ( 'status' => false , 'message' => $ message ) ; } }
Charge a customer on basis of customer ID
Charge a customer on basis of customer ID
//amount in cents, for $1 it should be 100 cents //success