Skip to content

Instantly share code, notes, and snippets.

@delba
Created March 28, 2014 00:39
Show Gist options
  • Save delba/9822518 to your computer and use it in GitHub Desktop.
Save delba/9822518 to your computer and use it in GitHub Desktop.
Processing payment in a queue
class StripeCharger
include Sidekiq::Worker
def perform(charge_id)
@charge = Charge.find(charge_id)
begin
stripe_charge = Stripe::Charge.create(charge_params)
@charge.update stripe: stripe_charge.to_json
rescue Stripe::CardError => e
logger.error e
end
end
private
def charge_params
{
amount: @charge.amount,
currency: @charge.currency,
card: @charge.card_token,
description: @charge.id
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment