creative-paypal-express 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2623304761cdf500c82acefe85e8e626bbd306bb
4
- data.tar.gz: ba7be3ba0b865c979e3ad4de9272c670b7a6f1b4
3
+ metadata.gz: e3a1313ca1047f68a9801c63c2c0eae9aaf4bc9d
4
+ data.tar.gz: 4d9aeedc4d2692e2301079d42c7b3a8db94834ea
5
5
  SHA512:
6
- metadata.gz: b964a4a4906cb4ccfbd0a794e8a07e5995d2634709eda97692ba073fdbc3ef1f6b94bf4ade0a7d5f300b85d469d26397de4c5aebb4e9c7720f15cb8905f9471d
7
- data.tar.gz: f0ce0d81a873f140d567ad79743cdeb7d0d115f97d14028ca75212e9b8dd6b5301013b2ab96bdd3e0a930a6482f3e87331ca4bdc1479c1209bc929f7794c966b
6
+ metadata.gz: e942250f8683e6f2d07e8d1c140679fce166365c64082df09e120717b81608a1db38f0d0745ac75768d2276b46141a87a80b90bd7297aefef7a120737b335e0c
7
+ data.tar.gz: b3ebea5d48de225090e9ad354836b91f0bc65f12f55cd90f7ce0659e63f394becc6609af79cf8445f52016ef384b6087d0359a0c80bc96a9f2e366117a8b7106
@@ -0,0 +1,47 @@
1
+ ## v1.2.0
2
+ __Added:__
3
+ - Ability to amend a created paypal subscription (its amount)
4
+
5
+ ```rb
6
+ Paypal::Express::Request.new(params).amend!("profile_id", {amount: 19.95, note: "will show up in email and profile logs"})
7
+ ```
8
+
9
+ ## v1.1.0 news (not in wiki)
10
+ ### Paypal::Payment::Recurring
11
+ The helper object can be instantiated by using the :raw key.
12
+
13
+ ```rb
14
+ params = {
15
+ # optional initial payment parameters
16
+ :INITAMT => "9.00",
17
+ :FAILEDINITAMTACTION => "CancelOnFailure", # or "ContinueOnFailure"
18
+
19
+ # optional trial parameters
20
+ :TRIALBILLINGPERIOD => "Day",
21
+ :TRIALBILLINGFREQUENCY => "7",
22
+ :TRIALAMT => "0.00",
23
+ :TRIALCURRENCYCODE => "EUR",
24
+ :TRIALTOTALBILLINGCYCLES => "1",
25
+
26
+ # mandatory regular recurring profile parameters
27
+ :DESC => "Funny Movie Clips Subscription",
28
+ :PROFILESTARTDATE => "2017-01-25T15:00:00Z",
29
+ :BILLINGPERIOD => "Day", # "Month", "Year"
30
+ :BILLINGFREQUENCY => "30",
31
+ :AMT => "9.00", # two-decimals for cents, whole number for whole currency, like a Euro or Dollar
32
+ :CURRENCYCODE => "EUR",
33
+
34
+ # termination
35
+ :TOTALBILLINGCYCLES => "0", # optional field, '0' value makes profile last forever
36
+ :MAXFAILEDPAYMENTS => "3",
37
+ :AUTOBILLAMT => "AddToNextBilling",
38
+
39
+ # Digital goods fields
40
+ :L_PAYMENTREQUEST_0_ITEMCATEGORY0 => "Digital",
41
+ :L_PAYMENTREQUEST_0_NAME0 => "Cat Clip Collection",
42
+ :L_PAYMENTREQUEST_0_AMT0 => "9.00",
43
+ :L_PAYMENTREQUEST_0_QTY0 => "1",
44
+ }
45
+
46
+ recurring_profile = Paypal::Payment::Recurring.new(raw: params)
47
+ ```
data/README.md CHANGED
@@ -7,11 +7,9 @@ Express Checkout for Digital Goods is also supported.
7
7
  ## Installation
8
8
 
9
9
  ```rb
10
- gem "creative-paypal-express", "~> 1.0.0"
10
+ gem "creative-paypal-express", "~> 1.2.0"
11
11
  ```
