Rails : Spree : Get the gateway and other payment information

This post covers tips how you can get the payment objects related to particular order / line items.

line_item = order.line_items.first
payments = order.payments
payment = payment.first
payment_method = payment.payment_method
=> #<Spree::CreditCard:0x0000000e795190
 id: 5,
 month: "12",
 year: "2019",
 cc_type: "visa",
 last_digits: "4242",
 address_id: nil,
 gateway_customer_profile_id: "cus_83nlvzTDq8eJln",
 gateway_payment_profile_id: "card_17ngACBFSOv6rFJZVfRZYpVT",
 created_at: Fri, 11 Mar 2016 02:38:05 UTC +00:00,

Get all charge objects

Now since Spree::Stripe uses active merchant and it creates separate customer in stripe for every order, so you can get the charge object like


Get single Charge Object

# => ch_17pzjwBFSOv6rFJZBbd3YNuS
















































Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s