Class: ActiveMerchant::Billing::UsaEpayCustom
- Inherits:
-
UsaEpayTransactionGateway
- Object
- UsaEpayTransactionGateway
- ActiveMerchant::Billing::UsaEpayCustom
- Defined in:
- lib/usaepay/gateway.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pin ⇒ Object
readonly
Returns the value of attribute pin.
Instance Method Summary collapse
- #add_save_card(post, options) ⇒ Object
- #add_token(post, credit_card) ⇒ Object
- #authorize(money, credit_card, options = {}) ⇒ Object
- #parse(body) ⇒ Object
- #purchase(money, payment, options = {}) ⇒ Object
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/usaepay/gateway.rb', line 5 def key @key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/usaepay/gateway.rb', line 5 def @options end |
#pin ⇒ Object (readonly)
Returns the value of attribute pin.
5 6 7 |
# File 'lib/usaepay/gateway.rb', line 5 def pin @pin end |
Instance Method Details
#add_save_card(post, options) ⇒ Object
67 68 69 |
# File 'lib/usaepay/gateway.rb', line 67 def add_save_card(post, ) post[:saveCard] = ([:save_card] ? 1 : 0) if .has_key?(:save_card) end |
#add_token(post, credit_card) ⇒ Object
63 64 65 |
# File 'lib/usaepay/gateway.rb', line 63 def add_token(post, credit_card) post[:card] = credit_card end |
#authorize(money, credit_card, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/usaepay/gateway.rb', line 9 def (money, credit_card, = {}) billing_address = [:billing_address] || [:address] post = {} post[:ip] = [:ip_address] if [:ip_address].present? post[:name] = billing_address[:name] if billing_address.present? add_amount(post, money) add_invoice(post, ) add_address_for_type(:billing, post, credit_card, billing_address) if billing_address if credit_card.is_a? String add_token(post, credit_card) else add_payment(post, credit_card) add_address(post, credit_card, ) unless credit_card.track_data.present? add_customer_data(post, ) end end add_split_payments(post, ) add_recurring_fields(post, ) add_custom_fields(post, ) add_line_items(post, ) add_test_mode(post, ) add_save_card(post, ) commit(:authorization, post) end |
#parse(body) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/usaepay/gateway.rb', line 71 def parse(body) fields = {} for line in body.split('&') key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten fields[key] = CGI.unescape(value.to_s) end { :status => fields['UMstatus'], :auth_code => fields['UMauthCode'], :ref_num => fields['UMrefNum'], :batch => fields['UMbatch'], :avs_result => fields['UMavsResult'], :avs_result_code => fields['UMavsResultCode'], :cvv2_result => fields['UMcvv2Result'], :cvv2_result_code => fields['UMcvv2ResultCode'], :vpas_result_code => fields['UMvpasResultCode'], :result => fields['UMresult'], :error => fields['UMerror'], :error_code => fields['UMerrorcode'], :acs_url => fields['UMacsurl'], :payload => fields['UMpayload'], :token => fields['UMcardRef'] }.delete_if { |k, v| v.nil? } end |
#purchase(money, payment, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/usaepay/gateway.rb', line 37 def purchase(money, payment, = {}) post = {} add_amount(post, money) add_invoice(post, ) if payment.is_a? String add_token(post, payment) else add_payment(post, payment, ) unless payment.respond_to?(:track_data) && payment.track_data.present? add_address(post, payment, ) add_customer_data(post, ) end end add_split_payments(post, ) add_recurring_fields(post, ) add_custom_fields(post, ) add_line_items(post, ) add_test_mode(post, ) add_save_card(post, ) payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post) end |