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
payment = DiscourseDonations::Stripe.new(secret_key, stripe_options)
response = payment.charge(email, params)
response['message'] = response['outcome']['seller_message']
end
response['rewards'] = []

View File

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

View File

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

View File

@ -34,13 +34,6 @@ module DiscourseDonations
subject.charge(email, params)
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
let(:charge_options) { { customer: customer.id, amount: params[:amount], description: stripe_options[:description], currency: stripe_options[:currency] } }