paypal-express 0.4.0.alpha → 0.4.0
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.
- data/VERSION +1 -1
- data/lib/paypal/express/request.rb +18 -1
- data/lib/paypal/nvp/response.rb +4 -1
- data/lib/paypal/payment/response/reference.rb +1 -0
- data/spec/fake_response/BillAgreementUpdate/fetch.txt +1 -0
- data/spec/fake_response/BillAgreementUpdate/revoke.txt +1 -0
- data/spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt +1 -0
- data/spec/paypal/express/request_spec.rb +51 -15
- data/spec/paypal/nvp/response_spec.rb +11 -0
- metadata +9 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.0
|
1
|
+
0.4.0
|
@@ -68,7 +68,7 @@ module Paypal
|
|
68
68
|
response = self.request :ManageRecurringPaymentsProfileStatus, params
|
69
69
|
Response.new response
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def suspend!(profile_id, options = {})
|
73
73
|
renew!(profile_id, :Suspend, options)
|
74
74
|
end
|
@@ -95,6 +95,14 @@ module Paypal
|
|
95
95
|
Response.new response
|
96
96
|
end
|
97
97
|
|
98
|
+
def agreement(reference_id)
|
99
|
+
params = {
|
100
|
+
:REFERENCEID => reference_id,
|
101
|
+
}
|
102
|
+
response = self.request :BillAgreementUpdate, params
|
103
|
+
Response.new response
|
104
|
+
end
|
105
|
+
|
98
106
|
def charge!(reference_id, amount, options = {})
|
99
107
|
params = {
|
100
108
|
:REFERENCEID => reference_id,
|
@@ -108,6 +116,15 @@ module Paypal
|
|
108
116
|
Response.new response
|
109
117
|
end
|
110
118
|
|
119
|
+
def revoke!(reference_id)
|
120
|
+
params = {
|
121
|
+
:REFERENCEID => reference_id,
|
122
|
+
:BillingAgreementStatus => :Canceled
|
123
|
+
}
|
124
|
+
response = self.request :BillAgreementUpdate, params
|
125
|
+
Response.new response
|
126
|
+
end
|
127
|
+
|
111
128
|
|
112
129
|
# Refund Specific
|
113
130
|
|
data/lib/paypal/nvp/response.rb
CHANGED
@@ -6,6 +6,7 @@ module Paypal
|
|
6
6
|
:ACK => :ack,
|
7
7
|
:ADDRESSSTATUS => :address_status,
|
8
8
|
:BUILD => :build,
|
9
|
+
:BILLINGAGREEMENTACCEPTEDSTATUS => :billing_agreement_accepted_status,
|
9
10
|
:CHECKOUTSTATUS => :checkout_status,
|
10
11
|
:CORRELATIONID => :colleration_id,
|
11
12
|
:COUNTRYCODE => :country_code,
|
@@ -111,7 +112,9 @@ module Paypal
|
|
111
112
|
end
|
112
113
|
if attrs[:BILLINGAGREEMENTID]
|
113
114
|
@billing_agreement = Payment::Response::Reference.new(
|
114
|
-
:identifier => attrs.delete(:BILLINGAGREEMENTID)
|
115
|
+
:identifier => attrs.delete(:BILLINGAGREEMENTID),
|
116
|
+
:description => attrs.delete(:BILLINGAGREEMENTDESCRIPTION),
|
117
|
+
:status => attrs.delete(:BILLINGAGREEMENTSTATUS)
|
115
118
|
)
|
116
119
|
billing_agreement_info = Payment::Response::Info.attribute_mapping.keys.inject({}) do |billing_agreement_info, key|
|
117
120
|
billing_agreement_info.merge! key => attrs.delete(key)
|
@@ -0,0 +1 @@
|
|
1
|
+
BILLINGAGREEMENTID=B%2d8XW15926RT2253736&BILLINGAGREEMENTDESCRIPTION=Reference%20Payment%20Agreement&BILLINGAGREEMENTSTATUS=Canceled&TIMESTAMP=2011%2d08%2d06T09%3a47%3a41Z&CORRELATIONID=28e5a24b3ea98&ACK=Success&VERSION=78%2e0&BUILD=2020243&EMAIL=client_1305381804_per%40matake%2ejp&PAYERID=CMJLWADKVFQYJ&PAYERSTATUS=verified&FIRSTNAME=Test&LASTNAME=User&COUNTRYCODE=US
|
@@ -0,0 +1 @@
|
|
1
|
+
BILLINGAGREEMENTID=B%2d8XW15926RT2253736&BILLINGAGREEMENTDESCRIPTION=Reference%20Payment%20Agreement&BILLINGAGREEMENTSTATUS=Canceled&TIMESTAMP=2011%2d08%2d06T09%3a47%3a41Z&CORRELATIONID=28e5a24b3ea98&ACK=Success&VERSION=78%2e0&BUILD=2020243&EMAIL=client_1305381804_per%40matake%2ejp&PAYERID=CMJLWADKVFQYJ&PAYERSTATUS=verified&FIRSTNAME=Test&LASTNAME=User&COUNTRYCODE=US
|
@@ -0,0 +1 @@
|
|
1
|
+
TOKEN=EC%2d4D299105F9409730D&BILLINGAGREEMENTACCEPTEDSTATUS=1&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2011%2d08%2d08T01%3a56%3a13Z&CORRELATIONID=53a48e61dfca7&ACK=Success&VERSION=78%2e0&BUILD=2020243&EMAIL=client_1305381804_per%40matake%2ejp&PAYERID=CMJLWADKVFQYJ&PAYERSTATUS=verified&FIRSTNAME=Test&LASTNAME=User&COUNTRYCODE=US&CURRENCYCODE=JPY&AMT=0&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&INSURANCEAMT=0&SHIPDISCAMT=0&PAYMENTREQUEST_0_CURRENCYCODE=JPY&PAYMENTREQUEST_0_AMT=0&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUESTINFO_0_ERRORCODE=0
|
@@ -325,39 +325,38 @@ describe Paypal::Express::Request do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
|
-
describe '#
|
328
|
+
describe '#agree!' do
|
329
329
|
it 'should return Paypal::Express::Response' do
|
330
|
-
fake_response '
|
331
|
-
response = instance.
|
330
|
+
fake_response 'CreateBillingAgreement/success'
|
331
|
+
response = instance.agree! 'token'
|
332
332
|
response.should be_instance_of Paypal::Express::Response
|
333
333
|
end
|
334
334
|
|
335
|
-
it 'should call
|
335
|
+
it 'should call CreateBillingAgreement' do
|
336
336
|
expect do
|
337
|
-
instance.
|
337
|
+
instance.agree! 'token'
|
338
338
|
end.should request_to nvp_endpoint, :post
|
339
|
-
instance._method_.should == :
|
339
|
+
instance._method_.should == :CreateBillingAgreement
|
340
340
|
instance._sent_params_.should == {
|
341
|
-
:
|
342
|
-
:REFUNDTYPE => :Full
|
341
|
+
:TOKEN => 'token'
|
343
342
|
}
|
344
343
|
end
|
345
344
|
end
|
346
345
|
|
347
|
-
describe '#
|
346
|
+
describe '#agreement' do
|
348
347
|
it 'should return Paypal::Express::Response' do
|
349
|
-
fake_response '
|
350
|
-
response = instance.
|
348
|
+
fake_response 'BillAgreementUpdate/fetch'
|
349
|
+
response = instance.agreement 'reference_id'
|
351
350
|
response.should be_instance_of Paypal::Express::Response
|
352
351
|
end
|
353
352
|
|
354
|
-
it 'should call
|
353
|
+
it 'should call BillAgreementUpdate' do
|
355
354
|
expect do
|
356
|
-
instance.
|
355
|
+
instance.agreement 'reference_id'
|
357
356
|
end.should request_to nvp_endpoint, :post
|
358
|
-
instance._method_.should == :
|
357
|
+
instance._method_.should == :BillAgreementUpdate
|
359
358
|
instance._sent_params_.should == {
|
360
|
-
:
|
359
|
+
:REFERENCEID => 'reference_id'
|
361
360
|
}
|
362
361
|
end
|
363
362
|
end
|
@@ -383,4 +382,41 @@ describe Paypal::Express::Request do
|
|
383
382
|
end
|
384
383
|
end
|
385
384
|
|
385
|
+
describe '#revoke!' do
|
386
|
+
it 'should return Paypal::Express::Response' do
|
387
|
+
fake_response 'BillAgreementUpdate/revoke'
|
388
|
+
response = instance.revoke! 'reference_id'
|
389
|
+
response.should be_instance_of Paypal::Express::Response
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'should call BillAgreementUpdate' do
|
393
|
+
expect do
|
394
|
+
instance.revoke! 'reference_id'
|
395
|
+
end.should request_to nvp_endpoint, :post
|
396
|
+
instance._method_.should == :BillAgreementUpdate
|
397
|
+
instance._sent_params_.should == {
|
398
|
+
:REFERENCEID => 'reference_id',
|
399
|
+
:BillingAgreementStatus => :Canceled
|
400
|
+
}
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
describe '#refund!' do
|
405
|
+
it 'should return Paypal::Express::Response' do
|
406
|
+
fake_response 'RefundTransaction/full'
|
407
|
+
response = instance.refund! 'transaction_id'
|
408
|
+
response.should be_instance_of Paypal::Express::Response
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'should call RefundTransaction' do
|
412
|
+
expect do
|
413
|
+
instance.refund! 'transaction_id'
|
414
|
+
end.should request_to nvp_endpoint, :post
|
415
|
+
instance._method_.should == :RefundTransaction
|
416
|
+
instance._sent_params_.should == {
|
417
|
+
:TRANSACTIONID => 'transaction_id',
|
418
|
+
:REFUNDTYPE => :Full
|
419
|
+
}
|
420
|
+
end
|
421
|
+
end
|
386
422
|
end
|
@@ -67,6 +67,17 @@ describe Paypal::NVP::Response do
|
|
67
67
|
response.payment_info.size.should == 0
|
68
68
|
response.payment_responses.first.should be_instance_of(Paypal::Payment::Response)
|
69
69
|
end
|
70
|
+
|
71
|
+
context 'when BILLINGAGREEMENTACCEPTEDSTATUS included' do
|
72
|
+
before do
|
73
|
+
fake_response 'GetExpressCheckoutDetails/with_billing_accepted_status'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should handle all attributes' do
|
77
|
+
Paypal.logger.should_not_receive(:warn)
|
78
|
+
response = request.details 'token'
|
79
|
+
end
|
80
|
+
end
|
70
81
|
end
|
71
82
|
|
72
83
|
context 'when DoExpressCheckoutPayment response given' do
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-express
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.4.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- nov matake
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-08 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -145,6 +145,8 @@ files:
|
|
145
145
|
- lib/paypal/payment/response/ship_to.rb
|
146
146
|
- lib/paypal/util.rb
|
147
147
|
- paypal-express.gemspec
|
148
|
+
- spec/fake_response/BillAgreementUpdate/fetch.txt
|
149
|
+
- spec/fake_response/BillAgreementUpdate/revoke.txt
|
148
150
|
- spec/fake_response/CreateBillingAgreement/success.txt
|
149
151
|
- spec/fake_response/CreateRecurringPaymentsProfile/failure.txt
|
150
152
|
- spec/fake_response/CreateRecurringPaymentsProfile/success.txt
|
@@ -155,6 +157,7 @@ files:
|
|
155
157
|
- spec/fake_response/DoReferenceTransaction/success.txt
|
156
158
|
- spec/fake_response/GetExpressCheckoutDetails/failure.txt
|
157
159
|
- spec/fake_response/GetExpressCheckoutDetails/success.txt
|
160
|
+
- spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt
|
158
161
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|
159
162
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt
|
160
163
|
- spec/fake_response/IPN/invalid.txt
|
@@ -212,6 +215,8 @@ signing_key:
|
|
212
215
|
specification_version: 3
|
213
216
|
summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods Payment.
|
214
217
|
test_files:
|
218
|
+
- spec/fake_response/BillAgreementUpdate/fetch.txt
|
219
|
+
- spec/fake_response/BillAgreementUpdate/revoke.txt
|
215
220
|
- spec/fake_response/CreateBillingAgreement/success.txt
|
216
221
|
- spec/fake_response/CreateRecurringPaymentsProfile/failure.txt
|
217
222
|
- spec/fake_response/CreateRecurringPaymentsProfile/success.txt
|
@@ -222,6 +227,7 @@ test_files:
|
|
222
227
|
- spec/fake_response/DoReferenceTransaction/success.txt
|
223
228
|
- spec/fake_response/GetExpressCheckoutDetails/failure.txt
|
224
229
|
- spec/fake_response/GetExpressCheckoutDetails/success.txt
|
230
|
+
- spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt
|
225
231
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|
226
232
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt
|
227
233
|
- spec/fake_response/IPN/invalid.txt
|