12
12
 
13
- gem install paypal-express
14
-
15
13
  ## Usage
16
14
 
17
15
  See Wiki on Github
@@ -21,46 +19,6 @@ Play with Sample Rails App
21
19
  https://github.com/nov/paypal-express-sample
22
20
  https://paypal-express-sample.heroku.com
23
21
 
24
- ## v1.1.0 news (not in wiki)
25
- ### Paypal::Payment::Recurring
26
- The helper object can be instantiated by using the :raw key.
27
-
28
- ```rb
29
- params = {
30
- # optional initial payment parameters
31
- :INITAMT => "9.00",
32
- :FAILEDINITAMTACTION => "CancelOnFailure", # or "ContinueOnFailure"
33
-
34
- # optional trial parameters
35
- :TRIALBILLINGPERIOD => "Day",
36
- :TRIALBILLINGFREQUENCY => "7",
37
- :TRIALAMT => "0.00",
38
- :TRIALCURRENCYCODE => "EUR",
39
- :TRIALTOTALBILLINGCYCLES => "1",
40
-
41
- # mandatory regular recurring profile parameters
42
- :DESC => "Funny Movie Clips Subscription",
43
- :PROFILESTARTDATE => "2017-01-25T15:00:00Z",
44
- :BILLINGPERIOD => "Day", # "Month", "Year"
45
- :BILLINGFREQUENCY => "30",
46
- :AMT => "9.00", # two-decimals for cents, whole number for whole currency, like a Euro or Dollar
47
- :CURRENCYCODE => "EUR",
48
-
49
- # termination
50
- :TOTALBILLINGCYCLES => "0", # optional field, '0' value makes profile last forever
51
- :MAXFAILEDPAYMENTS => "3",
52
- :AUTOBILLAMT => "AddToNextBilling",
53
-
54
- # Digital goods fields
55
- :L_PAYMENTREQUEST_0_ITEMCATEGORY0 => "Digital",
56
- :L_PAYMENTREQUEST_0_NAME0 => "Cat Clip Collection",
57
- :L_PAYMENTREQUEST_0_AMT0 => "9.00",
58
- :L_PAYMENTREQUEST_0_QTY0 => "1",
59
- }
60
-
61
- recurring_profile = Paypal::Payment::Recurring.new(raw: params)
62
- ```
63
-
64
22
  ## Note on Patches/Pull Requests
65
23
 
66
24
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -127,6 +127,19 @@ module Paypal
127
127
  renew!(profile_id, :Reactivate, options)
128
128
  end
129
129
 
130
+ # Expects optional :note option and mandatory :amount option
131
+ def amend!(profile_id, options={})
132
+ # Developed according to https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECRecurringPayments/#modifying-a-recurring-payments-profile
133
+ # and https://developer.paypal.com/docs/classic/api/merchant/UpdateRecurringPaymentsProfile_API_Operation_NVP/
134
+ params = {
135
+ :PROFILEID => profile_id,
136
+ :NOTE => options[:note],
137
+ :AMT => options[:amount].presence || (raise ArgumentError.new(":amount option missing!")), # Paypal accepts 19.95 type decimals
138
+ }
139
+
140
+ response = request(:UpdateRecurringPaymentsProfile, params)
141
+ return Response.new(response)
142
+ end
130
143
 
131
144
  # Reference Transaction Specific
132
145
 
@@ -0,0 +1 @@
1
+ PROFILEID=I%2dK1VFLRN3VVG0&TIMESTAMP=2017%2d02%2d20T07%3a20%3a44Z&CORRELATIONID=86bde487ccba6&ACK=Success&VERSION=66%2e0&BUILD=1704252
@@ -1,5 +1,4 @@
1
- require 'spec_helper.rb'
2
-
1
+ # rspec spec/paypal/express/request_spec.rb
3
2
  describe Paypal::Express::Request do
4
3
  class Paypal::Express::Request
5
4
  attr_accessor :_sent_params_, :_method_
@@ -489,6 +488,27 @@ describe Paypal::Express::Request do
489
488
  end
