an “error code” of “0” means “No error - transaction successful“
an “error code” of “34” means “Future Payment Stored OK“
# File lib/active_merchant/billing/gateways/paystation.rb, line 45 45: def capture(money, authorization_token, options = {}) 46: post = new_request 47: 48: add_invoice(post, options) 49: add_amount(post, money, options) 50: 51: add_authorization_token(post, authorization_token, options[:credit_card_verification]) 52: 53: commit(post) 54: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 56 56: def purchase(money, payment_source, options = {}) 57: post = new_request 58: 59: add_invoice(post, options) 60: add_amount(post, money, options) 61: 62: if payment_source.is_a?(String) 63: add_token(post, payment_source) 64: else 65: add_credit_card(post, payment_source) 66: end 67: 68: add_customer_data(post, options) if options.has_key?(:customer) 69: 70: commit(post) 71: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 73 73: def store(credit_card, options = {}) 74: post = new_request 75: 76: add_invoice(post, options) 77: add_credit_card(post, credit_card) 78: store_credit_card(post, options) 79: 80: commit(post) 81: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 140 140: def add_amount(post, money, options) 141: 142: post[:am] = amount(money) 143: post[:cu] = options[:currency] || currency(money) 144: 145: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 107 107: def add_credit_card(post, credit_card) 108: 109: post[:cn] = credit_card.number 110: post[:ct] = credit_card.type 111: post[:ex] = format_date(credit_card.month, credit_card.year) 112: post[:cc] = credit_card.verification_value if credit_card.verification_value? 113: 114: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 95 95: def add_customer_data(post, options) 96: post[:mc] = options[:customer] 97: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 99 99: def add_invoice(post, options) 100: requires!(options, :order_id) 101: 102: post[:ms] = options[:order_id] # "Merchant Session", must be unique per request 103: post[:mo] = options[:invoice] # "Order Details", displayed in Paystation Admin 104: post[:mr] = options[:description] # "Merchant Reference Code", seen from Paystation Admin 105: end
bill a token (stored via “store”) rather than a Credit Card
# File lib/active_merchant/billing/gateways/paystation.rb, line 117 117: def add_token(post, token) 118: post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing 119: post[:ft] = token 120: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 161 161: def commit(post) 162: 163: post[:tm] = "T" if test? # test mode 164: 165: pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join("&") 166: 167: # need include paystation param as "initiator flag for payment engine" 168: data = ssl_post(URL, "#{pstn_prefix_params}&paystation=_empty") 169: response = parse(data) 170: message = message_from(response) 171: 172: PaystationResponse.new(success?(response), message, response, 173: :test => (response[:tm] && response[:tm].downcase == "t"), 174: :authorization => response[:paystation_transaction_id] 175: ) 176: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 186 186: def format_date(month, year) 187: "#{format(year, :two_digits)}#{format(month, :two_digits)}" 188: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 182 182: def message_from(response) 183: response[:em] 184: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 85 85: def new_request 86: { 87: :pi => @options[:paystation_id], # paystation account id 88: :gi => @options[:gateway_id], # paystation gateway id 89: "2p" => "t", # two-party transaction type 90: :nr => "t", # -- redirect?? 91: :df => "yymm" # date format: optional sometimes, required others 92: } 93: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 147 147: def parse(xml_response) 148: response = {} 149: 150: xml = REXML::Document.new(xml_response) 151: 152: # for normal payments, the root node is <Response> 153: # for "future payments", it's <PaystationFuturePaymentResponse> 154: xml.elements.each("#{xml.root.name}/*") do |element| 155: response[element.name.underscore.to_sym] = element.text 156: end 157: 158: response 159: end
# File lib/active_merchant/billing/gateways/paystation.rb, line 122 122: def store_credit_card(post, options) 123: 124: post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing 125: post[:fs] = "t" # tells paystation to store right now, not bill 126: post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one 127: 128: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.