Sha256: fbbb7ee32e63729a772566bb3e06ba9ba993a9dc1c12493ea56ea39f9c60189f
Contents?: true
Size: 1.63 KB
Versions: 5
Compression:
Stored size: 1.63 KB
Contents
module Spreedly module CreationHelper def create_card_on(environment, options = {}) options = default_card_options.merge(options) environment.add_credit_card(options).payment_method end def create_failed_card_on(environment, options = {}) options = default_card_options.merge(number: '4012888888881881').merge(options) environment.add_credit_card(options).payment_method end def create_threeds_2_card_on(environment, options = {}) options = default_card_options.merge(number: '4556761029983886').merge(options) environment.add_credit_card(options).payment_method end def create_sprel_on(environment) body = default_sprel_body(environment) redirect_html = raw_ssl_request(:post, environment.transparent_redirect_form_action, body, {}).body redirect_html.match(/token=(\w+)/)[1] end private def default_card_options { email: 'perrin@wot.com', number: '5555555555554444', month: 1, year: 2023, last_name: 'Aybara', first_name: 'Perrin', retained: true } end def default_sprel_body(environment) { environment_key: environment.key, redirect_url: "http://example.com/transparent_redirect_complete", payment_method_type: "sprel" }.map do |key, value| "#{key}=#{CGI.escape(value.to_s)}" end.compact.join("&") end def raw_ssl_request(method, endpoint, body, headers, options = {}) raw_response = Timeout::timeout(60) do connection = Spreedly::Connection.new(endpoint) connection.request(method, body, headers) end raw_response end end end
Version data entries
5 entries across 5 versions & 1 rubygems