Skip to content

Commit 366013c

Browse files
committed
Added Digital Goods Support - changes by mikian
1 parent 687f7b3 commit 366013c

File tree

5 files changed

+108
-3
lines changed

5 files changed

+108
-3
lines changed

lib/paypal/recurring/base.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def checkout
6363
:cancel_url,
6464
:currency,
6565
:description,
66-
:ipn_url
66+
:ipn_url,
67+
:item_category,
68+
:item_name,
69+
:item_amount,
70+
:item_quantity
6771
).merge(
6872
:payment_action => "Authorization",
6973
:no_shipping => 1,
@@ -132,7 +136,11 @@ def request_payment
132136
:description,
133137
:payer_id,
134138
:token,
135-
:reference
139+
:reference,
140+
:item_category,
141+
:item_name,
142+
:item_amount,
143+
:item_quantity
136144
).merge(:payment_action => "Sale")
137145
request.run(:payment, params)
138146
end
@@ -180,7 +188,11 @@ def create_recurring_profile
180188
:email,
181189
:trial_length,
182190
:trial_period,
183-
:trial_frequency
191+
:trial_frequency,
192+
:item_category,
193+
:item_name,
194+
:item_amount,
195+
:item_quantity
184196
)
185197
request.run(:create_profile, params)
186198
end

