active_paypal_adaptive_payment 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -12,6 +12,9 @@ This library is meant to interface with PayPal's Adaptive Payment Gateway.
|
|
12
12
|
* Peapprovals
|
13
13
|
* Refunds
|
14
14
|
* Currency conversions
|
15
|
+
* getting/setting payment options
|
16
|
+
* getting shipping addresses
|
17
|
+
* getting a redirect for the embedded pay flow
|
15
18
|
* More soon!
|
16
19
|
|
17
20
|
## Installation
|
@@ -28,24 +31,23 @@ See [iAuction: An Adaptive Payments Tutorial Featuring Parallel Payments](https:
|
|
28
31
|
|
29
32
|
### Init
|
30
33
|
|
31
|
-
gateway =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:appid => "APP-80W284485P519543T" )
|
34
|
+
gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(
|
35
|
+
:login => "acutio_1313133342_biz_api1.gmail.com",
|
36
|
+
:password => "1255043567",
|
37
|
+
:signature => "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
|
38
|
+
:appid => "APP-80W284485P519543T" )
|
37
39
|
|
38
40
|
### Pre-approved paymen
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
gateway.preapprove_payment (
|
43
|
+
:return_url => "returnURL",
|
44
|
+
:cancel_url => "cancelURL",
|
45
|
+
:senderEmail =>"email address of sender",
|
46
|
+
:start_date => Time.now,
|
47
|
+
:end_date => Time.now + (60*60*24) * 30,
|
48
|
+
:currency_code =>"currency code",
|
49
|
+
:max_amount => "maxTotalAmountOfAllPayments",
|
50
|
+
:maxNumberOfPayments => "maxNumberOfPayments" )
|
49
51
|
|
50
52
|
### Cancel pre-approved payment
|
51
53
|
|
@@ -69,7 +71,7 @@ See [iAuction: An Adaptive Payments Tutorial Featuring Parallel Payments](https:
|
|
69
71
|
)
|
70
72
|
|
71
73
|
# for redirecting the customer to the actual paypal site to finish the payment.
|
72
|
-
|
74
|
+
redirect_to (gateway.redirect_url_for(response["payKey"]))
|
73
75
|
end
|
74
76
|
|
75
77
|
Set the `:primary` flag to `false` for each recipient for a split payment.
|
@@ -78,9 +80,12 @@ Maybe also check the tests for a sample implementation.
|
|
78
80
|
|
79
81
|
## Testing
|
80
82
|
|
81
|
-
First modify the
|
83
|
+
First modify the `test/fixtures.yml` to fit your app credentials (You
|
84
|
+
will need at least a PayPal developer account).
|
82
85
|
|
83
|
-
After that you can
|
86
|
+
After that you can run them like this:
|
87
|
+
|
88
|
+
$ ruby -Ilib test/test_paypal_adaptive_payment.rb
|
84
89
|
|
85
90
|
## Debugging
|
86
91
|
|
@@ -96,8 +101,12 @@ xml request, raw json response and the URL of the endpoint.
|
|
96
101
|
|
97
102
|
## TODO
|
98
103
|
|
99
|
-
* Documentation
|
100
|
-
*
|
104
|
+
* More/better Documentation.
|
105
|
+
* Improve/change the tests implementation by maybe run them off
|
106
|
+
fixture data and use a separate script/test for actually invoking
|
107
|
+
requests to PayPal. This will allow other developers to implement
|
108
|
+
the without being required to set and request the credentials from
|
109
|
+
PayPal process.
|
101
110
|
|
102
111
|
## Contributors
|
103
112
|
|
@@ -106,6 +115,7 @@ xml request, raw json response and the URL of the endpoint.
|
|
106
115
|
* LeviRosol (<https://github.com/LeviRosol>)
|
107
116
|
* Florian95 (<https://github.com/Florian95>)
|
108
117
|
* akichatov (<https://github.com/akichatov>)
|
118
|
+
* Patrick Sinclair (<https://github.com/metade>)
|
109
119
|
|
110
120
|
## Other previous contributors where some code was taken from.
|
111
121
|
|
@@ -47,6 +47,18 @@ module ActiveMerchant #:nodoc:
|
|
47
47
|
commit('PaymentDetails', build_adaptive_payment_details_request(options))
|
48
48
|
end
|
49
49
|
|
50
|
+
def get_shipping_addresses(options)
|
51
|
+
commit('GetShippingAddresses', build_adaptive_get_shipping_addresses_request(options))
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_payment_options(options)
|
55
|
+
commit('GetPaymentOptions', build_adaptive_get_payment_options_request(options))
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_payment_options(options)
|
59
|
+
commit('SetPaymentOptions', build_adaptive_set_payment_options_request(options))
|
60
|
+
end
|
61
|
+
|
50
62
|
def refund(options)
|
51
63
|
commit('Refund', build_adaptive_refund_details(options))
|
52
64
|
end
|
@@ -75,6 +87,10 @@ module ActiveMerchant #:nodoc:
|
|
75
87
|
test? ? EMBEDDED_FLOW_TEST_URL : EMBEDDED_FLOW_LIVE_URL
|
76
88
|
end
|
77
89
|
|
90
|
+
def embedded_flow_url_for(token)
|
91
|
+
"#{embedded_flow_url}?paykey=#{token}"
|
92
|
+
end
|
93
|
+
|
78
94
|
def debug
|
79
95
|
"Url: #{@url}\n\n Request: #{@xml} \n\n Response: #{@response.json}"
|
80
96
|
end
|
@@ -148,6 +164,52 @@ module ActiveMerchant #:nodoc:
|
|
148
164
|
end
|
149
165
|
end
|
150
166
|
|
167
|
+
def build_adaptive_get_shipping_addresses_request(opts)
|
168
|
+
@xml = ''
|
169
|
+
xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
|
170
|
+
xml.instruct!
|
171
|
+
xml.GetShippingAddressesRequest do |x|
|
172
|
+
x.requestEnvelope do |x|
|
173
|
+
x.detailLevel 'ReturnAll'
|
174
|
+
x.errorLanguage opts[:error_language] ||= 'en_US'
|
175
|
+
end
|
176
|
+
x.key opts[:pay_key]
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def build_adaptive_get_payment_options_request(opts)
|
181
|
+
@xml = ''
|
182
|
+
xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
|
183
|
+
xml.instruct!
|
184
|
+
xml.GetPaymentOptionsRequest do |x|
|
185
|
+
x.requestEnvelope do |x|
|
186
|
+
x.detailLevel 'ReturnAll'
|
187
|
+
x.errorLanguage opts[:error_language] ||= 'en_US'
|
188
|
+
end
|
189
|
+
x.payKey opts[:pay_key]
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def build_adaptive_set_payment_options_request(opts)
|
194
|
+
opts[:sender] ||= {}
|
195
|
+
|
196
|
+
@xml = ''
|
197
|
+
xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
|
198
|
+
xml.instruct!
|
199
|
+
xml.SetPaymentOptionsRequest do |x|
|
200
|
+
x.requestEnvelope do |x|
|
201
|
+
x.detailLevel 'ReturnAll'
|
202
|
+
x.errorLanguage opts[:error_language] ||= 'en_US'
|
203
|
+
end
|
204
|
+
x.senderOptions do |x|
|
205
|
+
x.shareAddress opts[:sender][:share_address] if opts[:sender][:share_address]
|
206
|
+
x.sharePhoneNumber opts[:sender][:share_phone_number] if opts[:sender][:share_phone_number]
|
207
|
+
x.requireShippingAddressSelection opts[:sender][:require_shipping_address_selection] if opts[:sender][:require_shipping_address_selection]
|
208
|
+
end
|
209
|
+
x.payKey opts[:pay_key]
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
151
213
|
def build_adaptive_refund_details(options)
|
152
214
|
@xml = ''
|
153
215
|
xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_paypal_adaptive_payment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemerchant
|
16
|
-
requirement: &
|
16
|
+
requirement: &80394670 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *80394670
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &80394430 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *80394430
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hashie
|
38
|
-
requirement: &
|
38
|
+
requirement: &80394190 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.2.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *80394190
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: money
|
49
|
-
requirement: &
|
49
|
+
requirement: &80393950 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 3.6.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *80393950
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mocha
|
60
|
-
requirement: &
|
60
|
+
requirement: &80393710 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.10.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *80393710
|
69
69
|
description: ! ' This library is meant to interface with PayPal''s Adaptive Payment
|
70
70
|
Gateway.
|
71
71
|
|
@@ -76,17 +76,17 @@ executables: []
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
-
- lib/active_paypal_adaptive_payment.rb
|
80
|
-
- lib/active_merchant/billing/integrations/paypal_adaptive_payment.rb
|
81
|
-
- lib/active_merchant/billing/integrations/paypal_adaptive_payment/helper.rb
|
82
79
|
- lib/active_merchant/billing/integrations/paypal_adaptive_payment/return.rb
|
83
80
|
- lib/active_merchant/billing/integrations/paypal_adaptive_payment/notification.rb
|
81
|
+
- lib/active_merchant/billing/integrations/paypal_adaptive_payment/helper.rb
|
82
|
+
- lib/active_merchant/billing/integrations/paypal_adaptive_payment.rb
|
84
83
|
- lib/active_merchant/billing/integrations/notification.rb
|
85
|
-
- lib/active_merchant/billing/gateways/paypal_adaptive_payment.rb
|
86
|
-
- lib/active_merchant/billing/gateways/paypal_adaptive_payments/ext.rb
|
87
84
|
- lib/active_merchant/billing/gateways/paypal_adaptive_payments/exceptions.rb
|
85
|
+
- lib/active_merchant/billing/gateways/paypal_adaptive_payments/ext.rb
|
88
86
|
- lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb
|
89
87
|
- lib/active_merchant/billing/gateways/paypal_adaptive_payment_common.rb
|
88
|
+
- lib/active_merchant/billing/gateways/paypal_adaptive_payment.rb
|
89
|
+
- lib/active_paypal_adaptive_payment.rb
|
90
90
|
- MIT-LICENSE
|
91
91
|
- README.md
|
92
92
|
- CHANGELOG.md
|