Last active
June 28, 2019 16:20
-
-
Save webuilder240/69c2ea623b61249bec0cb411da283b05 to your computer and use it in GitHub Desktop.
for capybara pay.jp payment modal helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PayjpModalHelpers | |
def payment_payjp(card_number: '4242 4242 4242 4242', | |
expiration_month: '12', expiration_year: '20', cvc: "123", card_name: "YUI ARAGAKI") | |
sleep(1) # wait for the js to create the popup in response to pressing the button | |
within_frame 'payjp-checkout-iframe' do # must be selenium | |
driver = page.driver.browser | |
sleep 2 | |
credit_card = driver.find_element(css: '#payjp_cardNumber') | |
credit_card.send_keys card_number | |
expiration_month_el = driver.find_element(css: '#payjp_cardExpiresMonth') | |
expiration_month_el.send_keys expiration_month | |
expiration_year_el = driver.find_element(css: '#payjp_cardExpiresYear') | |
expiration_year_el.send_keys expiration_year | |
cvc_el = driver.find_element(css: '#payjp_cardCvc') | |
cvc_el.send_keys cvc | |
card_name_el = driver.find_element(css: '#payjp_cardName') | |
card_name_el.send_keys card_name | |
pay_btn = driver.find_element(css: '#payjp_cardSubmit') | |
pay_btn.click | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment