Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/spree/payment_method/stripe_credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def try_void(payment)
reason: payment_intents_refund_reason
).response
else
payment.void_transaction!
void(payment.response_code, nil, nil)
end
end

Expand Down
117 changes: 76 additions & 41 deletions spec/features/stripe_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,54 +240,89 @@
expect(page).to have_content("Your order has been processed successfully")
end

it "can re-use saved cards" do
within_frame find('#card_number iframe') do
'4242 4242 4242 4242'.split('').each { |n| find_field('cardnumber').native.send_keys(n) }
end
within_frame(find '#card_cvc iframe') { fill_in 'cvc', with: '123' }
within_frame(find '#card_expiry iframe') do
'0132'.split('').each { |n| find_field('exp-date').native.send_keys(n) }
end
click_button "Save and Continue"
expect(page).to have_current_path("/checkout/confirm")
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")
context "when reusing saved cards" do
stub_authorization!

visit spree.root_path
click_link "DL-44"
click_button "Add To Cart"
it "completes the order, captures the payment and cancels the order" do
within_frame find('#card_number iframe') do
'4242 4242 4242 4242'.split('').each { |n| find_field('cardnumber').native.send_keys(n) }
end
within_frame(find '#card_cvc iframe') { fill_in 'cvc', with: '123' }
within_frame(find '#card_expiry iframe') do
'0132'.split('').each { |n| find_field('exp-date').native.send_keys(n) }
end
click_button "Save and Continue"
expect(page).to have_current_path("/checkout/confirm")
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")

expect(page).to have_current_path("/cart")
click_button "Checkout"
visit spree.root_path
click_link "DL-44"
click_button "Add To Cart"

# Address
expect(page).to have_current_path("/checkout/address")
expect(page).to have_current_path("/cart")
click_button "Checkout"

within("#billing") do
fill_in_name
fill_in "Street Address", with: "YT-1300"
fill_in "City", with: "Mos Eisley"
select "United States of America", from: "Country"
select country.states.first.name, from: "order_bill_address_attributes_state_id"
fill_in "Zip", with: "12010"
fill_in "Phone", with: "(555) 555-5555"
end
click_on "Save and Continue"
# Address
expect(page).to have_current_path("/checkout/address")

# Delivery
expect(page).to have_current_path("/checkout/delivery")
expect(page).to have_content("UPS Ground")
click_on "Save and Continue"
within("#billing") do
fill_in_name
fill_in "Street Address", with: "YT-1300"
fill_in "City", with: "Mos Eisley"
select "United States of America", from: "Country"
select country.states.first.name, from: "order_bill_address_attributes_state_id"
fill_in "Zip", with: "12010"
fill_in "Phone", with: "(555) 555-5555"
end
click_on "Save and Continue"

# Payment
expect(page).to have_current_path("/checkout/payment")
choose "Use an existing card on file"
click_button "Save and Continue"
# Delivery
expect(page).to have_current_path("/checkout/delivery")
expect(page).to have_content("UPS Ground")
click_on "Save and Continue"

# Confirm
expect(page).to have_current_path("/checkout/confirm")
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")
# Payment
expect(page).to have_current_path("/checkout/payment")
choose "Use an existing card on file"
click_button "Save and Continue"

# Confirm
expect(page).to have_current_path("/checkout/confirm")
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")

Spree::Order.complete.each do |order|
# Capture in backend

visit spree.admin_path

expect(page).to have_selector("#listing_orders tbody tr", count: 2)

click_link order.number

click_link "Payments"
find(".fa-capture").click

expect(page).to have_content "Payment Updated"
expect(find("table#payments")).to have_content "Completed"

# Order cancel, after capture
click_link "Cart"

within "#sidebar" do
expect(page).to have_content "Completed"
end

find('input[value="Cancel"]').click

expect(page).to have_content "Order canceled"

within "#sidebar" do
expect(page).to have_content "Canceled"
end
end
end
end

it_behaves_like "Stripe Elements invalid payments"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@

shared_examples 'voids the payment transaction' do
it 'voids the payment transaction' do
expect(payment).to receive(:void_transaction!)
expect(gateway).to receive(:void)

subject.try_void(payment)
end
Expand Down