handle the response in the controller
This commit is contained in:
parent
a9d59d721f
commit
e2a12a1b11
|
@ -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'] = []
|
||||
|
|
|
@ -20,7 +20,6 @@ module DiscourseDonations
|
|||
description: description,
|
||||
currency: currency
|
||||
)
|
||||
@charge[:message] = @charge[:outcome][:seller_message] if @charge[:outcome]
|
||||
@charge
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] } }
|
||||
|
||||
|
|
Loading…
Reference in New Issue