Right now I'm making successful charges with my Rails app but I'd like to to fetch certain details about the transaction such as the description of the item purchase and the last four digits of the credit card to show the user on their receipt page.
I've been looking at the documentation but there's really nothing that explains how to give an app the token and get back the charge_id which I can then use to get a hash of other info about the charge.
Any help would be huge. Thanks!
Stripe returns charge IDs in the response to a charge creation call. If you're using the Ruby library, you can do something like this to get the ID:
require "stripe"
Stripe.api_key = '<your api key>'
charge = Stripe::Charge.create(
:amount => 400,
:currency => "usd",
:card => "tok_JkdcRcQfyFsoZ2", # obtained with Stripe.js
:description => "Charge for [email protected]"
)
You can then store charge.id
and use the Charge Retrieve call to look up charge details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With