490
489
  end
491
490
 
491
+ describe "#amend!(profile_id, options={})" do
492
+ it "should raise ArgumentError if :amount not passed" do
493
+ expect{instance.amend!('profile_id')}.to raise_error(ArgumentError, ":amount option missing!")
494
+ end
495
+
496
+ it "should call UpdateRecurringPaymentsProfile" do
497
+ expect{instance.amend!('profile_id', {note: "test changes", amount: 19.95})}.
498
+ to request_to(nvp_endpoint, :post)
499
+
500
+ expect(instance._method_).to eq :UpdateRecurringPaymentsProfile
501
+ expect(instance._sent_params_).to eq({:PROFILEID => 'profile_id', :NOTE => "test changes", :AMT => 19.95})
502
+ end
503
+
504
+ it 'should return Paypal::Express::Response' do
505
+ fake_response 'UpdateRecurringPaymentsProfile/success'
506
+ response = instance.amend!('profile_id', {note: "test changes", amount: 19.95})
507
+
508
+ expect(response.class).to eq Paypal::Express::Response
509
+ end
510
+ end
511
+
492
512
  describe '#agree!' do
493
513
  it 'should return Paypal::Express::Response' do
494
514
  fake_response 'CreateBillingAgreement/success'
@@ -50,6 +50,7 @@ def expected_recurring_profile_parameters(options={})
50
50
  # :TOTALBILLINGCYCLES => "0", # optional field, '0' value makes profile last forever
51
51
  # :MAXFAILEDPAYMENTS => "3",
52
52
  # :AUTOBILLAMT => "AddToNextBilling",
53
+ # :AUTOBILLOUTAMT => "AddToNextBilling",
53
54
  #
54
55
  # # Digital goods fields
55
56
  # :L_PAYMENTREQUEST_0_ITEMCATEGORY0 => "Digital",
@@ -94,10 +95,7 @@ def auxilary_profile_parameters(options={})
94
95
  :TOTALBILLINGCYCLES => "0", # optional field, '0' value makes profile last forever
95
96
  :MAXFAILEDPAYMENTS => "3",
96
97
  :AUTOBILLAMT => "AddToNextBilling",
98
+ :AUTOBILLOUTAMT => "AddToNextBilling",
97
99
 
98
- :L_PAYMENTREQUEST_0_ITEMCATEGORY0 => "Digital",
99
- :L_PAYMENTREQUEST_0_NAME0 => "Cat Clip Collection",
100
- :L_PAYMENTREQUEST_0_AMT0 => "9.00",
101
- :L_PAYMENTREQUEST_0_QTY0 => "1",
102
100
  }.merge(options)
103
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creative-paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-25 00:00:00.000000000 Z
12
+ date: 2017-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -136,6 +136,7 @@ files:
136
136
  - ".gitignore"
137
137
  - ".rspec"
138
138
  - ".travis.yml"
139
+ - CHANGELOG.md
139
140
  - Gemfile
140
141
  - LICENSE
141
142
  - README.md
@@ -196,6 +197,7 @@ files:
196
197
  - spec/fake_response/RefundTransaction/full.txt
197
198
  - spec/fake_response/SetExpressCheckout/failure.txt
198
199
  - spec/fake_response/SetExpressCheckout/success.txt
200
+ - spec/fake_response/UpdateRecurringPaymentsProfile/success.txt
199
201
  - spec/helpers/fake_response_helper.rb
200
202
  - spec/paypal/exception/api_error_spec.rb
201
203
  - spec/paypal/exception/http_error_spec.rb
@@ -270,6 +272,7 @@ test_files:
270
272
  - spec/fake_response/RefundTransaction/full.txt
271
273
  - spec/fake_response/SetExpressCheckout/failure.txt
272
274
  - spec/fake_response/SetExpressCheckout/success.txt
275
+ - spec/fake_response/UpdateRecurringPaymentsProfile/success.txt
273
276
  - spec/helpers/fake_response_helper.rb
274
277
  - spec/paypal/exception/api_error_spec.rb
275
278
  - spec/paypal/exception/http_error_spec.rb