app/helpers/charges_helper.rb
# determine if the given user has ordered by card and if so return the charge
# given user may be nil, in which case nil is returned (save caller checking)
# nil is also returned if no stripe order was placed
# from the returned charge one may get the card (to display last4) or
#    the customer to create a new charge (with the charge_customer method)
determine if the given user has ordered by card and if so return the charge
given user may be nil, in which case nil is returned (save caller checking)
nil is also returned if no stripe order was placed
from the returned charge one may get the card (to display last4) or
the customer to create a new charge (with the charge_customer method)
determine if the given user has ordered by card and if so return the charge given user may be nil in which case nil is returned ( save caller checking ) nil is also returned if no stripe order was placed from the returned charge one may get the card ( to display last4 ) or the customer to create a new charge ( with the charge_customer method )
def has_charge user
    return nil unless user
    order = Order.where(email: user.email).where(payment_type: :stripe).order(:ordered_on).last
    return nil unless order
    Stripe::Charge.retrieve(order.payment_info)
  end
def has_charge user return nil unless user order = Order . where ( email : user . email ) . where ( payment_type : :stripe ) . order ( :ordered_on ) . last return nil unless order Stripe :: Charge . retrieve ( order . payment_info ) end
determine if the given user has ordered by card and if so return the charge
given user may be nil, in which case nil is returned (save caller checking)
nil is also returned if no stripe order was placed
from the returned charge one may get the card (to display last4) or
the customer to create a new charge (with the charge_customer method)
determine if the given user has ordered by card and if so return the charge given user may be nil in which case nil is returned ( save caller checking ) nil is also returned if no stripe order was placed from the returned charge one may get the card ( to display last4 ) or the customer to create a new charge ( with the charge_customer method )
user
<not_specific>