Jump to content
Larry Ullman's Book Forums

Recommended Posts

RE: Page 518 Capturing charges and the download script stripe_capture.php


Should this script work as it is written in book and download?

my code below:


Stripe:: setApiKey(STRIPE_PRIVATE_KEY);

$charge = Stripe_Charge::retrieve($charge_id);

$charge->capture(); <<<<<<<<<<<This line is not working


When I echo out the charge_id from the database the value = the value in the  charges table.



I just performed a live purchase.  Then went to stripe website and verified it was not captured nor  paid.

Then I went to my admin->view_order.php ..Clicked Ship This Order...I get an error message from Stripe.

But then when I look in stripe.com under payments the order now shows captured and Status :Paid


Your thoughts?



Thank you very much.

Link to post
Share on other sites

Hey Larry.. many thanks for the quick response....Error message == A System error occurred. We apologize for the inconvenience.

Everything else seems to be working..except for the error message.....I did notice that on stripe dashboard...CVC Check is showing Failed...


Only diff in my code is the email below... I am leaving this blank...

    Stripe:: setApiKey(STRIPE_PRIVATE_KEY);
    $email = '';
    $customer = Stripe_Customer::create(array(
    'description' => "Customer $email",
    'email' => $email,
    'card' => $token,
    'plan' => 'kip_basic'


Ahhh do not worry about it ...I will keep looking to see if I can find what is not working and then maybe that will lead me to why the error is appearing....

Thank you

Link to post
Share on other sites
  • 1 year later...

Retrieving the last 4 digits of the credit card:


I'm having problems retrieving the last 4 digits of the credit card used for payment from Stripe, so I can include n the receipt.


I have found some information online, but it does not seem to work.


Has anyone had any luck with this?





Link to post
Share on other sites

For anyone still looking for  way to retrieve the last4 numbers of the credit card so that they are available for the receipt etc, here is the solution:


After Larry's code:


$charge =\Stripe\charge::create(array(

"amount" => $order_total,

"currency" => "usd",

"source" = > $token,

"description" => $_SESSION['email'], ));


place the following line of code:


$last4 = $charge->source->last4;


then update the order query to replace the previous number from $cc_last_four.

Link to post
Share on other sites
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...