lib/paypal/recurring/request.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Request
5656
:cancel_url => "CANCELURL",
5757
:currency => ["PAYMENTREQUEST_0_CURRENCYCODE", "CURRENCYCODE"],
5858
:description => ["DESC", "PAYMENTREQUEST_0_DESC", "L_BILLINGAGREEMENTDESCRIPTION0"],
59+
:note => "NOTE",
60+
:item_category => "L_PAYMENTREQUEST_0_ITEMCATEGORY0",
61+
:item_name => "L_PAYMENTREQUEST_0_NAME0",
62+
:item_amount => "L_PAYMENTREQUEST_0_AMT0",
63+
:item_quantity => "L_PAYMENTREQUEST_0_QTY0",
5964
:email => "EMAIL",
6065
:failed => "MAXFAILEDPAYMENTS",
6166
:frequency => "BILLINGFREQUENCY",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- !ruby/struct:VCR::HTTPInteraction
3+
request: !ruby/struct:VCR::Request
4+
method: :post
5+
uri: https://api-3t.sandbox.paypal.com:443/nvp
6+
body: USER=seller_1308793919_biz_api1.simplesideias.com.br&PWD=1308793931&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31AzaB6TzXx5amObyEghjU13.0av2Y&VERSION=72.0&METHOD=UpdateRecurringPaymentsProfile
7+
headers:
8+
user-agent:
9+
- PayPal::Recurring/0.1.0
10+
content-type:
11+
- application/x-www-form-urlencoded
12+
response: !ruby/struct:VCR::Response
13+
status: !ruby/struct:VCR::ResponseStatus
14+
code: 200
15+
message: OK
16+
headers:
17+
date:
18+
- Mon, 27 Jun 2011 11:03:37 GMT
19+
server:
20+
- Apache
21+
content-length:
22+
- "933"
23+
content-type:
24+
- text/plain; charset=utf-8
25+
body: TIMESTAMP=2011%2d06%2d27T11%3a03%3a38Z&CORRELATIONID=cc5d656723747&ACK=Failure&VERSION=72%2e0&BUILD=1907759&L_ERRORCODE0=11585&L_ERRORCODE1=11518&L_ERRORCODE2=11516&L_ERRORCODE3=11519&L_ERRORCODE4=11549&L_SHORTMESSAGE0=Missing%20Token%20or%20payment%20source&L_SHORTMESSAGE1=Invalid%20billing%20period%2e&L_SHORTMESSAGE2=Invalid%20billing%20frequency&L_SHORTMESSAGE3=Invalid%20amount&L_SHORTMESSAGE4=Start%20Date%20is%20required&L_LONGMESSAGE0=Missing%20Token%20or%20buyer%20credit%20card&L_LONGMESSAGE1=Billing%20period%20must%20be%20one%20of%20Day%2c%20Week%2c%20SemiMonth%2c%20or%20Year&L_LONGMESSAGE2=Billing%20frequency%20must%20be%20%3e%200%20and%20be%20less%20than%20or%20equal%20to%20one%20year&L_LONGMESSAGE3=Bill%20amount%20must%20be%20greater%20than%200&L_LONGMESSAGE4=Subscription%20start%20date%20is%20required&L_SEVERITYCODE0=Error&L_SEVERITYCODE1=Error&L_SEVERITYCODE2=Error&L_SEVERITYCODE3=Error&L_SEVERITYCODE4=Error
26+
http_version: "1.1"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- !ruby/struct:VCR::HTTPInteraction
3+
request: !ruby/struct:VCR::Request
4+
method: :post
5+
uri: https://api-3t.sandbox.paypal.com:443/nvp
6+
body: USER=seller_1308793919_biz_api1.simplesideias.com.br&PWD=1308793931&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31AzaB6TzXx5amObyEghjU13.0av2Y&VERSION=72.0&PAYMENTREQUEST_0_AMT=9.00&AMT=9.00&PAYMENTREQUEST_0_CURRENCYCODE=USD&CURRENCYCODE=USD&DESC=Awesome%20-%20Monthly%20Subscription&PAYMENTREQUEST_0_DESC=Awesome%20-%20Monthly%20Subscription&L_BILLINGAGREEMENTDESCRIPTION0=Awesome%20-%20Monthly%20Subscription&PAYERID=WTTS5KC2T46YU&TOKEN=EC-2UK36172XH723314S&PROFILEREFERENCE=1234&PROFILESTARTDATE=2011-06-27T07%3a59%3a54Z&MAXFAILEDPAYMENTS=1&AUTOBILLOUTAMT=AddToNextBilling&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2fexample.com%2fpaypal%2fipn&NOTIFYURL=http%3a%2f%2fexample.com%2fpaypal%2fipn&BILLINGFREQUENCY=1&BILLINGPERIOD=Month&METHOD=UpdateRecurringPaymentsProfile
7+
headers:
8+
user-agent:
9+
- PayPal::Recurring/0.1.0
10+
content-type:
11+
- application/x-www-form-urlencoded
12+
response: !ruby/struct:VCR::Response
13+
status: !ruby/struct:VCR::ResponseStatus
14+
code: 200
15+
message: OK
16+
headers:
17+
date:
18+
- Mon, 27 Jun 2011 10:59:58 GMT
19+
server:
20+
- Apache
21+
content-length:
22+
- "162"
23+
content-type:
24+
- text/plain; charset=utf-8
25+
body: PROFILEID=I%2d89LD5VEHEVK4&PROFILESTATUS=ActiveProfile&TIMESTAMP=2011%2d06%2d27T11%3a00%3a01Z&CORRELATIONID=17ea90bec34e6&ACK=Success&VERSION=72%2e0&BUILD=1907759
26+
http_version: "1.1"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require "spec_helper"
2+
3+
describe PayPal::Recurring::Response::Profile do
4+
context "when successful" do
5+
use_vcr_cassette "update_profile/success"
6+
7+
subject {
8+
ppr = PayPal::Recurring.new({
9+
:amount => "19.00",
10+
:currency => "USD",
11+
:description => "Awesome - Monthly Subscription",
12+
:ipn_url => "http://example.com/paypal/ipn",
13+
:reference => "1234",
14+
:note => "Changed Plan",
15+
:profile_id => "I-89LD5VEHEVK4",
16+
:outstanding => :next_billing,
17+
:start_at => Time.now,
18+
})
19+
ppr.update_recurring_profile
20+
}
21+
22+
it { should be_valid }
23+
24+
its(:profile_id) { should == "I-89LD5VEHEVK4" }
25+
its(:status) { should == "ActiveProfile" }
26+
its(:errors) { should be_empty }
27+
end
28+
29+
context "when failure" do
30+
use_vcr_cassette("update_profile/failure")
31+
subject { PayPal::Recurring.new.create_recurring_profile }
32+
33+
it { should_not be_valid }
34+
its(:errors) { should have(5).items }
35+
end
36+
end

0 commit comments

Comments
 (0)