Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if stripe charge is success or not

I have php code to charge credit card via stripe I am beginner in php classes, so i don't know how to tell if the payment is succeed or not

<?
require_once('lib/Stripe.php');
Stripe::setApiKey("sk_test_123ABC");
if(isset($_POST)) {
$payment = Stripe_Charge::create(array(
'amount'        => '50',

'currency'      => 'usd',

'card'          => array(
'number'=> '4242424242424242',
'exp_month' => '12',
'exp_year'=> '14',
'cvc'=> '123'),
'description'   => 'New payment'
)); }

print_r($payment);
?>

Results

Stripe_Charge Object
(
    [_apiKey:protected] => sk_test_123ABC
    [_values:protected] => Array
        (
            [id] => ch_157h99GwRVG4EfR7dCxslaAs
            [object] => charge
            [created] => 1418105445
            [livemode] => 
            [paid] => 1
            [amount] => 50
            [currency] => usd
            [refunded] => 
            [captured] => 1
            [refunds] => Stripe_List Object
                (
like image 753
Scott Dempasy Avatar asked Dec 09 '14 06:12

Scott Dempasy


1 Answers

Your question has its answer.If an object is returned of stripecharge object that means the payment was successfull.

like image 88
Sameer Shaikh Avatar answered Oct 29 '22 15:10

Sameer Shaikh