yetanothernguyen-activemerchant 1.16.0 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +95 -0
- data/CONTRIBUTORS +29 -0
- data/lib/active_merchant/billing/credit_card.rb +105 -19
- data/lib/active_merchant/billing/credit_card_methods.rb +5 -1
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net.rb +24 -2
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -18
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +110 -4
- data/lib/active_merchant/billing/gateways/beanstream.rb +29 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +9 -4
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +279 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +9 -9
- data/lib/active_merchant/billing/gateways/elavon.rb +2 -1
- data/lib/active_merchant/billing/gateways/epay.rb +12 -6
- data/lib/active_merchant/billing/gateways/eway_managed.rb +46 -12
- data/lib/active_merchant/billing/gateways/exact.rb +5 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +3 -3
- data/lib/active_merchant/billing/gateways/ipay88.rb +157 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +3 -3
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +4 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +244 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +94 -56
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +57 -34
- data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow.rb +10 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +8 -5
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +93 -40
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +8 -3
- data/lib/active_merchant/billing/gateways/qbms.rb +4 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +97 -22
- data/lib/active_merchant/billing/gateways/realex.rb +5 -1
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +136 -49
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +7 -2
- data/lib/active_merchant/billing/gateways/stripe.rb +51 -19
- data/lib/active_merchant/billing/gateways/usa_epay.rb +13 -184
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1496 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +2 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -1
- data/lib/active_merchant/billing/gateways/worldpay.rb +1 -1
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +6 -2
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +4 -4
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/helper.rb +19 -2
- data/lib/active_merchant/billing/integrations/ipay88/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/ipay88/return.rb +121 -0
- data/lib/active_merchant/billing/integrations/ipay88.rb +40 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +1 -1
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +4 -4
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +18 -2
- data/lib/active_merchant/billing/integrations/two_checkout.rb +1 -2
- data/lib/active_merchant/railtie.rb +7 -7
- data/lib/active_merchant/railtie.rb.orig +19 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +23 -10
- data/lib/active_merchant.rb.orig +78 -0
- metadata +147 -63
- data/lib/active_merchant/common/connection.rb +0 -177
- data/lib/active_merchant/common/country.rb +0 -328
- data/lib/active_merchant/common/error.rb +0 -26
- data/lib/active_merchant/common/post_data.rb +0 -24
- data/lib/active_merchant/common/posts_data.rb +0 -63
- data/lib/active_merchant/common/requires_parameters.rb +0 -16
- data/lib/active_merchant/common/utils.rb +0 -22
- data/lib/active_merchant/common/validateable.rb +0 -81
- data/lib/active_merchant/common.rb +0 -14
- data/lib/certs/cacert.pem +0 -7815
@@ -0,0 +1,120 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Ipay88
|
7
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
8
|
+
include RequiresParameters
|
9
|
+
|
10
|
+
# Currencies supported
|
11
|
+
# MYR (Malaysian Ringgit - for all payment methods except China Union Pay and PayPal)
|
12
|
+
# USD (US Dollar - only for PayPal)
|
13
|
+
# CNY (Yuan Renminbi - only for China Union Pay)
|
14
|
+
SUPPORTED_CURRENCIES = %w[MYR USD CNY]
|
15
|
+
|
16
|
+
# Languages supported
|
17
|
+
# ISO-8859-1 (English)
|
18
|
+
# UTF-8 (Unicode)
|
19
|
+
# GB2312 (Chinese Simplified)
|
20
|
+
# GD18030 (Chinese Simplified)
|
21
|
+
# BIG5 (Chinese Traditional)
|
22
|
+
SUPPORTED_LANGS = %w[ISO-8859-1 UTF-8 GB2312 GD18030 BIG5]
|
23
|
+
|
24
|
+
# Payment methods supported
|
25
|
+
# 8 (Alliance Online Transfer)
|
26
|
+
# 10 (AmBank)
|
27
|
+
# 21 (China Union Pay)
|
28
|
+
# 20 (CIMB Click)
|
29
|
+
# 2 (Credit Card MYR)
|
30
|
+
# 16 (FPX)
|
31
|
+
# 15 (Hong Leong Bank Transfer)
|
32
|
+
# 6 (Maybank2u.com)
|
33
|
+
# 23 (MEPS Cash)
|
34
|
+
# 17 (Mobile Money)
|
35
|
+
# 33 (PayPal)
|
36
|
+
# 14 (RHB)
|
37
|
+
PAYMENT_METHODS = %w[8 10 21 20 2 16 15 6 23 17 33 14]
|
38
|
+
|
39
|
+
attr_reader :amount_in_cents
|
40
|
+
|
41
|
+
def initialize(order, account, options = {})
|
42
|
+
requires!(options, :amount, :currency)
|
43
|
+
@amount_in_cents = options[:amount]
|
44
|
+
super
|
45
|
+
add_field mappings[:signature], signature
|
46
|
+
end
|
47
|
+
|
48
|
+
def amount=(money)
|
49
|
+
cents = money.respond_to?(:cents) ? money.cents : money
|
50
|
+
if money.is_a?(String) or cents.to_i < 0
|
51
|
+
raise ArgumentError, "money amount must be either a Money object or a positive integer in cents."
|
52
|
+
end
|
53
|
+
add_field mappings[:amount], sprintf("%.2f", cents.to_f/100)
|
54
|
+
end
|
55
|
+
|
56
|
+
def currency(symbol)
|
57
|
+
raise ArgumentError, "unsupported currency" unless SUPPORTED_CURRENCIES.include?(symbol)
|
58
|
+
add_field mappings[:currency], symbol
|
59
|
+
end
|
60
|
+
|
61
|
+
def language(lang)
|
62
|
+
raise ArgumentError, "unsupported language" unless SUPPORTED_LANGS.include?(lang)
|
63
|
+
add_field mappings[:language], lang
|
64
|
+
end
|
65
|
+
|
66
|
+
def payment(pay_method)
|
67
|
+
raise ArgumentError, "unsupported payment method" unless PAYMENT_METHODS.include?(pay_method.to_s)
|
68
|
+
add_field mappings[:payment], pay_method
|
69
|
+
end
|
70
|
+
|
71
|
+
# Generate a Base64-encoded SHA1 given a string
|
72
|
+
def self.sign(str)
|
73
|
+
[Digest::SHA1.digest(str)].pack("m").chomp
|
74
|
+
end
|
75
|
+
|
76
|
+
def signature
|
77
|
+
self.class.sign(self.sig_components)
|
78
|
+
end
|
79
|
+
|
80
|
+
# MerchantCode (required)
|
81
|
+
mapping :account, "MerchantCode"
|
82
|
+
# Amount (required)
|
83
|
+
mapping :amount, "Amount"
|
84
|
+
# Currency (required)
|
85
|
+
mapping :currency, "Currency"
|
86
|
+
# RefNo (required)
|
87
|
+
mapping :order, "RefNo"
|
88
|
+
# ProdDesc (required)
|
89
|
+
mapping :description, "ProdDesc"
|
90
|
+
# UserName (required)
|
91
|
+
# UserEmail (required)
|
92
|
+
# UserContact (required)
|
93
|
+
mapping :customer, :name => "UserName",
|
94
|
+
:email => "UserEmail",
|
95
|
+
:phone => "UserContact"
|
96
|
+
# Remark
|
97
|
+
mapping :remark, "Remark"
|
98
|
+
# Lang
|
99
|
+
mapping :language, "Lang"
|
100
|
+
# PaymentId
|
101
|
+
mapping :payment, "PaymentId"
|
102
|
+
# ResponseURL
|
103
|
+
mapping :return_url, "ResponseURL"
|
104
|
+
# Signature
|
105
|
+
mapping :signature, "Signature"
|
106
|
+
|
107
|
+
protected
|
108
|
+
def sig_components #:nodoc:
|
109
|
+
components = [Ipay88.merchant_key]
|
110
|
+
components << fields[mappings[:account]]
|
111
|
+
components << fields[mappings[:order]]
|
112
|
+
components << amount_in_cents
|
113
|
+
components << fields[mappings[:currency]]
|
114
|
+
components.join
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Ipay88
|
7
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
8
|
+
include ActiveMerchant::PostsData
|
9
|
+
|
10
|
+
# Merchant Code assigned by iPay88
|
11
|
+
def account
|
12
|
+
params["MerchantCode"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# The payment method
|
16
|
+
def payment
|
17
|
+
params["PaymentId"].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
# Unique merchant transaction number
|
21
|
+
def order
|
22
|
+
params["RefNo"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# The payment with two decimals
|
26
|
+
def amount
|
27
|
+
params["Amount"]
|
28
|
+
end
|
29
|
+
|
30
|
+
# The currency. List of possible values:
|
31
|
+
# <tt>MYR</tt>::
|
32
|
+
# <tt>USD</tt>::
|
33
|
+
# <tt>CNY</tt>::
|
34
|
+
def currency
|
35
|
+
params["Currency"]
|
36
|
+
end
|
37
|
+
|
38
|
+
# Merchant remark
|
39
|
+
def remark
|
40
|
+
params["Remark"]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Transaction ID from iPay88
|
44
|
+
def transaction
|
45
|
+
params["TransId"]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Bank's approval code
|
49
|
+
def auth_code
|
50
|
+
params["AuthCode"]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Payment status. List of possible values:
|
54
|
+
# <tt>1</tt>:: Success
|
55
|
+
# <tt>0</tt>:: Fail
|
56
|
+
def status
|
57
|
+
params["Status"]
|
58
|
+
end
|
59
|
+
|
60
|
+
# The error description. List of possible values:
|
61
|
+
# <tt>Duplicate reference number</tt>::
|
62
|
+
# <tt>Invalid merchant</tt>::
|
63
|
+
# <tt>Invalid parameters</tt>::
|
64
|
+
# <tt>Overlimit per transaction</tt>::
|
65
|
+
# <tt>Payment not allowed</tt>::
|
66
|
+
# <tt>Permission not allow</tt>::
|
67
|
+
# <tt>Signature not match</tt>::
|
68
|
+
# <tt>Status not approved</tt>::
|
69
|
+
def error
|
70
|
+
params["ErrDesc"]
|
71
|
+
end
|
72
|
+
|
73
|
+
# The hash signature
|
74
|
+
def signature
|
75
|
+
params["Signature"]
|
76
|
+
end
|
77
|
+
|
78
|
+
# Convenience method to check if the request is secure by
|
79
|
+
# checking the incoming signature against our own generated
|
80
|
+
# signature
|
81
|
+
def secure?
|
82
|
+
self.generated_signature == self.signature
|
83
|
+
end
|
84
|
+
|
85
|
+
# Was the transaction successful?
|
86
|
+
def success?
|
87
|
+
self.secure? && self.requery == "00" && self.status == "1"
|
88
|
+
end
|
89
|
+
|
90
|
+
protected
|
91
|
+
def generated_signature #:nodoc:
|
92
|
+
Helper.sign(self.sig_components)
|
93
|
+
end
|
94
|
+
|
95
|
+
def sig_components #:nodoc:
|
96
|
+
components = [Ipay88.merchant_key]
|
97
|
+
[:account, :payment, :order, :amount_in_cents, :currency, :status].each do |i|
|
98
|
+
components << self.send(i)
|
99
|
+
end
|
100
|
+
components.join
|
101
|
+
end
|
102
|
+
|
103
|
+
def requery #:nodoc:
|
104
|
+
data = { "MerchantCode" => self.account, "RefNo" => self.order, "Amount" => self.amount }
|
105
|
+
params = parameterize(data)
|
106
|
+
ssl_post Ipay88.service_url, params, { "Content-Length" => params.size.to_s, "User-Agent" => "Active Merchant -- http://activemerchant.org" }
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
def parameterize(params) #:nodoc:
|
111
|
+
params.reject { |k, v| v.blank? }.keys.sort.collect { |key| "#{key}=#{CGI.escape(params[key].to_s)}" }.join("&")
|
112
|
+
end
|
113
|
+
|
114
|
+
def amount_in_cents #:nodoc:
|
115
|
+
@amount_in_cents ||= (self.amount || "").gsub(/[.,]/, "")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Ipay88
|
5
|
+
autoload :Return, "active_merchant/billing/integrations/ipay88/return.rb"
|
6
|
+
autoload :Helper, "active_merchant/billing/integrations/ipay88/helper.rb"
|
7
|
+
autoload :Notification, "active_merchant/billing/integrations/ipay88/notification.rb"
|
8
|
+
|
9
|
+
mattr_accessor :merch_key
|
10
|
+
|
11
|
+
# The merchant key provided to you by iPay88.
|
12
|
+
def self.merchant_key
|
13
|
+
self.merch_key
|
14
|
+
end
|
15
|
+
|
16
|
+
# Set the merchant key (in a Rails initializer, for example)
|
17
|
+
#
|
18
|
+
# ActiveMerchant::Billing::Integrations::Ipay88.merchant_key = "foo"
|
19
|
+
#
|
20
|
+
def self.merchant_key=(key)
|
21
|
+
self.merch_key = key
|
22
|
+
end
|
23
|
+
|
24
|
+
# The requery URL upon returning from iPay88
|
25
|
+
def self.service_url
|
26
|
+
"https://www.mobile88.com/epayment/enquiry.asp"
|
27
|
+
end
|
28
|
+
|
29
|
+
# The URL to POST your payment form to
|
30
|
+
def self.entry_url
|
31
|
+
"https://www.mobile88.com/epayment/entry.asp"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.return(query_string)
|
35
|
+
Return.new(query_string)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -68,7 +68,7 @@ module ActiveMerchant #:nodoc:
|
|
68
68
|
|
69
69
|
|
70
70
|
mattr_accessor :service_url
|
71
|
-
self.service_url = 'https://
|
71
|
+
self.service_url = 'https://secure.nochex.com'
|
72
72
|
|
73
73
|
mattr_accessor :notification_confirmation_url
|
74
74
|
self.notification_confirmation_url = 'https://www.nochex.com/nochex.dll/apc/apc'
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module PayflowLink
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
+
include PostsData
|
7
|
+
|
8
|
+
def initialize(order, account, options = {})
|
9
|
+
super
|
10
|
+
add_field('login', account)
|
11
|
+
add_field('echodata', 'True')
|
12
|
+
add_field('user2', self.test?)
|
13
|
+
add_field('invoice', order)
|
14
|
+
add_field('vendor', account)
|
15
|
+
add_field('user', options[:credential4] || account)
|
16
|
+
add_field('trxtype', options[:transaction_type] || 'S')
|
17
|
+
end
|
18
|
+
|
19
|
+
mapping :account, 'login'
|
20
|
+
mapping :credential2, 'pwd'
|
21
|
+
mapping :credential3, 'partner'
|
22
|
+
mapping :order, 'user1'
|
23
|
+
mapping :description, 'description'
|
24
|
+
|
25
|
+
mapping :amount, 'amt'
|
26
|
+
|
27
|
+
|
28
|
+
mapping :billing_address, :city => 'city',
|
29
|
+
:address => 'address',
|
30
|
+
:state => 'state',
|
31
|
+
:zip => 'zip',
|
32
|
+
:country => 'country',
|
33
|
+
:phone => 'phone',
|
34
|
+
:name => 'name'
|
35
|
+
|
36
|
+
mapping :customer, :name => 'name'
|
37
|
+
|
38
|
+
def customer(params = {})
|
39
|
+
add_field(mappings[:customer][:name], [params.delete(:first_name), params.delete(:last_name)].compact.join(' '))
|
40
|
+
end
|
41
|
+
|
42
|
+
def billing_address(params = {})
|
43
|
+
# Get the country code in the correct format
|
44
|
+
# Use what we were given if we can't find anything
|
45
|
+
country_code = lookup_country_code(params.delete(:country))
|
46
|
+
add_field(mappings[:billing_address][:country], country_code)
|
47
|
+
|
48
|
+
add_field(mappings[:billing_address][:address], [params.delete(:address1), params.delete(:address2)].compact.join(' '))
|
49
|
+
|
50
|
+
province_code = params.delete(:state)
|
51
|
+
add_field(mappings[:billing_address][:state], province_code.blank? ? 'N/A' : province_code.upcase)
|
52
|
+
|
53
|
+
# Everything else
|
54
|
+
params.each do |k, v|
|
55
|
+
field = mappings[:billing_address][k]
|
56
|
+
add_field(field, v) unless field.nil?
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def form_fields
|
61
|
+
token, token_id = request_secure_token
|
62
|
+
|
63
|
+
{"securetoken" => token, "securetokenid" => token_id, "mode" => test? ? "test" : "live"}
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def secure_token_id
|
69
|
+
@secure_token_id ||= Utils.generate_unique_id
|
70
|
+
end
|
71
|
+
|
72
|
+
def secure_token_url
|
73
|
+
test? ? "https://pilot-payflowpro.paypal.com" : "https://payflowpro.paypal.com"
|
74
|
+
end
|
75
|
+
|
76
|
+
def request_secure_token
|
77
|
+
@fields["securetokenid"] = secure_token_id
|
78
|
+
@fields["createsecuretoken"] = "Y"
|
79
|
+
|
80
|
+
fields = @fields.collect {|key, value| "#{key}[#{value.length}]=#{value}" }.join("&")
|
81
|
+
|
82
|
+
response = ssl_post(secure_token_url, fields)
|
83
|
+
|
84
|
+
parse_response(response)
|
85
|
+
end
|
86
|
+
|
87
|
+
def parse_response(response)
|
88
|
+
response = response.split("&").inject({}) do |hash, param|
|
89
|
+
key, value = param.split("=")
|
90
|
+
hash[key] = value
|
91
|
+
hash
|
92
|
+
end
|
93
|
+
|
94
|
+
[response['SECURETOKEN'], response['SECURETOKENID']] if response['RESPMSG'] && response['RESPMSG'].downcase == "approved"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module PayflowLink
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
+
|
9
|
+
# Was the transaction complete?
|
10
|
+
def complete?
|
11
|
+
status == "Completed"
|
12
|
+
end
|
13
|
+
|
14
|
+
# When was this payment received by the client.
|
15
|
+
# sometimes it can happen that we get the notification much later.
|
16
|
+
# One possible scenario is that our web application was down. In this case paypal tries several
|
17
|
+
# times an hour to inform us about the notification
|
18
|
+
def received_at
|
19
|
+
DateTime.parse(params['TRANSTIME']) if params['TRANSTIME']
|
20
|
+
rescue ArgumentError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def status
|
25
|
+
params['RESPMSG']
|
26
|
+
end
|
27
|
+
|
28
|
+
# Id of this transaction (paypal number)
|
29
|
+
def transaction_id
|
30
|
+
params['PNREF']
|
31
|
+
end
|
32
|
+
|
33
|
+
# What type of transaction are we dealing with?
|
34
|
+
def type
|
35
|
+
params['TYPE']
|
36
|
+
end
|
37
|
+
|
38
|
+
# the money amount we received in X.2 decimal.
|
39
|
+
def gross
|
40
|
+
params['AMT']
|
41
|
+
end
|
42
|
+
|
43
|
+
# What currency have we been dealing with
|
44
|
+
def currency
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def status
|
49
|
+
params['RESULT'] == '0' ? 'Completed' : 'Failed'
|
50
|
+
end
|
51
|
+
|
52
|
+
# This is the item number which we submitted to paypal
|
53
|
+
def item_id
|
54
|
+
params['USER1']
|
55
|
+
end
|
56
|
+
|
57
|
+
# This is the invoice which you passed to paypal
|
58
|
+
def invoice
|
59
|
+
params['INVNUM']
|
60
|
+
end
|
61
|
+
|
62
|
+
# Was this a test transaction?
|
63
|
+
def test?
|
64
|
+
params['USER2'] == 'true'
|
65
|
+
end
|
66
|
+
|
67
|
+
def account
|
68
|
+
params["ACCT"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def acknowledge
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module PayflowLink
|
5
|
+
autoload :Helper, 'active_merchant/billing/integrations/payflow_link/helper.rb'
|
6
|
+
autoload :Notification, 'active_merchant/billing/integrations/payflow_link/notification.rb'
|
7
|
+
|
8
|
+
mattr_accessor :service_url
|
9
|
+
self.service_url = 'https://payflowlink.paypal.com'
|
10
|
+
|
11
|
+
def self.notification(post, options = {})
|
12
|
+
Notification.new(post)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.return(query_string, options = {})
|
16
|
+
ActiveMerchant::Billing::Integrations::Return.new(query_string)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,11 +4,11 @@ module ActiveMerchant #:nodoc:
|
|
4
4
|
module SagePayForm
|
5
5
|
module Encryption
|
6
6
|
def sage_encrypt(plaintext, key)
|
7
|
-
|
7
|
+
Base64.strict_encode64(sage_encrypt_xor(plaintext, key))
|
8
8
|
end
|
9
9
|
|
10
10
|
def sage_decrypt(ciphertext, key)
|
11
|
-
sage_encrypt_xor(
|
11
|
+
sage_encrypt_xor(Base64.decode64(ciphertext), key)
|
12
12
|
end
|
13
13
|
|
14
14
|
def sage_encrypt_salt(min, max)
|
@@ -21,8 +21,8 @@ module ActiveMerchant #:nodoc:
|
|
21
21
|
def sage_encrypt_xor(data, key)
|
22
22
|
raise 'No key provided' if key.blank?
|
23
23
|
|
24
|
-
key *= (data.
|
25
|
-
key = key[0, data.
|
24
|
+
key *= (data.bytesize.to_f / key.bytesize.to_f).ceil
|
25
|
+
key = key[0, data.bytesize]
|
26
26
|
|
27
27
|
data.bytes.zip(key.bytes).map { |b1, b2| (b1 ^ b2).chr }.join
|
28
28
|
end
|
@@ -41,17 +41,33 @@ module ActiveMerchant #:nodoc:
|
|
41
41
|
mapping :return_url, 'SuccessURL'
|
42
42
|
mapping :description, 'Description'
|
43
43
|
|
44
|
+
def shipping_address(params = {})
|
45
|
+
@shipping_address_set = true unless params.empty?
|
46
|
+
|
47
|
+
params.each do |k, v|
|
48
|
+
field = mappings[:shipping_address][k]
|
49
|
+
add_field(field, v) unless field.nil?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def map_billing_address_to_shipping_address
|
54
|
+
%w(City Address1 Address2 State PostCode Country).each do |field|
|
55
|
+
fields["Delivery#{field}"] = fields["Billing#{field}"]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
44
59
|
def form_fields
|
60
|
+
map_billing_address_to_shipping_address unless @shipping_address_set
|
61
|
+
|
45
62
|
fields['DeliveryFirstnames'] ||= fields['BillingFirstnames']
|
46
63
|
fields['DeliverySurname'] ||= fields['BillingSurname']
|
47
|
-
|
64
|
+
|
48
65
|
fields['FailureURL'] ||= fields['SuccessURL']
|
49
66
|
|
50
67
|
crypt_skip = ['Vendor', 'EncryptKey', 'SendEmail']
|
51
68
|
crypt_skip << 'BillingState' unless fields['BillingCountry'] == 'US'
|
52
69
|
crypt_skip << 'DeliveryState' unless fields['DeliveryCountry'] == 'US'
|
53
70
|
crypt_skip << 'CustomerEMail' unless fields['SendEmail']
|
54
|
-
|
55
71
|
key = fields['EncryptKey']
|
56
72
|
@crypt ||= create_crypt_field(fields.except(*crypt_skip), key)
|
57
73
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module ActiveMerchant #:nodoc:
|
3
2
|
module Billing #:nodoc:
|
4
3
|
module Integrations #:nodoc:
|
@@ -8,7 +7,7 @@ module ActiveMerchant #:nodoc:
|
|
8
7
|
autoload 'Notification', File.dirname(__FILE__) + '/two_checkout/notification'
|
9
8
|
|
10
9
|
mattr_accessor :service_url
|
11
|
-
self.service_url = 'https://www.2checkout.com/
|
10
|
+
self.service_url = 'https://www.2checkout.com/checkout/purchase'
|
12
11
|
|
13
12
|
def self.notification(post, options = {})
|
14
13
|
Notification.new(post)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ActiveMerchant
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
initializer 'activemerchant.initialize' do
|
4
|
+
ActiveSupport.on_load(:action_view) do
|
5
|
+
include ActiveMerchant::Billing::Integrations::ActionViewHelper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
9
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
<<<<<<< HEAD
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
initializer 'activemerchant.initialize' do
|
5
|
+
ActiveSupport.on_load(:action_view) do
|
6
|
+
include ActiveMerchant::Billing::Integrations::ActionViewHelper
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
=======
|
11
|
+
class Railtie < Rails::Railtie
|
12
|
+
initializer 'activemerchant.initialize' do
|
13
|
+
ActiveSupport.on_load(:action_view) do
|
14
|
+
include ActiveMerchant::Billing::Integrations::ActionViewHelper
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
>>>>>>> Use Railtie to include view helpers in Rails 3
|
19
|
+
end
|
data/lib/active_merchant.rb
CHANGED
@@ -20,33 +20,46 @@
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
|
-
|
24
|
-
$:.unshift File.dirname(__FILE__)
|
25
23
|
|
26
24
|
require 'active_support'
|
27
25
|
require 'active_support/core_ext/string/inflections'
|
28
26
|
require 'active_support/core_ext/hash/indifferent_access'
|
29
27
|
require 'active_support/core_ext/hash/conversions'
|
30
|
-
require 'active_support/core_ext/
|
28
|
+
require 'active_support/core_ext/object/conversions'
|
29
|
+
require 'active_support/core_ext/class/attribute'
|
31
30
|
require 'active_support/core_ext/class/attribute_accessors'
|
32
31
|
require 'active_support/core_ext/class/delegating_attributes'
|
33
32
|
require 'active_support/core_ext/module/attribute_accessors'
|
34
|
-
require 'active_support/core_ext/kernel/requires'
|
35
|
-
require 'active_support/base64'
|
36
|
-
require 'active_support/secure_random'
|
37
33
|
|
34
|
+
begin
|
35
|
+
require 'active_support/base64'
|
36
|
+
|
37
|
+
unless defined?(Base64)
|
38
|
+
Base64 = ActiveSupport::Base64
|
39
|
+
end
|
40
|
+
|
41
|
+
unless Base64.respond_to?(:strict_encode64)
|
42
|
+
def Base64.strict_encode64(v)
|
43
|
+
ActiveSupport::Base64.encode64s(v)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
require 'base64'
|
48
|
+
end
|
49
|
+
|
50
|
+
require 'securerandom'
|
38
51
|
require 'builder'
|
39
52
|
require 'cgi'
|
40
53
|
require 'rexml/document'
|
41
54
|
|
42
|
-
require '
|
55
|
+
require 'active_utils'
|
43
56
|
require 'active_merchant/billing'
|
44
57
|
require 'active_merchant/version'
|
45
58
|
|
46
|
-
require 'active_merchant/railtie' if defined?(::Rails)
|
47
|
-
|
48
59
|
module ActiveMerchant #:nodoc:
|
49
|
-
module Billing #:nodoc:
|
60
|
+
module Billing #:nodoc:
|
50
61
|
autoload :Integrations, 'active_merchant/billing/integrations'
|
51
62
|
end
|
52
63
|
end
|
64
|
+
|
65
|
+
require 'active_merchant/railtie' if defined?(Rails) && ActiveSupport::VERSION::MAJOR >= 3
|