handle the response in the controller

This commit is contained in:
Rimian Perkins 2017-05-02 10:02:07 +10:00
parent a9d59d721f
commit e2a12a1b11
4 changed files with 2 additions and 9 deletions

View File

@ -14,6 +14,7 @@ module DiscourseDonations
else else
payment = DiscourseDonations::Stripe.new(secret_key, stripe_options) payment = DiscourseDonations::Stripe.new(secret_key, stripe_options)
response = payment.charge(email, params) response = payment.charge(email, params)
response['message'] = response['outcome']['seller_message']
end end
response['rewards'] = [] response['rewards'] = []

View File

@ -20,7 +20,6 @@ module DiscourseDonations
description: description, description: description,
currency: currency currency: currency
) )
@charge[:message] = @charge[:outcome][:seller_message] if @charge[:outcome]
@charge @charge
end end

View File

@ -79,7 +79,7 @@ module DiscourseDonations
end end
it 'has no rewards' do it 'has no rewards' do
stripe.expects(:create).returns({ outcome: { seller_message: 'bummer' } }) stripe.expects(:create).returns({ 'outcome' => { 'seller_message' => 'bummer' } })
post :create post :create
expect(response_rewards).to be_empty expect(response_rewards).to be_empty
end end

View File

@ -34,13 +34,6 @@ module DiscourseDonations
subject.charge(email, params) subject.charge(email, params)
end end
it 'has a message' do
::Stripe::Customer.expects(:create).returns(customer)
::Stripe::Charge.expects(:create).returns({ outcome: { seller_message: 'yay!' } })
response = subject.charge(email, params)
expect(response[:message]).to eq 'yay!'
end
describe '.successful?' do describe '.successful?' do
let(:charge_options) { { customer: customer.id, amount: params[:amount], description: stripe_options[:description], currency: stripe_options[:currency] } } let(:charge_options) { { customer: customer.id, amount: params[:amount], description: stripe_options[:description], currency: stripe_options[:currency] } }