activemerchant 1.42.6 → 1.42.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG +12 -0
- data/CONTRIBUTORS +8 -0
- data/README.md +39 -35
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1 -1
- data/lib/active_merchant/billing/gateways/cecabank.rb +5 -1
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +4 -1
- data/lib/active_merchant/billing/gateways/sage_pay.rb +4 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +12 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +189 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +4 -0
- data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +2 -0
- data/lib/active_merchant/billing/integrations/paydollar/notification.rb +6 -2
- data/lib/active_merchant/version.rb +1 -1
- metadata +4 -5
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/integrations/alipay.rb +0 -18
- data/lib/active_merchant/billing/integrations/alipay/helper.rb +0 -34
- data/lib/active_merchant/billing/integrations/alipay/notification.rb +0 -101
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDRjYjY2NmNjZWUyNDMwMjdhOTZjOGMyMzJjOTUxYWMxNjFlNjVkNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTFjN2I2ZjQ3ZTdkZTIwZWY0ZGY0OTFhNzhjOTkwYWIxNDFlYTI3OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTZiMWRlNzE0OWZmOWQwZjk2NjNlZmJjYmYxOGNhMWIzMjk4ZDAxMDg5MjZk
|
10
|
+
Y2I3ZDVhYjkzZDA4NTAyYjk0ZDU3ZjZkODAyMmEzOWVjMjg1OTJlNmRiYzg4
|
11
|
+
YTQ5YTc4ZGRjMmVmZGU5N2ZlMWI0MjdiNmRjZjUyZmVlN2NhMzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTY3ZGViYTg2MTIxOTFhZmFhMzE5Y2JiZmYxNzZlMzMzMDJhNDYwNTA1OTE0
|
14
|
+
ZDEzNWQ1OGYyZjJkOTM5ODE0OGViNGFiNmFmNjg3NDczMmQyOTI1OWYyMDZi
|
15
|
+
ZTZjYzVkZWM5ZTFhNzhkOGU4MTc3YWY1NGI3OWMyM2Q0OGIzYTA=
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
= ActiveMerchant CHANGELOG
|
2
2
|
|
3
|
+
== Version 1.42.7 (March 18, 2014)
|
4
|
+
|
5
|
+
* SagePay: Add support for ReferrerID [markabe]
|
6
|
+
* Cecabank: Fix expiration date formatting [duff]
|
7
|
+
* Add WePay gateway [faizalzakaria]
|
8
|
+
* SmartPs: Add ECI option to SmartPs [odorcicd]
|
9
|
+
* Rescue and re-raise ActionViewHelperError when offsite helpers raise an error [odorcicd]
|
10
|
+
* Add FirstGiving gateway [faizalzakaria]
|
11
|
+
* FirstGiving: Fix refunds [ntalbott]
|
12
|
+
* Samurai: Handle server errors [ntalbott]
|
13
|
+
* WePay: Fix refund [duff]
|
14
|
+
|
3
15
|
== Version 1.42.6 (February 24, 2014)
|
4
16
|
|
5
17
|
* Litle: Truncate order_id [duff]
|
data/CONTRIBUTORS
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[](https://travis-ci.org/Shopify/active_merchant)
|
3
3
|
[](https://codeclimate.com/github/Shopify/active_merchant)
|
4
4
|
|
5
|
-
Active Merchant is an extraction from the
|
5
|
+
Active Merchant is an extraction from the ecommerce system [Shopify](http://www.shopify.com).
|
6
6
|
Shopify's requirements for a simple and unified API to access dozens of different payment
|
7
7
|
gateways with very different internal APIs was the chief principle in designing the library.
|
8
8
|
|
@@ -40,39 +40,41 @@ Or, if you're using Bundler, just add the following to your Gemfile:
|
|
40
40
|
This simple example demonstrates how a purchase can be made using a person's
|
41
41
|
credit card details.
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
43
|
+
```ruby
|
44
|
+
require 'rubygems'
|
45
|
+
require 'active_merchant'
|
46
|
+
|
47
|
+
# Use the TrustCommerce test servers
|
48
|
+
ActiveMerchant::Billing::Base.mode = :test
|
49
|
+
|
50
|
+
gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
|
51
|
+
:login => 'TestMerchant',
|
52
|
+
:password => 'password')
|
53
|
+
|
54
|
+
# ActiveMerchant accepts all amounts as Integer values in cents
|
55
|
+
amount = 1000 # $10.00
|
56
|
+
|
57
|
+
# The card verification value is also known as CVV2, CVC2, or CID
|
58
|
+
credit_card = ActiveMerchant::Billing::CreditCard.new(
|
59
|
+
:first_name => 'Bob',
|
60
|
+
:last_name => 'Bobsen',
|
61
|
+
:number => '4242424242424242',
|
62
|
+
:month => '8',
|
63
|
+
:year => Time.now.year+1,
|
64
|
+
:verification_value => '000')
|
65
|
+
|
66
|
+
# Validating the card automatically detects the card type
|
67
|
+
if credit_card.valid?
|
68
|
+
# Capture $10 from the credit card
|
69
|
+
response = gateway.purchase(amount, credit_card)
|
70
|
+
|
71
|
+
if response.success?
|
72
|
+
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
|
73
|
+
else
|
74
|
+
raise StandardError, response.message
|
75
|
+
end
|
76
|
+
end
|
77
|
+
```
|
76
78
|
|
77
79
|
For more in-depth documentation and tutorials, see [GettingStarted.md](GettingStarted.md) and the
|
78
80
|
[API documentation](http://rubydoc.info/github/Shopify/active_merchant/master/file/README.md).
|
@@ -83,7 +85,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
|
|
83
85
|
|
84
86
|
* [App55](https://www.app55.com/) - AU, BR, CA, CH, CL, CN, CO, CZ, DK, EU, GB, HK, HU, ID, IS, JP, KE, KR, MX, MY, NO, NZ, PH, PL, TH, TW, US, VN, ZA
|
85
87
|
* [Authorize.Net CIM](http://www.authorize.net/) - US
|
86
|
-
* [Authorize.Net](http://www.authorize.net/) -
|
88
|
+
* [Authorize.Net](http://www.authorize.net/) - AD, AT, AU, BE, BG, CA, CH, CY, CZ, DE, DK, ES, FI, FR, GB, GB, GI, GR, HU, IE, IT, LI, LU, MC, MT, NL, NO, PL, PT, RO, SE, SI, SK, SM, TR, US, VA
|
87
89
|
* [Balanced](https://www.balancedpayments.com/) - US
|
88
90
|
* [Banwire](http://www.banwire.com/) - MX
|
89
91
|
* [Barclays ePDQ Extra Plus](http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/) - GB
|
@@ -111,6 +113,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
|
|
111
113
|
* [Finansbank WebPOS](https://www.fbwebpos.com/) - US, TR
|
112
114
|
* [First Pay](http://www.first-pay.com) - US
|
113
115
|
* [FirstData Global Gateway e4](http://www.firstdata.com) - CA, US
|
116
|
+
* [FirstGiving](http://www.firstgiving.com/) - US
|
114
117
|
* [Garanti Sanal POS](https://sanalposweb.garanti.com.tr) - US, TR
|
115
118
|
* [HDFC](http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i) - IN
|
116
119
|
* [IATSPayments](http://www.iatspayments.com/) - US, CA, GB
|
@@ -191,6 +194,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
|
|
191
194
|
* [ViaKLIX](http://viaklix.com) - US
|
192
195
|
* [Vindicia](http://www.vindicia.com/) - US, CA, GB, AU, MX, BR, DE, KR, CN, HK
|
193
196
|
* [WebPay](https://webpay.jp/) - JP
|
197
|
+
* [WePay](https://www.wepay.com/) - US
|
194
198
|
* [Wirecard](http://www.wirecard.com) - AD, CY, GI, IM, MT, RO, CH, AT, DK, GR, IT, MC, SM, TR, BE, EE, HU, LV, NL, SK, GB, BG, FI, IS, LI, NO, SI, VA, FR, IL, LT, PL, ES, CZ, DE, IE, LU, PT, SE
|
195
199
|
* [WorldPay](http://www.worldpay.com/) - HK, US, GB, AU, AD, BE, CH, CY, CZ, DE, DK, ES, FI, FR, GI, GR, HU, IE, IL, IT, LI, LU, MC, MT, NL, NO, NZ, PL, PT, SE, SG, SI, SM, TR, UM, VA
|
196
200
|
|
@@ -43,7 +43,7 @@ module ActiveMerchant #:nodoc:
|
|
43
43
|
|
44
44
|
self.default_currency = 'USD'
|
45
45
|
|
46
|
-
self.supported_countries =
|
46
|
+
self.supported_countries = %w(AD AT AU BE BG CA CH CY CZ DE DK ES FI FR GB GB GI GR HU IE IT LI LU MC MT NL NO PL PT RO SE SI SK SM TR US VA)
|
47
47
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
|
48
48
|
self.homepage_url = 'http://www.authorize.net/'
|
49
49
|
self.display_name = 'Authorize.Net'
|
@@ -98,11 +98,15 @@ module ActiveMerchant #:nodoc:
|
|
98
98
|
|
99
99
|
def add_creditcard(post, creditcard)
|
100
100
|
post['PAN'] = creditcard.number
|
101
|
-
post['Caducidad'] =
|
101
|
+
post['Caducidad'] = expdate(creditcard)
|
102
102
|
post['CVV2'] = creditcard.verification_value
|
103
103
|
post['Pago_elegido'] = CECA_MODE
|
104
104
|
end
|
105
105
|
|
106
|
+
def expdate(creditcard)
|
107
|
+
"#{format(creditcard.year, :four_digits)}#{format(creditcard.month, :two_digits)}"
|
108
|
+
end
|
109
|
+
|
106
110
|
def parse(body)
|
107
111
|
response = {}
|
108
112
|
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class FirstGivingGateway < Gateway
|
6
|
+
self.test_url = 'http://usapisandbox.fgdev.net'
|
7
|
+
self.live_url = 'https://api.firstgiving.com'
|
8
|
+
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
11
|
+
self.homepage_url = 'http://www.firstgiving.com/'
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.display_name = 'FirstGiving'
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :application_key, :security_token, :charity_id)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def purchase(money, creditcard, options = {})
|
21
|
+
post = {}
|
22
|
+
add_invoice(post, options)
|
23
|
+
add_creditcard(post, creditcard)
|
24
|
+
add_address(post, options)
|
25
|
+
add_customer_data(post, options)
|
26
|
+
add_donation_data(post, money, options)
|
27
|
+
commit('/donation/creditcard', post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def refund(money, identifier, options = {})
|
31
|
+
get = {}
|
32
|
+
get[:transactionId] = identifier
|
33
|
+
get[:tranType] = 'REFUNDREQUEST'
|
34
|
+
commit("/transaction/refundrequest?" + encode(get))
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def add_donation_data(post, money, options)
|
40
|
+
post[:amount] = amount(money)
|
41
|
+
post[:charityId] = @options[:charity_id]
|
42
|
+
post[:description] = (options[:description] || "Purchase")
|
43
|
+
post[:currencyCode] = (options[:currency] || currency(money))
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_customer_data(post, options)
|
47
|
+
post[:billToEmail] = (options[:email] || "activemerchant@example.com")
|
48
|
+
post[:remoteAddr] = (options[:ip] || "127.0.0.1")
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_address(post, options)
|
52
|
+
if(billing_address = (options[:billing_address] || options[:address]))
|
53
|
+
post[:billToAddressLine1] = billing_address[:address1]
|
54
|
+
post[:billToCity] = billing_address[:city]
|
55
|
+
post[:billToState] = billing_address[:state]
|
56
|
+
post[:billToZip] = billing_address[:zip]
|
57
|
+
post[:billToCountry] = billing_address[:country]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_invoice(post, options)
|
62
|
+
post[:orderId] = options[:order_id]
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_creditcard(post, creditcard)
|
66
|
+
post[:billToFirstName] = creditcard.first_name
|
67
|
+
post[:billToLastName] = creditcard.last_name
|
68
|
+
post[:ccNumber] = creditcard.number
|
69
|
+
post[:ccType] = creditcard_brand(creditcard.brand)
|
70
|
+
post[:ccExpDateMonth] = creditcard.month
|
71
|
+
post[:ccExpDateYear] = creditcard.year
|
72
|
+
post[:ccCardValidationNum] = creditcard.verification_value
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse(body)
|
76
|
+
response = {}
|
77
|
+
|
78
|
+
xml = Nokogiri::XML(body)
|
79
|
+
element = xml.xpath("//firstGivingDonationApi/firstGivingResponse").first
|
80
|
+
|
81
|
+
element.attributes.each do |name, attribute|
|
82
|
+
response[name] = attribute.content
|
83
|
+
end
|
84
|
+
element.children.each do |child|
|
85
|
+
next if child.text?
|
86
|
+
response[child.name] = child.text
|
87
|
+
end
|
88
|
+
|
89
|
+
response
|
90
|
+
end
|
91
|
+
|
92
|
+
def commit(action, post=nil)
|
93
|
+
url = (test? ? self.test_url : self.live_url) + action
|
94
|
+
|
95
|
+
begin
|
96
|
+
if post
|
97
|
+
response = parse(ssl_post(url, post_data(post), headers))
|
98
|
+
else
|
99
|
+
response = parse(ssl_get(url, headers))
|
100
|
+
end
|
101
|
+
rescue ResponseError => e
|
102
|
+
response = parse(e.response.body)
|
103
|
+
end
|
104
|
+
|
105
|
+
Response.new(
|
106
|
+
(response["acknowledgement"] == "Success"),
|
107
|
+
(response["friendlyErrorMessage"] || response["verboseErrorMessage"] || response["acknowledgement"]),
|
108
|
+
response,
|
109
|
+
authorization: response["transactionId"],
|
110
|
+
test: test?,
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
def post_data(post)
|
115
|
+
post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
116
|
+
end
|
117
|
+
|
118
|
+
def encode(hash)
|
119
|
+
hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
|
120
|
+
end
|
121
|
+
|
122
|
+
def creditcard_brand(brand)
|
123
|
+
case brand
|
124
|
+
when "visa" then "VI"
|
125
|
+
when "master" then "MC"
|
126
|
+
when "discover" then "DI"
|
127
|
+
when "american_express" then "AX"
|
128
|
+
else
|
129
|
+
raise "Unhandled credit card brand #{brand}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def headers
|
134
|
+
{
|
135
|
+
"User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
136
|
+
"JG_APPLICATIONKEY" => "#{@options[:application_key]}",
|
137
|
+
"JG_SECURITYTOKEN" => "#{@options[:security_token]}"
|
138
|
+
}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
@@ -177,6 +177,8 @@ module ActiveMerchant #:nodoc:
|
|
177
177
|
USE_ORDER_ID = 'O' # Use OrderID field
|
178
178
|
USE_COMMENTS = 'D' # Use Comments field
|
179
179
|
|
180
|
+
SENSITIVE_FIELDS = [:account_num]
|
181
|
+
|
180
182
|
def initialize(options = {})
|
181
183
|
requires!(options, :merchant_id)
|
182
184
|
requires!(options, :login, :password) unless options[:ip_authentication]
|
@@ -431,7 +433,8 @@ module ActiveMerchant #:nodoc:
|
|
431
433
|
recurring_parse_element(response, node)
|
432
434
|
end
|
433
435
|
end
|
434
|
-
|
436
|
+
|
437
|
+
response.delete_if { |k,_| SENSITIVE_FIELDS.include?(k) }
|
435
438
|
end
|
436
439
|
|
437
440
|
def recurring_parse_element(response, node)
|
@@ -293,6 +293,10 @@ module ActiveMerchant #:nodoc:
|
|
293
293
|
:VPSProtocol => "2.23"
|
294
294
|
)
|
295
295
|
|
296
|
+
if(application_id && (application_id != Gateway.application_id))
|
297
|
+
parameters.update(:ReferrerID => application_id)
|
298
|
+
end
|
299
|
+
|
296
300
|
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
297
301
|
end
|
298
302
|
|
@@ -32,6 +32,8 @@ module ActiveMerchant #:nodoc:
|
|
32
32
|
|
33
33
|
authorize = Samurai::Processor.authorize(token, amount(money), processor_options(options))
|
34
34
|
handle_result(authorize)
|
35
|
+
rescue ActiveResource::ServerError => e
|
36
|
+
Response.new(false, e.message, {}, test: test?)
|
35
37
|
end
|
36
38
|
|
37
39
|
def purchase(money, credit_card_or_vault_id, options = {})
|
@@ -40,21 +42,29 @@ module ActiveMerchant #:nodoc:
|
|
40
42
|
|
41
43
|
purchase = Samurai::Processor.purchase(token, amount(money), processor_options(options))
|
42
44
|
handle_result(purchase)
|
45
|
+
rescue ActiveResource::ServerError => e
|
46
|
+
Response.new(false, e.message, {}, test: test?)
|
43
47
|
end
|
44
48
|
|
45
49
|
def capture(money, authorization_id, options = {})
|
46
50
|
transaction = Samurai::Transaction.find(authorization_id)
|
47
51
|
handle_result(transaction.capture(amount(money)))
|
52
|
+
rescue ActiveResource::ServerError => e
|
53
|
+
Response.new(false, e.message, {}, test: test?)
|
48
54
|
end
|
49
55
|
|
50
56
|
def refund(money, transaction_id, options = {})
|
51
57
|
transaction = Samurai::Transaction.find(transaction_id)
|
52
58
|
handle_result(transaction.credit(amount(money)))
|
59
|
+
rescue ActiveResource::ServerError => e
|
60
|
+
Response.new(false, e.message, {}, test: test?)
|
53
61
|
end
|
54
62
|
|
55
63
|
def void(transaction_id, options = {})
|
56
64
|
transaction = Samurai::Transaction.find(transaction_id)
|
57
65
|
handle_result(transaction.void)
|
66
|
+
rescue ActiveResource::ServerError => e
|
67
|
+
Response.new(false, e.message, {}, test: test?)
|
58
68
|
end
|
59
69
|
|
60
70
|
def store(creditcard, options = {})
|
@@ -78,6 +88,8 @@ module ActiveMerchant #:nodoc:
|
|
78
88
|
Response.new(result.is_sensitive_data_valid,
|
79
89
|
message_from_result(result),
|
80
90
|
{ :payment_method_token => result.is_sensitive_data_valid && result.payment_method_token })
|
91
|
+
rescue ActiveResource::ServerError => e
|
92
|
+
Response.new(false, e.message, {}, test: test?)
|
81
93
|
end
|
82
94
|
|
83
95
|
private
|
@@ -43,6 +43,7 @@ module ActiveMerchant #:nodoc:
|
|
43
43
|
add_currency(post, money, options)
|
44
44
|
add_taxes(post, options)
|
45
45
|
add_processor(post, options)
|
46
|
+
add_eci(post, options)
|
46
47
|
commit('sale', money, post)
|
47
48
|
end
|
48
49
|
|
@@ -207,6 +208,10 @@ module ActiveMerchant #:nodoc:
|
|
207
208
|
post[:transactionid] = auth
|
208
209
|
end
|
209
210
|
|
211
|
+
def add_eci(post, options)
|
212
|
+
post[:billing_method] = options[:eci] if options[:eci]
|
213
|
+
end
|
214
|
+
|
210
215
|
def parse(body)
|
211
216
|
results = {}
|
212
217
|
body.split(/&/).each do |pair|
|
@@ -0,0 +1,189 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class WepayGateway < Gateway
|
4
|
+
self.test_url = 'https://stage.wepayapi.com/v2'
|
5
|
+
self.live_url = 'https://wepayapi.com/v2'
|
6
|
+
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
9
|
+
self.homepage_url = 'https://www.wepay.com/'
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.display_name = 'WePay'
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :client_id, :account_id, :access_token)
|
15
|
+
super(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def purchase(money, payment_method, options = {})
|
19
|
+
post = {}
|
20
|
+
if payment_method.is_a?(String)
|
21
|
+
purchase_with_token(post, money, payment_method, options)
|
22
|
+
else
|
23
|
+
MultiResponse.run do |r|
|
24
|
+
r.process { store(payment_method, options) }
|
25
|
+
r.process { purchase_with_token(post, money, split_authorization(r.authorization).first, options) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def authorize(money, payment_method, options = {})
|
31
|
+
post = {auto_capture: 0}
|
32
|
+
if payment_method.is_a?(String)
|
33
|
+
purchase_with_token(post, money, payment_method, options)
|
34
|
+
else
|
35
|
+
MultiResponse.run do |r|
|
36
|
+
r.process { store(payment_method, options) }
|
37
|
+
r.process { purchase_with_token(post, money, split_authorization(r.authorization).first, options) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def capture(money, identifier, options = {})
|
43
|
+
post = {}
|
44
|
+
post[:checkout_id] = split_authorization(identifier).first
|
45
|
+
commit('/checkout/capture', post)
|
46
|
+
end
|
47
|
+
|
48
|
+
def void(identifier, options = {})
|
49
|
+
post = {}
|
50
|
+
post[:checkout_id] = split_authorization(identifier).first
|
51
|
+
post[:cancel_reason] = (options[:description] || "Void")
|
52
|
+
commit('/checkout/cancel', post)
|
53
|
+
end
|
54
|
+
|
55
|
+
def refund(money, identifier, options = {})
|
56
|
+
checkout_id, original_amount = split_authorization(identifier)
|
57
|
+
|
58
|
+
post = {}
|
59
|
+
post[:checkout_id] = checkout_id
|
60
|
+
if(money && (original_amount != amount(money)))
|
61
|
+
post[:amount] = amount(money)
|
62
|
+
end
|
63
|
+
post[:refund_reason] = (options[:description] || "Refund")
|
64
|
+
post[:app_fee] = options[:application_fee] if options[:application_fee]
|
65
|
+
post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message]
|
66
|
+
post[:payee_email_message] = options[:payee_email_message] if options[:payee_email_message]
|
67
|
+
commit("/checkout/refund", post)
|
68
|
+
end
|
69
|
+
|
70
|
+
def store(creditcard, options = {})
|
71
|
+
requires!(options, :email)
|
72
|
+
|
73
|
+
post = {}
|
74
|
+
post[:client_id] = @options[:client_id]
|
75
|
+
post[:user_name] = "#{creditcard.first_name} #{creditcard.last_name}"
|
76
|
+
post[:email] = options[:email]
|
77
|
+
post[:cc_number] = creditcard.number
|
78
|
+
post[:cvv] = creditcard.verification_value
|
79
|
+
post[:expiration_month] = creditcard.month
|
80
|
+
post[:expiration_year] = creditcard.year
|
81
|
+
post[:original_ip] = options[:ip] if options[:ip]
|
82
|
+
post[:original_device] = options[:device_fingerprint] if options[:device_fingerprint]
|
83
|
+
if(billing_address = (options[:billing_address] || options[:address]))
|
84
|
+
post[:address] = {
|
85
|
+
"address1" => billing_address[:address1],
|
86
|
+
"city" => billing_address[:city],
|
87
|
+
"state" => billing_address[:state],
|
88
|
+
"country" => billing_address[:country]
|
89
|
+
}
|
90
|
+
if(post[:country] == "US")
|
91
|
+
post[:address]["zip"] = billing_address[:zip]
|
92
|
+
else
|
93
|
+
post[:address]["postcode"] = billing_address[:zip]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
commit('/credit_card/create', post)
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def purchase_with_token(post, money, token, options)
|
102
|
+
add_token(post, token)
|
103
|
+
add_product_data(post, money, options)
|
104
|
+
commit('/checkout/create', post)
|
105
|
+
end
|
106
|
+
|
107
|
+
def add_product_data(post, money, options)
|
108
|
+
post[:account_id] = @options[:account_id]
|
109
|
+
post[:amount] = amount(money)
|
110
|
+
post[:short_description] = (options[:description] || "Purchase")
|
111
|
+
post[:type] = (options[:type] || "GOODS")
|
112
|
+
post[:currency] = (options[:currency] || currency(money))
|
113
|
+
post[:long_description] = options[:long_description] if options[:long_description]
|
114
|
+
post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message]
|
115
|
+
post[:payee_email_message] = options[:payee_email_message] if options[:payee_email_message]
|
116
|
+
post[:reference_id] = options[:order_id] if options[:order_id]
|
117
|
+
post[:app_fee] = options[:application_fee] if options[:application_fee]
|
118
|
+
post[:fee_payer] = options[:fee_payer] if options[:fee_payer]
|
119
|
+
post[:redirect_uri] = options[:redirect_uri] if options[:redirect_uri]
|
120
|
+
post[:callback_uri] = options[:callback_uri] if options[:callback_uri]
|
121
|
+
post[:fallback_uri] = options[:fallback_uri] if options[:fallback_uri]
|
122
|
+
post[:require_shipping] = options[:require_shipping] if options[:require_shipping]
|
123
|
+
post[:shipping_fee] = options[:shipping_fee] if options[:shipping_fee]
|
124
|
+
post[:charge_tax] = options[:charge_tax] if options[:charge_tax]
|
125
|
+
post[:mode] = options[:mode] if options[:mode]
|
126
|
+
post[:preapproval_id] = options[:preapproval_id] if options[:preapproval_id]
|
127
|
+
post[:prefill_info] = options[:prefill_info] if options[:prefill_info]
|
128
|
+
post[:funding_sources] = options[:funding_sources] if options[:funding_sources]
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_token(post, token)
|
132
|
+
post[:payment_method_id] = token
|
133
|
+
post[:payment_method_type] = "credit_card"
|
134
|
+
end
|
135
|
+
|
136
|
+
def parse(response)
|
137
|
+
JSON.parse(response)
|
138
|
+
end
|
139
|
+
|
140
|
+
def commit(action, params, options={})
|
141
|
+
begin
|
142
|
+
response = parse(ssl_post(
|
143
|
+
((test? ? test_url : live_url) + action),
|
144
|
+
params.to_json,
|
145
|
+
headers
|
146
|
+
))
|
147
|
+
rescue ResponseError => e
|
148
|
+
response = parse(e.response.body)
|
149
|
+
end
|
150
|
+
|
151
|
+
Response.new(
|
152
|
+
success_from(response),
|
153
|
+
message_from(response),
|
154
|
+
response,
|
155
|
+
authorization: authorization_from(response, params),
|
156
|
+
test: test?
|
157
|
+
)
|
158
|
+
end
|
159
|
+
|
160
|
+
def success_from(response)
|
161
|
+
(!response["error"])
|
162
|
+
end
|
163
|
+
|
164
|
+
def message_from(response)
|
165
|
+
(response["error"] ? response["error_description"] : "Success")
|
166
|
+
end
|
167
|
+
|
168
|
+
def authorization_from(response, params)
|
169
|
+
return response["credit_card_id"].to_s if response["credit_card_id"]
|
170
|
+
|
171
|
+
[response["checkout_id"], params[:amount]].join('|')
|
172
|
+
end
|
173
|
+
|
174
|
+
def split_authorization(authorization)
|
175
|
+
auth, original_amount = authorization.to_s.split("|")
|
176
|
+
[auth, original_amount]
|
177
|
+
end
|
178
|
+
|
179
|
+
def headers
|
180
|
+
{
|
181
|
+
"Content-Type" => "application/json",
|
182
|
+
"User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
183
|
+
"Authorization" => "Bearer #{@options[:access_token]}"
|
184
|
+
}
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
@@ -3,6 +3,8 @@ require 'action_pack'
|
|
3
3
|
module ActiveMerchant #:nodoc:
|
4
4
|
module Billing #:nodoc:
|
5
5
|
module Integrations #:nodoc:
|
6
|
+
ActionViewHelperError = Class.new(StandardError)
|
7
|
+
|
6
8
|
module ActionViewHelper
|
7
9
|
# This helper allows the usage of different payment integrations
|
8
10
|
# through a single form helper. Payment integrations are the
|
@@ -67,6 +69,8 @@ module ActiveMerchant #:nodoc:
|
|
67
69
|
|
68
70
|
concat(result.respond_to?(:html_safe) ? result.html_safe : result)
|
69
71
|
nil
|
72
|
+
rescue => e
|
73
|
+
raise ActionViewHelperError.new(e)
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -36,8 +36,12 @@ module ActiveMerchant #:nodoc:
|
|
36
36
|
|
37
37
|
def acknowledge(authcode = nil)
|
38
38
|
# paydollar supports multiple signature keys, therefore we need to check if any
|
39
|
-
# of their signatures
|
40
|
-
@params['secureHash']
|
39
|
+
# of their signatures match ours
|
40
|
+
hash = @params['secureHash']
|
41
|
+
if !hash
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
hash.split(',').include? generate_secure_hash
|
41
45
|
end
|
42
46
|
|
43
47
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.42.
|
4
|
+
version: 1.42.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
U1BPVm5oYkZKM3ZTWFkxdWxQL1I2WFc5dm53CjZra1FpMmZIaFUyMHVnTXpw
|
39
39
|
ODgxRWl4citUakMwUnZVZXJMRzdnPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUt
|
40
40
|
LS0tLQo=
|
41
|
-
date: 2014-
|
41
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: activesupport
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/active_merchant/billing/gateways/fat_zebra.rb
|
273
273
|
- lib/active_merchant/billing/gateways/federated_canada.rb
|
274
274
|
- lib/active_merchant/billing/gateways/finansbank.rb
|
275
|
+
- lib/active_merchant/billing/gateways/first_giving.rb
|
275
276
|
- lib/active_merchant/billing/gateways/first_pay.rb
|
276
277
|
- lib/active_merchant/billing/gateways/firstdata_e4.rb
|
277
278
|
- lib/active_merchant/billing/gateways/garanti.rb
|
@@ -379,6 +380,7 @@ files:
|
|
379
380
|
- lib/active_merchant/billing/gateways/viaklix.rb
|
380
381
|
- lib/active_merchant/billing/gateways/vindicia.rb
|
381
382
|
- lib/active_merchant/billing/gateways/webpay.rb
|
383
|
+
- lib/active_merchant/billing/gateways/wepay.rb
|
382
384
|
- lib/active_merchant/billing/gateways/wirecard.rb
|
383
385
|
- lib/active_merchant/billing/gateways/worldpay.rb
|
384
386
|
- lib/active_merchant/billing/gateways.rb
|
@@ -387,9 +389,6 @@ files:
|
|
387
389
|
- lib/active_merchant/billing/integrations/a1agregator/status.rb
|
388
390
|
- lib/active_merchant/billing/integrations/a1agregator.rb
|
389
391
|
- lib/active_merchant/billing/integrations/action_view_helper.rb
|
390
|
-
- lib/active_merchant/billing/integrations/alipay/helper.rb
|
391
|
-
- lib/active_merchant/billing/integrations/alipay/notification.rb
|
392
|
-
- lib/active_merchant/billing/integrations/alipay.rb
|
393
392
|
- lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb
|
394
393
|
- lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb
|
395
394
|
- lib/active_merchant/billing/integrations/authorize_net_sim.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/alipay/helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/alipay/notification.rb'
|
3
|
-
|
4
|
-
module ActiveMerchant #:nodoc:
|
5
|
-
module Billing #:nodoc:
|
6
|
-
module Integrations #:nodoc:
|
7
|
-
module Alipay
|
8
|
-
|
9
|
-
mattr_accessor :service_url
|
10
|
-
self.service_url = 'https://www.example.com'
|
11
|
-
|
12
|
-
def self.notification(post)
|
13
|
-
Notification.new(post)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
2
|
-
module Billing #:nodoc:
|
3
|
-
module Integrations #:nodoc:
|
4
|
-
module Alipay
|
5
|
-
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
-
# Replace with the real mapping
|
7
|
-
mapping :account, ''
|
8
|
-
mapping :amount, ''
|
9
|
-
|
10
|
-
mapping :order, ''
|
11
|
-
|
12
|
-
mapping :customer, :first_name => '',
|
13
|
-
:last_name => '',
|
14
|
-
:email => '',
|
15
|
-
:phone => ''
|
16
|
-
|
17
|
-
mapping :billing_address, :city => '',
|
18
|
-
:address1 => '',
|
19
|
-
:address2 => '',
|
20
|
-
:state => '',
|
21
|
-
:zip => '',
|
22
|
-
:country => ''
|
23
|
-
|
24
|
-
mapping :notify_url, ''
|
25
|
-
mapping :return_url, ''
|
26
|
-
mapping :cancel_return_url, ''
|
27
|
-
mapping :description, ''
|
28
|
-
mapping :tax, ''
|
29
|
-
mapping :shipping, ''
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
|
-
module ActiveMerchant #:nodoc:
|
4
|
-
module Billing #:nodoc:
|
5
|
-
module Integrations #:nodoc:
|
6
|
-
module Alipay
|
7
|
-
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
-
def complete?
|
9
|
-
params['']
|
10
|
-
end
|
11
|
-
|
12
|
-
def item_id
|
13
|
-
params['']
|
14
|
-
end
|
15
|
-
|
16
|
-
def transaction_id
|
17
|
-
params['']
|
18
|
-
end
|
19
|
-
|
20
|
-
# When was this payment received by the client.
|
21
|
-
def received_at
|
22
|
-
params['']
|
23
|
-
end
|
24
|
-
|
25
|
-
def payer_email
|
26
|
-
params['']
|
27
|
-
end
|
28
|
-
|
29
|
-
def receiver_email
|
30
|
-
params['']
|
31
|
-
end
|
32
|
-
|
33
|
-
def security_key
|
34
|
-
params['']
|
35
|
-
end
|
36
|
-
|
37
|
-
# the money amount we received in X.2 decimal.
|
38
|
-
def gross
|
39
|
-
params['']
|
40
|
-
end
|
41
|
-
|
42
|
-
# Was this a test transaction?
|
43
|
-
def test?
|
44
|
-
params[''] == 'test'
|
45
|
-
end
|
46
|
-
|
47
|
-
def status
|
48
|
-
params['']
|
49
|
-
end
|
50
|
-
|
51
|
-
# Acknowledge the transaction to Alipay. This method has to be called after a new
|
52
|
-
# apc arrives. Alipay will verify that all the information we received are correct and will return a
|
53
|
-
# ok or a fail.
|
54
|
-
#
|
55
|
-
# Example:
|
56
|
-
#
|
57
|
-
# def ipn
|
58
|
-
# notify = AlipayNotification.new(request.raw_post)
|
59
|
-
#
|
60
|
-
# if notify.acknowledge
|
61
|
-
# ... process order ... if notify.complete?
|
62
|
-
# else
|
63
|
-
# ... log possible hacking attempt ...
|
64
|
-
# end
|
65
|
-
def acknowledge(authcode = nil)
|
66
|
-
payload = raw
|
67
|
-
|
68
|
-
uri = URI.parse(Alipay.notification_confirmation_url)
|
69
|
-
|
70
|
-
request = Net::HTTP::Post.new(uri.path)
|
71
|
-
|
72
|
-
request['Content-Length'] = "#{payload.size}"
|
73
|
-
request['User-Agent'] = "Active Merchant -- http://home.leetsoft.com/am"
|
74
|
-
request['Content-Type'] = "application/x-www-form-urlencoded"
|
75
|
-
|
76
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
77
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
|
78
|
-
http.use_ssl = true
|
79
|
-
|
80
|
-
response = http.request(request, payload)
|
81
|
-
|
82
|
-
# Replace with the appropriate codes
|
83
|
-
raise StandardError.new("Faulty Alipay result: #{response.body}") unless ["AUTHORISED", "DECLINED"].include?(response.body)
|
84
|
-
response.body == "AUTHORISED"
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# Take the posted data and move the relevant data into a hash
|
90
|
-
def parse(post)
|
91
|
-
@raw = post.to_s
|
92
|
-
for line in @raw.split('&')
|
93
|
-
key, value = *line.scan( %r{^([A-Za-z0-9_.-]+)\=(.*)$} ).flatten
|
94
|
-
params[key] = CGI.unescape(value.to_s) if key.present?
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|