# File lib/active_merchant/billing/gateways/plugnpay.rb, line 134 134: def capture(money, authorization, options = {}) 135: post = PlugnpayPostData.new 136: 137: post[:orderID] = authorization 138: 139: add_amount(post, money, options) 140: add_customer_data(post, options) 141: 142: commit(:capture, post) 143: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 154 154: def credit(money, identification_or_creditcard, options = {}) 155: post = PlugnpayPostData.new 156: add_amount(post, money, options) 157: 158: if identification_or_creditcard.is_a?(String) 159: deprecated CREDIT_DEPRECATION_MESSAGE 160: refund(money, identification_or_creditcard, options) 161: else 162: add_creditcard(post, identification_or_creditcard) 163: add_addresses(post, options) 164: add_customer_data(post, options) 165: 166: commit(:credit, post) 167: end 168: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 108 108: def purchase(money, creditcard, options = {}) 109: post = PlugnpayPostData.new 110: 111: add_amount(post, money, options) 112: add_creditcard(post, creditcard) 113: add_addresses(post, options) 114: add_invoice_data(post, options) 115: add_customer_data(post, options) 116: 117: post[:authtype] = 'authpostauth' 118: commit(:authorization, post) 119: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 170 170: def refund(money, reference, options = {}) 171: post = PlugnpayPostData.new 172: add_amount(post, money, options) 173: post[:orderID] = reference 174: commit(:refund, post) 175: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 145 145: def void(authorization, options = {}) 146: post = PlugnpayPostData.new 147: 148: post[:orderID] = authorization 149: post[:txn_type] = 'auth' 150: 151: commit(:void, post) 152: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 234 234: def add_addresses(post, options) 235: if address = options[:billing_address] || options[:address] 236: post[:card_address1] = address[:address1] 237: post[:card_zip] = address[:zip] 238: post[:card_city] = address[:city] 239: post[:card_country] = address[:country] 240: post[:phone] = address[:phone] 241: 242: case address[:country] 243: when 'US', 'CA' 244: post[:card_state] = address[:state] 245: else 246: post[:card_state] = 'ZZ' 247: post[:card_prov] = address[:state] 248: end 249: end 250: 251: if shipping_address = options[:shipping_address] || address 252: post[:shipname] = shipping_address[:name] 253: post[:address1] = shipping_address[:address1] 254: post[:address2] = shipping_address[:address2] 255: post[:city] = shipping_address[:city] 256: 257: case shipping_address[:country] 258: when 'US', 'CA' 259: post[:state] = shipping_address[:state] 260: else 261: post[:state] = 'ZZ' 262: post[:province] = shipping_address[:state] 263: end 264: 265: post[:country] = shipping_address[:country] 266: post[:zip] = shipping_address[:zip] 267: end 268: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 270 270: def add_amount(post, money, options) 271: post[:card_amount] = amount(money) 272: post[:currency] = options[:currency] || currency(money) 273: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 216 216: def add_creditcard(post, creditcard) 217: post[:card_number] = creditcard.number 218: post[:card_cvv] = creditcard.verification_value 219: post[:card_exp] = expdate(creditcard) 220: post[:card_name] = creditcard.name.slice(0..38) 221: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 223 223: def add_customer_data(post, options) 224: post[:email] = options[:email] 225: post[:dontsndmail] = 'yes' unless options[:send_email_confirmation] 226: post[:ipaddress] = options[:ip] 227: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 229 229: def add_invoice_data(post, options) 230: post[:shipping] = amount(options[:shipping]) unless options[:shipping].blank? 231: post[:tax] = amount(options[:tax]) unless options[:tax].blank? 232: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 178 178: def commit(action, post) 179: response = parse( ssl_post(URL, post_data(action, post)) ) 180: 181: success = SUCCESS_CODES.include?(response[:finalstatus]) 182: message = success ? 'Success' : message_from(response) 183: 184: Response.new(success, message, response, 185: :test => test?, 186: :authorization => response[:orderid], 187: :avs_result => { :code => response[:avs_code] }, 188: :cvv_result => response[:cvvresp] 189: ) 190: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 290 290: def expdate(creditcard) 291: year = sprintf("%.4i", creditcard.year) 292: month = sprintf("%.2i", creditcard.month) 293: 294: "#{month}/#{year[-2..-1]}" 295: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 286 286: def message_from(results) 287: PAYMENT_GATEWAY_RESPONSES[results[:resp_code]] 288: end
Make a ruby type out of the response string
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 276 276: def normalize(field) 277: case field 278: when "true" then true 279: when "false" then false 280: when "" then nil 281: when "null" then nil 282: else field 283: end 284: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 192 192: def parse(body) 193: body = CGI.unescape(body) 194: results = {} 195: body.split('&').collect { |e| e.split('=') }.each do |key,value| 196: results[key.downcase.to_sym] = normalize(value.to_s.strip) 197: end 198: 199: results.delete(:publisher_password) 200: results[:avs_message] = AVS_MESSAGES[results[:avs_code]] if results[:avs_code] 201: results[:card_code_message] = CARD_CODE_MESSAGES[results[:cvvresp]] if results[:cvvresp] 202: 203: results 204: end
# File lib/active_merchant/billing/gateways/plugnpay.rb, line 206 206: def post_data(action, post) 207: post[:mode] = TRANSACTIONS[action] 208: post[:convert] = 'underscores' 209: post[:app_level] = 0 210: post[:publisher_name] = @options[:login] 211: post[:publisher_password] = @options[:password] 212: 213: post.to_s 214: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.