paypal-express 0.3.1 → 0.4.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/paypal.rb +2 -1
- data/lib/paypal/exception/api_error.rb +8 -2
- data/lib/paypal/express/request.rb +35 -0
- data/lib/paypal/nvp/response.rb +26 -16
- data/lib/paypal/payment/request.rb +2 -3
- data/lib/paypal/payment/response/reference.rb +8 -0
- data/spec/fake_response/CreateBillingAgreement/success.txt +1 -0
- data/spec/fake_response/DoExpressCheckoutPayment/success.txt +1 -1
- data/spec/fake_response/DoExpressCheckoutPayment/success_with_billing_agreement.txt +1 -0
- data/spec/fake_response/DoReferenceTransaction/failure.txt +1 -0
- data/spec/fake_response/DoReferenceTransaction/success.txt +1 -0
- data/spec/paypal/express/request_spec.rb +73 -9
- data/spec/paypal/nvp/response_spec.rb +12 -1
- data/spec/paypal/payment/request_spec.rb +10 -12
- metadata +13 -48
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0.alpha
|
data/lib/paypal.rb
CHANGED
@@ -6,7 +6,7 @@ require 'restclient_with_cert'
|
|
6
6
|
|
7
7
|
module Paypal
|
8
8
|
|
9
|
-
API_VERSION = '
|
9
|
+
API_VERSION = '78.0'
|
10
10
|
ENDPOINT = {
|
11
11
|
:production => 'https://www.paypal.com/cgi-bin/webscr',
|
12
12
|
:sandbox => 'https://www.sandbox.paypal.com/cgi-bin/webscr'
|
@@ -73,6 +73,7 @@ require 'paypal/payment/response'
|
|
73
73
|
require 'paypal/payment/response/info'
|
74
74
|
require 'paypal/payment/response/item'
|
75
75
|
require 'paypal/payment/response/payer'
|
76
|
+
require 'paypal/payment/response/reference'
|
76
77
|
require 'paypal/payment/response/refund'
|
77
78
|
require 'paypal/payment/response/ship_to'
|
78
79
|
require 'paypal/payment/recurring'
|
@@ -18,7 +18,13 @@ module Paypal
|
|
18
18
|
:BUILD => :build,
|
19
19
|
:CORRELATIONID => :colleration_id,
|
20
20
|
:TIMESTAMP => :timestamp,
|
21
|
-
:VERSION => :version
|
21
|
+
:VERSION => :version,
|
22
|
+
:ORDERTIME => :order_time,
|
23
|
+
:PENDINGREASON => :pending_reason,
|
24
|
+
:PAYMENTSTATUS => :payment_status,
|
25
|
+
:PAYMENTTYPE => :payment_type,
|
26
|
+
:REASONCODE => :reason_code,
|
27
|
+
:TRANSACTIONTYPE => :transaction_type
|
22
28
|
}
|
23
29
|
attr_accessor *@@attribute_mapping.values
|
24
30
|
attr_accessor :raw, :details
|
@@ -72,4 +78,4 @@ module Paypal
|
|
72
78
|
end
|
73
79
|
end
|
74
80
|
end
|
75
|
-
end
|
81
|
+
end
|
@@ -2,6 +2,8 @@ module Paypal
|
|
2
2
|
module Express
|
3
3
|
class Request < NVP::Request
|
4
4
|
|
5
|
+
# Common
|
6
|
+
|
5
7
|
def setup(payment_requests, return_url, cancel_url, options = {})
|
6
8
|
params = {
|
7
9
|
:RETURNURL => return_url,
|
@@ -35,6 +37,9 @@ module Paypal
|
|
35
37
|
Response.new response
|
36
38
|
end
|
37
39
|
|
40
|
+
|
41
|
+
# Recurring Payment Specific
|
42
|
+
|
38
43
|
def subscribe!(token, recurring_profile)
|
39
44
|
params = {
|
40
45
|
:TOKEN => token
|
@@ -76,6 +81,36 @@ module Paypal
|
|
76
81
|
renew!(profile_id, :Reactivate, options)
|
77
82
|
end
|
78
83
|
|
84
|
+
|
85
|
+
# Reference Transaction Specific
|
86
|
+
|
87
|
+
def agree!(token, options = {})
|
88
|
+
params = {
|
89
|
+
:TOKEN => token
|
90
|
+
}
|
91
|
+
if options[:max_amount]
|
92
|
+
params[:MAXAMT] = Util.formatted_amount options[:max_amount]
|
93
|
+
end
|
94
|
+
response = self.request :CreateBillingAgreement, params
|
95
|
+
Response.new response
|
96
|
+
end
|
97
|
+
|
98
|
+
def charge!(reference_id, amount, options = {})
|
99
|
+
params = {
|
100
|
+
:REFERENCEID => reference_id,
|
101
|
+
:AMT => Util.formatted_amount(amount),
|
102
|
+
:PAYMENTACTION => options[:payment_action] || :Sale
|
103
|
+
}
|
104
|
+
if options[:currency_code]
|
105
|
+
params[:CURRENCYCODE] = options[:currency_code]
|
106
|
+
end
|
107
|
+
response = self.request :DoReferenceTransaction, params
|
108
|
+
Response.new response
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
# Refund Specific
|
113
|
+
|
79
114
|
def refund!(transaction_id, options = {})
|
80
115
|
params = {
|
81
116
|
:TRANSACTIONID => transaction_id,
|
data/lib/paypal/nvp/response.rb
CHANGED
@@ -5,7 +5,6 @@ module Paypal
|
|
5
5
|
@@attribute_mapping = {
|
6
6
|
:ACK => :ack,
|
7
7
|
:ADDRESSSTATUS => :address_status,
|
8
|
-
:BILLINGAGREEMENTACCEPTEDSTATUS => :billing_agreement_accepted_status,
|
9
8
|
:BUILD => :build,
|
10
9
|
:CHECKOUTSTATUS => :checkout_status,
|
11
10
|
:CORRELATIONID => :colleration_id,
|
@@ -15,12 +14,12 @@ module Paypal
|
|
15
14
|
:NOTIFYURL => :notify_url,
|
16
15
|
:TIMESTAMP => :timestamp,
|
17
16
|
:TOKEN => :token,
|
18
|
-
:VERSION => :version
|
19
|
-
:BILLINGAGREEMENTID => :billing_agreement_id
|
17
|
+
:VERSION => :version
|
20
18
|
}
|
21
19
|
attr_accessor *@@attribute_mapping.values
|
22
20
|
attr_accessor :shipping_options_is_default, :success_page_redirect_requested, :insurance_option_selected
|
23
|
-
attr_accessor :amount, :description, :ship_to, :payer, :recurring, :
|
21
|
+
attr_accessor :amount, :description, :ship_to, :payer, :recurring, :billing_agreement, :refund
|
22
|
+
attr_accessor :payment_responses, :payment_info, :items
|
24
23
|
|
25
24
|
def initialize(attributes = {})
|
26
25
|
attrs = attributes.dup
|
@@ -37,7 +36,8 @@ module Paypal
|
|
37
36
|
:insurance => attrs.delete(:INSURANCEAMT),
|
38
37
|
:ship_disc => attrs.delete(:SHIPDISCAMT),
|
39
38
|
:shipping => attrs.delete(:SHIPPINGAMT),
|
40
|
-
:tax => attrs.delete(:TAXAMT)
|
39
|
+
:tax => attrs.delete(:TAXAMT),
|
40
|
+
:fee => attrs.delete(:FEEAMT)
|
41
41
|
)
|
42
42
|
@ship_to = Payment::Response::ShipTo.new(
|
43
43
|
:owner => attrs.delete(:SHIPADDRESSOWNER),
|
@@ -60,17 +60,6 @@ module Paypal
|
|
60
60
|
:email => attrs.delete(:EMAIL)
|
61
61
|
)
|
62
62
|
end
|
63
|
-
if attrs[:REFUNDTRANSACTIONID]
|
64
|
-
@refund = Payment::Response::Refund.new(
|
65
|
-
:transaction_id => attrs.delete(:REFUNDTRANSACTIONID),
|
66
|
-
:amount => {
|
67
|
-
:total => attrs.delete(:TOTALREFUNDEDAMOUNT),
|
68
|
-
:fee => attrs.delete(:FEEREFUNDAMT),
|
69
|
-
:gross => attrs.delete(:GROSSREFUNDAMT),
|
70
|
-
:net => attrs.delete(:NETREFUNDAMT)
|
71
|
-
}
|
72
|
-
)
|
73
|
-
end
|
74
63
|
if attrs[:PROFILEID]
|
75
64
|
@recurring = Payment::Recurring.new(
|
76
65
|
:identifier => attrs.delete(:PROFILEID),
|
@@ -120,6 +109,27 @@ module Paypal
|
|
120
109
|
)
|
121
110
|
end
|
122
111
|
end
|
112
|
+
if attrs[:BILLINGAGREEMENTID]
|
113
|
+
@billing_agreement = Payment::Response::Reference.new(
|
114
|
+
:identifier => attrs.delete(:BILLINGAGREEMENTID)
|
115
|
+
)
|
116
|
+
billing_agreement_info = Payment::Response::Info.attribute_mapping.keys.inject({}) do |billing_agreement_info, key|
|
117
|
+
billing_agreement_info.merge! key => attrs.delete(key)
|
118
|
+
end
|
119
|
+
@billing_agreement.info = Payment::Response::Info.new billing_agreement_info
|
120
|
+
@billing_agreement.info.amount = @amount
|
121
|
+
end
|
122
|
+
if attrs[:REFUNDTRANSACTIONID]
|
123
|
+
@refund = Payment::Response::Refund.new(
|
124
|
+
:transaction_id => attrs.delete(:REFUNDTRANSACTIONID),
|
125
|
+
:amount => {
|
126
|
+
:total => attrs.delete(:TOTALREFUNDEDAMOUNT),
|
127
|
+
:fee => attrs.delete(:FEEREFUNDAMT),
|
128
|
+
:gross => attrs.delete(:GROSSREFUNDAMT),
|
129
|
+
:net => attrs.delete(:NETREFUNDAMT)
|
130
|
+
}
|
131
|
+
)
|
132
|
+
end
|
123
133
|
|
124
134
|
# payment_responses
|
125
135
|
payment_responses = []
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Paypal
|
2
2
|
module Payment
|
3
3
|
class Request < Base
|
4
|
-
attr_optional :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description, :
|
4
|
+
attr_optional :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description, :billing_agreement_id
|
5
5
|
attr_accessor :amount, :items
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
@@ -34,8 +34,7 @@ module Paypal
|
|
34
34
|
# recurring payment doesn't support dynamic notify_url.
|
35
35
|
:"PAYMENTREQUEST_#{index}_NOTIFYURL" => self.notify_url,
|
36
36
|
:"L_BILLINGTYPE#{index}" => self.billing_type,
|
37
|
-
:"L_BILLINGAGREEMENTDESCRIPTION#{index}" => self.billing_agreement_description
|
38
|
-
:"BILLINGTYPE" => self.reference_transactions_billing_type
|
37
|
+
:"L_BILLINGAGREEMENTDESCRIPTION#{index}" => self.billing_agreement_description
|
39
38
|
}.delete_if do |k, v|
|
40
39
|
v.blank?
|
41
40
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
BILLINGAGREEMENTID=B%2d45776062X95244343&TIMESTAMP=2011%2d08%2d06T07%3a53%3a50Z&CORRELATIONID=9a16fde4456e1&ACK=Success&VERSION=78%2e0&BUILD=2020243
|
@@ -1 +1 @@
|
|
1
|
-
TOKEN=EC-9E2743126S4330617&SUCCESSPAGEREDIRECTREQUESTED=false&TIMESTAMP=2011-02-08T03:23:55Z&CORRELATIONID=15b93874c358c&ACK=Success&VERSION=66.0&BUILD=1721431&INSURANCEOPTIONSELECTED=false&SHIPPINGOPTIONISDEFAULT=false&PAYMENTINFO_0_TRANSACTIONID=8NC65222871997739&PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&PAYMENTINFO_0_PAYMENTTYPE=instant&PAYMENTINFO_0_ORDERTIME=2011-02-08T03:23:54Z&PAYMENTINFO_0_AMT=14.00&PAYMENTINFO_0_FEEAMT=0.85&PAYMENTINFO_0_TAXAMT=0.00&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTINFO_0_PAYMENTSTATUS=Completed&PAYMENTINFO_0_PENDINGREASON=None&PAYMENTINFO_0_REASONCODE=None&PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&PAYMENTINFO_0_ERRORCODE=0&
|
1
|
+
TOKEN=EC-9E2743126S4330617&SUCCESSPAGEREDIRECTREQUESTED=false&TIMESTAMP=2011-02-08T03:23:55Z&CORRELATIONID=15b93874c358c&ACK=Success&VERSION=66.0&BUILD=1721431&INSURANCEOPTIONSELECTED=false&SHIPPINGOPTIONISDEFAULT=false&PAYMENTINFO_0_TRANSACTIONID=8NC65222871997739&PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&PAYMENTINFO_0_PAYMENTTYPE=instant&PAYMENTINFO_0_ORDERTIME=2011-02-08T03:23:54Z&PAYMENTINFO_0_AMT=14.00&PAYMENTINFO_0_FEEAMT=0.85&PAYMENTINFO_0_TAXAMT=0.00&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTINFO_0_PAYMENTSTATUS=Completed&PAYMENTINFO_0_PENDINGREASON=None&PAYMENTINFO_0_REASONCODE=None&PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&PAYMENTINFO_0_ERRORCODE=0&PAYMENTINFO_0_ACK=Success
|
@@ -0,0 +1 @@
|
|
1
|
+
TOKEN=EC-9E2743126S4330617&SUCCESSPAGEREDIRECTREQUESTED=false&TIMESTAMP=2011-02-08T03:23:55Z&CORRELATIONID=15b93874c358c&ACK=Success&VERSION=66.0&BUILD=1721431&INSURANCEOPTIONSELECTED=false&SHIPPINGOPTIONISDEFAULT=false&PAYMENTINFO_0_TRANSACTIONID=8NC65222871997739&PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&PAYMENTINFO_0_PAYMENTTYPE=instant&PAYMENTINFO_0_ORDERTIME=2011-02-08T03:23:54Z&PAYMENTINFO_0_AMT=14.00&PAYMENTINFO_0_FEEAMT=0.85&PAYMENTINFO_0_TAXAMT=0.00&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTINFO_0_PAYMENTSTATUS=Completed&PAYMENTINFO_0_PENDINGREASON=None&PAYMENTINFO_0_REASONCODE=None&PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&PAYMENTINFO_0_ERRORCODE=0&BILLINGAGREEMENTID=B-1XR87946TC504770W&PAYMENTINFO_0_ACK=Success
|
@@ -0,0 +1 @@
|
|
1
|
+
TIMESTAMP=2011%2d07%2d19T08%3a59%3a52Z&CORRELATIONID=ed8096a3c3d7d&ACK=Failure&VERSION=72%2e0&BUILD=1982348&L_ERRORCODE0=11451&L_SHORTMESSAGE0=Billing%20Agreement%20Id%20or%20transaction%20Id%20is%20not%20valid&L_LONGMESSAGE0=Billing%20Agreement%20Id%20or%20transaction%20Id%20is%20not%20valid&L_SEVERITYCODE0=Error&TRANSACTIONTYPE=None&PAYMENTTYPE=None&ORDERTIME=1970%2d01%2d01T00%3a00%3a00Z&PAYMENTSTATUS=None&PENDINGREASON=None&REASONCODE=None
|
@@ -0,0 +1 @@
|
|
1
|
+
BILLINGAGREEMENTID=B%2d7HU5U5U1ULU14U49E&TIMESTAMP=2011%2d07%2d19T08%3a30%3a08Z&CORRELATIONID=12ca85fb3c9d2&ACK=Success&VERSION=72%2e0&BUILD=1982348&TRANSACTIONID=3IV51111LY1211907&TRANSACTIONTYPE=merchtpmt&PAYMENTTYPE=instant&ORDERTIME=2011%2d07%2d19T08%3a30%3a06Z&AMT=192&FEEAMT=47&TAXAMT=0&CURRENCYCODE=JPY&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None&PROTECTIONELIGIBILITY=Ineligible&PROTECTIONELIGIBILITYTYPE=None
|
@@ -34,7 +34,7 @@ describe Paypal::Express::Request do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
let :recurring_payment_request do
|
37
|
-
Paypal::Payment::Request.new(
|
37
|
+
Paypal::Payment::Request.new(
|
38
38
|
:billing_type => :RecurringPayments,
|
39
39
|
:billing_agreement_description => 'Recurring Payment Request'
|
40
40
|
)
|
@@ -52,6 +52,13 @@ describe Paypal::Express::Request do
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
let :reference_transaction_request do
|
56
|
+
Paypal::Payment::Request.new(
|
57
|
+
:billing_type => :MerchantInitiatedBilling,
|
58
|
+
:billing_agreement_description => 'Billing Agreement Request'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
55
62
|
describe '.new' do
|
56
63
|
context 'when any required parameters are missing' do
|
57
64
|
it 'should raise AttrRequired::AttrMissing' do
|
@@ -79,7 +86,7 @@ describe Paypal::Express::Request do
|
|
79
86
|
it 'should return Paypal::Express::Response' do
|
80
87
|
fake_response 'SetExpressCheckout/success'
|
81
88
|
response = instance.setup recurring_payment_request, return_url, cancel_url
|
82
|
-
response.should be_instance_of
|
89
|
+
response.should be_instance_of Paypal::Express::Response
|
83
90
|
end
|
84
91
|
|
85
92
|
it 'should support no_shipping option' do
|
@@ -133,13 +140,31 @@ describe Paypal::Express::Request do
|
|
133
140
|
}
|
134
141
|
end
|
135
142
|
end
|
143
|
+
|
144
|
+
context 'when reference transaction request given' do
|
145
|
+
it 'should call SetExpressCheckout' do
|
146
|
+
expect do
|
147
|
+
instance.setup reference_transaction_request, return_url, cancel_url
|
148
|
+
end.should request_to nvp_endpoint, :post
|
149
|
+
instance._method_.should == :SetExpressCheckout
|
150
|
+
instance._sent_params_.should == {
|
151
|
+
:L_BILLINGTYPE0 => :MerchantInitiatedBilling,
|
152
|
+
:L_BILLINGAGREEMENTDESCRIPTION0 => 'Billing Agreement Request',
|
153
|
+
:RETURNURL => return_url,
|
154
|
+
:CANCELURL => cancel_url,
|
155
|
+
:PAYMENTREQUEST_0_AMT => '0.00',
|
156
|
+
:PAYMENTREQUEST_0_TAXAMT => "0.00",
|
157
|
+
:PAYMENTREQUEST_0_SHIPPINGAMT => "0.00"
|
158
|
+
}
|
159
|
+
end
|
160
|
+
end
|
136
161
|
end
|
137
162
|
|
138
163
|
describe '#details' do
|
139
164
|
it 'should return Paypal::Express::Response' do
|
140
165
|
fake_response 'GetExpressCheckoutDetails/success'
|
141
166
|
response = instance.details 'token'
|
142
|
-
response.should be_instance_of
|
167
|
+
response.should be_instance_of Paypal::Express::Response
|
143
168
|
end
|
144
169
|
|
145
170
|
it 'should call GetExpressCheckoutDetails' do
|
@@ -157,7 +182,7 @@ describe Paypal::Express::Request do
|
|
157
182
|
it 'should return Paypal::Express::Response' do
|
158
183
|
fake_response 'DoExpressCheckoutPayment/success'
|
159
184
|
response = instance.checkout! 'token', 'payer_id', instant_payment_request
|
160
|
-
response.should be_instance_of
|
185
|
+
response.should be_instance_of Paypal::Express::Response
|
161
186
|
end
|
162
187
|
|
163
188
|
it 'should call DoExpressCheckoutPayment' do
|
@@ -180,7 +205,7 @@ describe Paypal::Express::Request do
|
|
180
205
|
it 'should return Paypal::Express::Response' do
|
181
206
|
fake_response 'CreateRecurringPaymentsProfile/success'
|
182
207
|
response = instance.subscribe! 'token', recurring_profile
|
183
|
-
response.should be_instance_of
|
208
|
+
response.should be_instance_of Paypal::Express::Response
|
184
209
|
end
|
185
210
|
|
186
211
|
it 'should call CreateRecurringPaymentsProfile' do
|
@@ -228,7 +253,7 @@ describe Paypal::Express::Request do
|
|
228
253
|
it 'should return Paypal::Express::Response' do
|
229
254
|
fake_response 'ManageRecurringPaymentsProfileStatus/success'
|
230
255
|
response = instance.renew! 'profile_id', :Cancel
|
231
|
-
response.should be_instance_of
|
256
|
+
response.should be_instance_of Paypal::Express::Response
|
232
257
|
end
|
233
258
|
|
234
259
|
it 'should call ManageRecurringPaymentsProfileStatus' do
|
@@ -266,7 +291,7 @@ describe Paypal::Express::Request do
|
|
266
291
|
it 'should return Paypal::Express::Response' do
|
267
292
|
fake_response 'ManageRecurringPaymentsProfileStatus/success'
|
268
293
|
response = instance.cancel! 'profile_id'
|
269
|
-
response.should be_instance_of
|
294
|
+
response.should be_instance_of Paypal::Express::Response
|
270
295
|
end
|
271
296
|
|
272
297
|
it 'should call ManageRecurringPaymentsProfileStatus' do
|
@@ -285,7 +310,7 @@ describe Paypal::Express::Request do
|
|
285
310
|
it 'should return Paypal::Express::Response' do
|
286
311
|
fake_response 'ManageRecurringPaymentsProfileStatus/success'
|
287
312
|
response = instance.cancel! 'profile_id'
|
288
|
-
response.should be_instance_of
|
313
|
+
response.should be_instance_of Paypal::Express::Response
|
289
314
|
end
|
290
315
|
|
291
316
|
it 'should call ManageRecurringPaymentsProfileStatus' do
|
@@ -304,7 +329,7 @@ describe Paypal::Express::Request do
|
|
304
329
|
it 'should return Paypal::Express::Response' do
|
305
330
|
fake_response 'RefundTransaction/full'
|
306
331
|
response = instance.refund! 'transaction_id'
|
307
|
-
response.should be_instance_of
|
332
|
+
response.should be_instance_of Paypal::Express::Response
|
308
333
|
end
|
309
334
|
|
310
335
|
it 'should call RefundTransaction' do
|
@@ -319,4 +344,43 @@ describe Paypal::Express::Request do
|
|
319
344
|
end
|
320
345
|
end
|
321
346
|
|
347
|
+
describe '#agree!' do
|
348
|
+
it 'should return Paypal::Express::Response' do
|
349
|
+
fake_response 'CreateBillingAgreement/success'
|
350
|
+
response = instance.agree! 'token'
|
351
|
+
response.should be_instance_of Paypal::Express::Response
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should call CreateBillingAgreement' do
|
355
|
+
expect do
|
356
|
+
instance.agree! 'token'
|
357
|
+
end.should request_to nvp_endpoint, :post
|
358
|
+
instance._method_.should == :CreateBillingAgreement
|
359
|
+
instance._sent_params_.should == {
|
360
|
+
:TOKEN => 'token'
|
361
|
+
}
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
describe '#charge!' do
|
366
|
+
it 'should return Paypal::Express::Response' do
|
367
|
+
fake_response 'DoReferenceTransaction/success'
|
368
|
+
response = instance.charge! 'billing_agreement_id', 1000
|
369
|
+
response.should be_instance_of Paypal::Express::Response
|
370
|
+
end
|
371
|
+
|
372
|
+
it 'should call DoReferenceTransaction' do
|
373
|
+
expect do
|
374
|
+
instance.charge! 'billing_agreement_id', 1000, :currency_code => :JPY
|
375
|
+
end.should request_to nvp_endpoint, :post
|
376
|
+
instance._method_.should == :DoReferenceTransaction
|
377
|
+
instance._sent_params_.should == {
|
378
|
+
:REFERENCEID => 'billing_agreement_id',
|
379
|
+
:AMT => '1000.00',
|
380
|
+
:PAYMENTACTION => :Sale,
|
381
|
+
:CURRENCYCODE => :JPY
|
382
|
+
}
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
322
386
|
end
|
@@ -79,9 +79,20 @@ describe Paypal::NVP::Response do
|
|
79
79
|
response = request.checkout! 'token', 'payer_id', payment_request
|
80
80
|
response.payment_responses.size.should == 0
|
81
81
|
response.payment_info.size.should == 1
|
82
|
-
response.billing_agreement_id.should == 'B-1XR87946TC504770W'
|
83
82
|
response.payment_info.first.should be_instance_of(Paypal::Payment::Response::Info)
|
84
83
|
end
|
84
|
+
|
85
|
+
context 'when billing_agreement is included' do
|
86
|
+
before do
|
87
|
+
fake_response 'DoExpressCheckoutPayment/success_with_billing_agreement'
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should have billing_agreement' do
|
91
|
+
Paypal.logger.should_not_receive(:warn)
|
92
|
+
response = request.checkout! 'token', 'payer_id', payment_request
|
93
|
+
response.billing_agreement.identifier.should == 'B-1XR87946TC504770W'
|
94
|
+
end
|
95
|
+
end
|
85
96
|
end
|
86
97
|
|
87
98
|
context 'when CreateRecurringPaymentsProfile response given' do
|
@@ -31,12 +31,11 @@ describe Paypal::Payment::Request do
|
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
-
let :
|
34
|
+
let :reference_transaction_request do
|
35
35
|
Paypal::Payment::Request.new(
|
36
36
|
:currency_code => :JPY,
|
37
|
-
:billing_type => :
|
38
|
-
:billing_agreement_description => '
|
39
|
-
:reference_transactions_billing_type => :MerchantInitiatedBillingSingleAgreement
|
37
|
+
:billing_type => :MerchantInitiatedBillingSingleAgreement,
|
38
|
+
:billing_agreement_description => 'Reference Transaction Request'
|
40
39
|
)
|
41
40
|
end
|
42
41
|
|
@@ -57,9 +56,9 @@ describe Paypal::Payment::Request do
|
|
57
56
|
end
|
58
57
|
|
59
58
|
it 'should handle Recurring Payment parameters' do
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
reference_transaction_request.currency_code.should == :JPY
|
60
|
+
reference_transaction_request.billing_type.should == :MerchantInitiatedBillingSingleAgreement
|
61
|
+
reference_transaction_request.billing_agreement_description.should == 'Reference Transaction Request'
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
@@ -95,15 +94,14 @@ describe Paypal::Payment::Request do
|
|
95
94
|
}
|
96
95
|
end
|
97
96
|
|
98
|
-
it 'should handle
|
99
|
-
|
97
|
+
it 'should handle Reference Transactions parameters' do
|
98
|
+
reference_transaction_request.to_params.should == {
|
100
99
|
:PAYMENTREQUEST_0_AMT => "0.00",
|
101
100
|
:PAYMENTREQUEST_0_TAXAMT => "0.00",
|
102
101
|
:PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
|
103
102
|
:PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
|
104
|
-
:L_BILLINGTYPE0 => :
|
105
|
-
:L_BILLINGAGREEMENTDESCRIPTION0 => "
|
106
|
-
:BILLINGTYPE => :MerchantInitiatedBillingSingleAgreement,
|
103
|
+
:L_BILLINGTYPE0 => :MerchantInitiatedBillingSingleAgreement,
|
104
|
+
:L_BILLINGAGREEMENTDESCRIPTION0 => "Reference Transaction Request"
|
107
105
|
}
|
108
106
|
end
|
109
107
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-express
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 0.3.1
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.4.0.alpha
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- nov matake
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-06
|
13
|
+
date: 2011-08-06 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: activesupport
|
@@ -25,10 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 5
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 3
|
32
23
|
version: "2.3"
|
33
24
|
type: :runtime
|
34
25
|
version_requirements: *id001
|
@@ -40,9 +31,6 @@ dependencies:
|
|
40
31
|
requirements:
|
41
32
|
- - ">="
|
42
33
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 3
|
44
|
-
segments:
|
45
|
-
- 0
|
46
34
|
version: "0"
|
47
35
|
type: :runtime
|
48
36
|
version_requirements: *id002
|
@@ -54,9 +42,6 @@ dependencies:
|
|
54
42
|
requirements:
|
55
43
|
- - ">="
|
56
44
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 3
|
58
|
-
segments:
|
59
|
-
- 0
|
60
45
|
version: "0"
|
61
46
|
type: :runtime
|
62
47
|
version_requirements: *id003
|
@@ -68,11 +53,6 @@ dependencies:
|
|
68
53
|
requirements:
|
69
54
|
- - ">="
|
70
55
|
- !ruby/object:Gem::Version
|
71
|
-
hash: 25
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
- 0
|
75
|
-
- 3
|
76
56
|
version: 0.0.3
|
77
57
|
type: :runtime
|
78
58
|
version_requirements: *id004
|
@@ -84,10 +64,6 @@ dependencies:
|
|
84
64
|
requirements:
|
85
65
|
- - ">="
|
86
66
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 27
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
- 8
|
91
67
|
version: "0.8"
|
92
68
|
type: :development
|
93
69
|
version_requirements: *id005
|
@@ -99,10 +75,6 @@ dependencies:
|
|
99
75
|
requirements:
|
100
76
|
- - ">="
|
101
77
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 25
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
- 9
|
106
78
|
version: "0.9"
|
107
79
|
type: :development
|
108
80
|
version_requirements: *id006
|
@@ -114,9 +86,6 @@ dependencies:
|
|
114
86
|
requirements:
|
115
87
|
- - ">="
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 7
|
118
|
-
segments:
|
119
|
-
- 2
|
120
89
|
version: "2"
|
121
90
|
type: :development
|
122
91
|
version_requirements: *id007
|
@@ -128,11 +97,6 @@ dependencies:
|
|
128
97
|
requirements:
|
129
98
|
- - ">="
|
130
99
|
- !ruby/object:Gem::Version
|
131
|
-
hash: 27
|
132
|
-
segments:
|
133
|
-
- 1
|
134
|
-
- 3
|
135
|
-
- 0
|
136
100
|
version: 1.3.0
|
137
101
|
type: :development
|
138
102
|
version_requirements: *id008
|
@@ -176,14 +140,19 @@ files:
|
|
176
140
|
- lib/paypal/payment/response/info.rb
|
177
141
|
- lib/paypal/payment/response/item.rb
|
178
142
|
- lib/paypal/payment/response/payer.rb
|
143
|
+
- lib/paypal/payment/response/reference.rb
|
179
144
|
- lib/paypal/payment/response/refund.rb
|
180
145
|
- lib/paypal/payment/response/ship_to.rb
|
181
146
|
- lib/paypal/util.rb
|
182
147
|
- paypal-express.gemspec
|
148
|
+
- spec/fake_response/CreateBillingAgreement/success.txt
|
183
149
|
- spec/fake_response/CreateRecurringPaymentsProfile/failure.txt
|
184
150
|
- spec/fake_response/CreateRecurringPaymentsProfile/success.txt
|
185
151
|
- spec/fake_response/DoExpressCheckoutPayment/failure.txt
|
186
152
|
- spec/fake_response/DoExpressCheckoutPayment/success.txt
|
153
|
+
- spec/fake_response/DoExpressCheckoutPayment/success_with_billing_agreement.txt
|
154
|
+
- spec/fake_response/DoReferenceTransaction/failure.txt
|
155
|
+
- spec/fake_response/DoReferenceTransaction/success.txt
|
187
156
|
- spec/fake_response/GetExpressCheckoutDetails/failure.txt
|
188
157
|
- spec/fake_response/GetExpressCheckoutDetails/success.txt
|
189
158
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|
@@ -228,33 +197,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
197
|
requirements:
|
229
198
|
- - ">="
|
230
199
|
- !ruby/object:Gem::Version
|
231
|
-
hash: 3
|
232
|
-
segments:
|
233
|
-
- 0
|
234
200
|
version: "0"
|
235
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
202
|
none: false
|
237
203
|
requirements:
|
238
204
|
- - ">="
|
239
205
|
- !ruby/object:Gem::Version
|
240
|
-
hash: 23
|
241
|
-
segments:
|
242
|
-
- 1
|
243
|
-
- 3
|
244
|
-
- 6
|
245
206
|
version: 1.3.6
|
246
207
|
requirements: []
|
247
208
|
|
248
209
|
rubyforge_project:
|
249
|
-
rubygems_version: 1.
|
210
|
+
rubygems_version: 1.8.5
|
250
211
|
signing_key:
|
251
212
|
specification_version: 3
|
252
213
|
summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods Payment.
|
253
214
|
test_files:
|
215
|
+
- spec/fake_response/CreateBillingAgreement/success.txt
|
254
216
|
- spec/fake_response/CreateRecurringPaymentsProfile/failure.txt
|
255
217
|
- spec/fake_response/CreateRecurringPaymentsProfile/success.txt
|
256
218
|
- spec/fake_response/DoExpressCheckoutPayment/failure.txt
|
257
219
|
- spec/fake_response/DoExpressCheckoutPayment/success.txt
|
220
|
+
- spec/fake_response/DoExpressCheckoutPayment/success_with_billing_agreement.txt
|
221
|
+
- spec/fake_response/DoReferenceTransaction/failure.txt
|
222
|
+
- spec/fake_response/DoReferenceTransaction/success.txt
|
258
223
|
- spec/fake_response/GetExpressCheckoutDetails/failure.txt
|
259
224
|
- spec/fake_response/GetExpressCheckoutDetails/success.txt
|
260
225
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|