paypal-payment 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Guardfile +24 -0
- data/README.rdoc +107 -0
- data/Rakefile +5 -0
- data/docs/AdaptivePayments.rdoc +84 -0
- data/docs/PP_NVPAPI_DeveloperGuide.pdf +0 -0
- data/docs/PP_WPP_IntegrationGuide.pdf +0 -0
- data/docs/adaptive_payments.md +55 -0
- data/docs/api.txt +67 -0
- data/docs/design.txt +38 -0
- data/docs/express_checkout.md +172 -0
- data/docs/requirements.txt +32 -0
- data/lib/paypal-payment.rb +10 -0
- data/lib/paypal/adaptive_payments.rb +31 -0
- data/lib/paypal/adaptive_payments/api.rb +51 -0
- data/lib/paypal/adaptive_payments/base.rb +11 -0
- data/lib/paypal/adaptive_payments/client_details.rb +14 -0
- data/lib/paypal/adaptive_payments/display_options.rb +10 -0
- data/lib/paypal/adaptive_payments/funding_constraint.rb +11 -0
- data/lib/paypal/adaptive_payments/funding_type_info.rb +8 -0
- data/lib/paypal/adaptive_payments/funding_type_list.rb +11 -0
- data/lib/paypal/adaptive_payments/initiating_entity.rb +11 -0
- data/lib/paypal/adaptive_payments/institution_customer.rb +13 -0
- data/lib/paypal/adaptive_payments/invoice_data.rb +13 -0
- data/lib/paypal/adaptive_payments/invoice_item.rb +11 -0
- data/lib/paypal/adaptive_payments/payment.rb +105 -0
- data/lib/paypal/adaptive_payments/payment_info.rb +18 -0
- data/lib/paypal/adaptive_payments/payment_info_list.rb +11 -0
- data/lib/paypal/adaptive_payments/payment_options.rb +39 -0
- data/lib/paypal/adaptive_payments/phone.rb +9 -0
- data/lib/paypal/adaptive_payments/preapproval.rb +52 -0
- data/lib/paypal/adaptive_payments/receiver.rb +17 -0
- data/lib/paypal/adaptive_payments/receiver_list.rb +49 -0
- data/lib/paypal/adaptive_payments/receiver_options.rb +19 -0
- data/lib/paypal/adaptive_payments/request.rb +51 -0
- data/lib/paypal/adaptive_payments/response.rb +38 -0
- data/lib/paypal/adaptive_payments/response/address.rb +13 -0
- data/lib/paypal/adaptive_payments/response/address_list.rb +11 -0
- data/lib/paypal/adaptive_payments/response/base_address.rb +13 -0
- data/lib/paypal/adaptive_payments/response/details.rb +19 -0
- data/lib/paypal/adaptive_payments/response/error_list.rb +15 -0
- data/lib/paypal/adaptive_payments/response/pay.rb +31 -0
- data/lib/paypal/adaptive_payments/response/pay_error.rb +16 -0
- data/lib/paypal/adaptive_payments/response/pay_error_list.rb +15 -0
- data/lib/paypal/adaptive_payments/response/pay_options.rb +7 -0
- data/lib/paypal/adaptive_payments/response/preapproval.rb +47 -0
- data/lib/paypal/adaptive_payments/response/refund.rb +16 -0
- data/lib/paypal/adaptive_payments/response/refund_info.rb +24 -0
- data/lib/paypal/adaptive_payments/response/refund_info_list.rb +11 -0
- data/lib/paypal/adaptive_payments/response/shipping_address.rb +11 -0
- data/lib/paypal/adaptive_payments/sender_identifier.rb +7 -0
- data/lib/paypal/adaptive_payments/sender_options.rb +8 -0
- data/lib/paypal/api.rb +94 -0
- data/lib/paypal/cacert.pem +3987 -0
- data/lib/paypal/common.rb +11 -0
- data/lib/paypal/common/base.rb +83 -0
- data/lib/paypal/common/error_data.rb +15 -0
- data/lib/paypal/common/request.rb +45 -0
- data/lib/paypal/common/request_envelope.rb +13 -0
- data/lib/paypal/common/response.rb +34 -0
- data/lib/paypal/common/response_envelope.rb +19 -0
- data/lib/paypal/express_checkout.rb +19 -0
- data/lib/paypal/express_checkout/account.rb +16 -0
- data/lib/paypal/express_checkout/api.rb +43 -0
- data/lib/paypal/express_checkout/base.rb +37 -0
- data/lib/paypal/express_checkout/billing.rb +7 -0
- data/lib/paypal/express_checkout/callback.rb +17 -0
- data/lib/paypal/express_checkout/checkout.rb +144 -0
- data/lib/paypal/express_checkout/fields.rb +449 -0
- data/lib/paypal/express_checkout/fmf.rb +7 -0
- data/lib/paypal/express_checkout/payment.rb +76 -0
- data/lib/paypal/express_checkout/payment_item.rb +7 -0
- data/lib/paypal/express_checkout/recurring.rb +131 -0
- data/lib/paypal/express_checkout/request.rb +212 -0
- data/lib/paypal/express_checkout/response.rb +52 -0
- data/lib/paypal/express_checkout/response/account.rb +30 -0
- data/lib/paypal/express_checkout/response/address.rb +29 -0
- data/lib/paypal/express_checkout/response/authorization.rb +25 -0
- data/lib/paypal/express_checkout/response/base.rb +125 -0
- data/lib/paypal/express_checkout/response/callback_request.rb +10 -0
- data/lib/paypal/express_checkout/response/callback_response.rb +8 -0
- data/lib/paypal/express_checkout/response/capture.rb +14 -0
- data/lib/paypal/express_checkout/response/checkout.rb +11 -0
- data/lib/paypal/express_checkout/response/details.rb +35 -0
- data/lib/paypal/express_checkout/response/manage_profile.rb +9 -0
- data/lib/paypal/express_checkout/response/notification.rb +85 -0
- data/lib/paypal/express_checkout/response/payment.rb +24 -0
- data/lib/paypal/express_checkout/response/profile.rb +58 -0
- data/lib/paypal/express_checkout/response/reference.rb +11 -0
- data/lib/paypal/express_checkout/response/refund.rb +13 -0
- data/lib/paypal/express_checkout/response/search.rb +33 -0
- data/lib/paypal/express_checkout/response/transaction_details.rb +11 -0
- data/lib/paypal/express_checkout/shipping_option.rb +7 -0
- data/lib/paypal/express_checkout/utils.rb +26 -0
- data/lib/paypal/express_checkout/version.rb +10 -0
- data/lib/paypal/invoice.rb +22 -0
- data/lib/paypal/invoice/api.rb +51 -0
- data/lib/paypal/invoice/base.rb +11 -0
- data/lib/paypal/invoice/base_address.rb +11 -0
- data/lib/paypal/invoice/business_info.rb +17 -0
- data/lib/paypal/invoice/date_range.rb +8 -0
- data/lib/paypal/invoice/invoice.rb +117 -0
- data/lib/paypal/invoice/invoice_details.rb +38 -0
- data/lib/paypal/invoice/invoice_item.rb +13 -0
- data/lib/paypal/invoice/invoice_item_list.rb +10 -0
- data/lib/paypal/invoice/invoice_summary.rb +22 -0
- data/lib/paypal/invoice/invoice_summary_list.rb +10 -0
- data/lib/paypal/invoice/other_payment_details.rb +13 -0
- data/lib/paypal/invoice/payment_details.rb +16 -0
- data/lib/paypal/invoice/paypal_payment_details.rb +11 -0
- data/lib/paypal/invoice/request.rb +43 -0
- data/lib/paypal/invoice/response.rb +27 -0
- data/lib/paypal/invoice/response/details.rb +23 -0
- data/lib/paypal/invoice/response/invoice.rb +10 -0
- data/lib/paypal/invoice/response/search.rb +15 -0
- data/lib/paypal/invoice/search.rb +19 -0
- data/lib/paypal/invoice/search_parameters.rb +20 -0
- data/lib/paypal/permissions.rb +12 -0
- data/lib/paypal/permissions/api.rb +60 -0
- data/lib/paypal/permissions/base.rb +11 -0
- data/lib/paypal/permissions/permission.rb +33 -0
- data/lib/paypal/permissions/personal_data.rb +17 -0
- data/lib/paypal/permissions/request.rb +52 -0
- data/lib/paypal/permissions/response.rb +24 -0
- data/lib/paypal/permissions/response/permission.rb +14 -0
- data/lib/paypal/permissions/response/personal_data.rb +8 -0
- data/lib/paypal/permissions/response/token.rb +10 -0
- data/lib/paypal/permissions/token.rb +13 -0
- data/lib/paypal/recurring.rb +110 -0
- data/lib/paypal/request.rb +82 -0
- data/lib/paypal/version.rb +8 -0
- data/paypal-payment.gemspec +30 -0
- data/spec/fixtures/adaptive_payments/payment/create/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/create/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/details/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/payment/pay/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/pay/preapproval.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/pay/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/pay/with_pay_key.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/refund/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/refund/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/shipping_addresses/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/payment_options/get/success.yml +174 -0
- data/spec/fixtures/adaptive_payments/payment_options/set/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/preapproval/create/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/preapproval/details/success.yml +168 -0
- data/spec/fixtures/express_checkout/account/balance/success.yml +32 -0
- data/spec/fixtures/express_checkout/account/pal_details/success.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/checkout/sales/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/checkout/success.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/details/failure.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/details/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/pay/sales/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/pay/success.yml +61 -0
- data/spec/fixtures/express_checkout/payment/details/failure.yml +32 -0
- data/spec/fixtures/express_checkout/payment/details/success.yml +32 -0
- data/spec/fixtures/express_checkout/payment/refund/failure.yml +32 -0
- data/spec/fixtures/express_checkout/payment/refund/success.yml +32 -0
- data/spec/fixtures/express_checkout/payment/search/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/cancel/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/cancel/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/checkout/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/create_profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/create_profile/success.yml +61 -0
- data/spec/fixtures/express_checkout/recurring/profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/profile/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/reactivate/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/reactivate/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/suspend/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/suspend/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/profile.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/success.yml +32 -0
- data/spec/fixtures/invoice/cancel/success.yml +174 -0
- data/spec/fixtures/invoice/create/failure.yml +62 -0
- data/spec/fixtures/invoice/create/success.yml +60 -0
- data/spec/fixtures/invoice/create_and_send/failure.yml +62 -0
- data/spec/fixtures/invoice/create_and_send/success.yml +60 -0
- data/spec/fixtures/invoice/details/success.yml +117 -0
- data/spec/fixtures/invoice/mark_as_paid/failure.yml +180 -0
- data/spec/fixtures/invoice/mark_as_paid/success.yml +174 -0
- data/spec/fixtures/invoice/mark_as_refunded/success.yml +174 -0
- data/spec/fixtures/invoice/mark_as_unpaid/success.yml +231 -0
- data/spec/fixtures/invoice/search/success.yml +174 -0
- data/spec/fixtures/invoice/send/success.yml +117 -0
- data/spec/fixtures/invoice/update/failure.yml +119 -0
- data/spec/fixtures/invoice/update/success.yml +117 -0
- data/spec/fixtures/ipn/express_checkout.json +35 -0
- data/spec/fixtures/ipn/recurring_payment.json +44 -0
- data/spec/fixtures/ipn/recurring_payment_profile_created.json +31 -0
- data/spec/fixtures/ipn/recurring_payment_profile_created_with_initial_amount.json +33 -0
- data/spec/fixtures/ipn/recurring_payment_skipped.json +30 -0
- data/spec/fixtures/ipn/recurring_payment_with_initial_amount.json +44 -0
- data/spec/fixtures/notification/failure.yml +50 -0
- data/spec/fixtures/notification/success.yml +50 -0
- data/spec/paypal/adaptive_payments/api_spec.rb +20 -0
- data/spec/paypal/adaptive_payments/payment/base_spec.rb +28 -0
- data/spec/paypal/adaptive_payments/payment/create_spec.rb +63 -0
- data/spec/paypal/adaptive_payments/payment/details_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/payment/pay_spec.rb +97 -0
- data/spec/paypal/adaptive_payments/payment/refund_spec.rb +49 -0
- data/spec/paypal/adaptive_payments/payment/shipping_addresses_spec.rb +30 -0
- data/spec/paypal/adaptive_payments/payment_options/get_spec.rb +33 -0
- data/spec/paypal/adaptive_payments/payment_options/set_spec.rb +66 -0
- data/spec/paypal/adaptive_payments/preapproval/cancel_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/preapproval/create_spec.rb +39 -0
- data/spec/paypal/adaptive_payments/preapproval/details_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/request_spec.rb +48 -0
- data/spec/paypal/api_spec.rb +78 -0
- data/spec/paypal/common/base_spec.rb +157 -0
- data/spec/paypal/common/error_data_spec.rb +0 -0
- data/spec/paypal/common/request_envelope_spec.rb +6 -0
- data/spec/paypal/common/response_spec.rb +0 -0
- data/spec/paypal/express_checkout/account/balance_spec.rb +25 -0
- data/spec/paypal/express_checkout/account/pal_details_spec.rb +20 -0
- data/spec/paypal/express_checkout/checkout/checkout_spec.rb +73 -0
- data/spec/paypal/express_checkout/checkout/details_spec.rb +70 -0
- data/spec/paypal/express_checkout/checkout/pay_spec.rb +68 -0
- data/spec/paypal/express_checkout/fields_spec.rb +138 -0
- data/spec/paypal/express_checkout/payment/refund_spec.rb +34 -0
- data/spec/paypal/express_checkout/payment/search_spec.rb +24 -0
- data/spec/paypal/express_checkout/payment/transaction_details_spec.rb +30 -0
- data/spec/paypal/express_checkout/payment_spec.rb +13 -0
- data/spec/paypal/express_checkout/recurring/create_profile_spec.rb +50 -0
- data/spec/paypal/express_checkout/recurring/manage_profile_spec.rb +62 -0
- data/spec/paypal/express_checkout/recurring/profile_spec.rb +44 -0
- data/spec/paypal/express_checkout/recurring/update_profile_spec.rb +50 -0
- data/spec/paypal/express_checkout/request_spec.rb +221 -0
- data/spec/paypal/express_checkout/response/account_spec.rb +33 -0
- data/spec/paypal/express_checkout/response/base_spec.rb +253 -0
- data/spec/paypal/invoice/cancel_spec.rb +38 -0
- data/spec/paypal/invoice/create_and_send_spec.rb +58 -0
- data/spec/paypal/invoice/create_spec.rb +58 -0
- data/spec/paypal/invoice/details_spec.rb +39 -0
- data/spec/paypal/invoice/mark_as_paid_spec.rb +75 -0
- data/spec/paypal/invoice/mark_as_refunded_spec.rb +47 -0
- data/spec/paypal/invoice/mark_as_unpaid_spec.rb +43 -0
- data/spec/paypal/invoice/search_spec.rb +70 -0
- data/spec/paypal/invoice/send_spec.rb +48 -0
- data/spec/paypal/invoice/update_spec.rb +72 -0
- data/spec/paypal/request_spec.rb +45 -0
- data/spec/spec_helper.rb +35 -0
- metadata +546 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include PayPal::ExpressCheckout
|
4
|
+
|
5
|
+
describe PayPal::ExpressCheckout::Payment do
|
6
|
+
describe "#search" do
|
7
|
+
context "when successful" do
|
8
|
+
use_vcr_cassette "express_checkout/payment/search/success"#, :record => :all
|
9
|
+
let(:payment) {
|
10
|
+
PayPal::ExpressCheckout::Payment.new(
|
11
|
+
:start_date => Date.today << 1,
|
12
|
+
:currency => 'USD'
|
13
|
+
)
|
14
|
+
}
|
15
|
+
|
16
|
+
subject { payment.search }
|
17
|
+
|
18
|
+
it { should be_valid }
|
19
|
+
it { should be_success }
|
20
|
+
|
21
|
+
its(:payments) { should_not be_empty }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Payment do
|
4
|
+
describe "#details" do
|
5
|
+
context "when successful" do
|
6
|
+
use_vcr_cassette "express_checkout/payment/details/success"
|
7
|
+
let(:transaction_id) { "14R798164A671130B" }
|
8
|
+
let(:payment) { PayPal::ExpressCheckout::Payment.new(:transaction_id => transaction_id) }
|
9
|
+
|
10
|
+
subject { payment.details }
|
11
|
+
|
12
|
+
its(:valid?) { should be_true }
|
13
|
+
its(:errors) { should be_empty }
|
14
|
+
its(:payment_items) { should have(2).item }
|
15
|
+
it "should have the correct items" do
|
16
|
+
subject.payment_items.first.amount.should eql("1150.00")
|
17
|
+
subject.payment_items.last.amount.should eql("1350.00")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when failure" do
|
22
|
+
use_vcr_cassette "express_checkout/payment/details/failure"
|
23
|
+
let(:payment) { PayPal::ExpressCheckout::Payment.new(:transaction_id => "aaa") }
|
24
|
+
|
25
|
+
subject { payment.details }
|
26
|
+
|
27
|
+
its(:errors) { should have(1).items }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Payment do
|
4
|
+
let(:payment) { PayPal::ExpressCheckout::Payment.new }
|
5
|
+
|
6
|
+
describe "methods" do
|
7
|
+
subject { payment.methods }
|
8
|
+
|
9
|
+
[:amount, :shipping_amount, :tax_amount].each do |field|
|
10
|
+
it { should include(field) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Recurring do
|
4
|
+
describe "#create_profile" do
|
5
|
+
context "when successful" do
|
6
|
+
use_vcr_cassette "express_checkout/recurring/create_profile/success"
|
7
|
+
|
8
|
+
let(:token) { "EC-2EV77664BK856305S" }
|
9
|
+
let(:payer_id) {
|
10
|
+
rco = PayPal::ExpressCheckout::Checkout.new(:token => token)
|
11
|
+
rco.details.payer_id
|
12
|
+
}
|
13
|
+
|
14
|
+
subject {
|
15
|
+
ppr = PayPal::ExpressCheckout::Recurring.new({
|
16
|
+
:amount => "9.00",
|
17
|
+
:initial_amount => "9.00",
|
18
|
+
:failed_initial_action => :cancel,
|
19
|
+
:currency => "USD",
|
20
|
+
:description => "Awesome - Monthly Subscription",
|
21
|
+
:frequency => 1,
|
22
|
+
:token => token,
|
23
|
+
:period => :monthly,
|
24
|
+
:reference => "1234",
|
25
|
+
:payer_id => payer_id,
|
26
|
+
:start_at => Time.now,
|
27
|
+
:max_failed_payments => 1,
|
28
|
+
:auto_bill_outstanding => :next_billing
|
29
|
+
})
|
30
|
+
|
31
|
+
ppr.create_profile
|
32
|
+
}
|
33
|
+
|
34
|
+
it { should be_valid }
|
35
|
+
|
36
|
+
its(:profile_id) { should eql("I-3LJF616J1FB7") }
|
37
|
+
its(:profile_status) { should eql("PendingProfile") }
|
38
|
+
its(:errors) { should be_empty }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when failure" do
|
42
|
+
use_vcr_cassette "express_checkout/recurring/create_profile/failure"
|
43
|
+
|
44
|
+
subject { PayPal::ExpressCheckout::Recurring.new.create_profile }
|
45
|
+
|
46
|
+
it { should_not be_valid }
|
47
|
+
its(:errors) { should have(5).items }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Response::ManageProfile do
|
4
|
+
let(:paypal) { PayPal::ExpressCheckout::Recurring.new(:profile_id => "I-1RFWFFS16BF4") }
|
5
|
+
|
6
|
+
context "suspending" do
|
7
|
+
context "when successful" do
|
8
|
+
use_vcr_cassette "express_checkout/recurring/suspend/success"
|
9
|
+
subject { paypal.suspend }
|
10
|
+
|
11
|
+
it { should be_success }
|
12
|
+
it { should be_valid }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when failure" do
|
16
|
+
use_vcr_cassette "express_checkout/recurring/suspend/failure"
|
17
|
+
subject { paypal.suspend }
|
18
|
+
|
19
|
+
it { should_not be_success }
|
20
|
+
it { should_not be_valid }
|
21
|
+
its(:errors) { should have(1).item }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "reactivating" do
|
26
|
+
context "when successful" do
|
27
|
+
use_vcr_cassette "express_checkout/recurring/reactivate/success"
|
28
|
+
subject { paypal.reactivate }
|
29
|
+
|
30
|
+
it { should be_success }
|
31
|
+
it { should be_valid }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when failure" do
|
35
|
+
use_vcr_cassette "express_checkout/recurring/reactivate/failure"
|
36
|
+
subject { paypal.reactivate }
|
37
|
+
|
38
|
+
it { should_not be_success }
|
39
|
+
it { should_not be_valid }
|
40
|
+
its(:errors) { should have(1).item }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "cancelling" do
|
45
|
+
context "when successful" do
|
46
|
+
use_vcr_cassette "express_checkout/recurring/cancel/success"
|
47
|
+
subject { paypal.cancel }
|
48
|
+
|
49
|
+
it { should be_success }
|
50
|
+
it { should be_valid }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when failure" do
|
54
|
+
use_vcr_cassette "express_checkout/recurring/cancel/failure"
|
55
|
+
subject { paypal.cancel }
|
56
|
+
|
57
|
+
it { should_not be_success }
|
58
|
+
it { should_not be_valid }
|
59
|
+
its(:errors) { should have(1).item }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe PayPal::ExpressCheckout::Response::Profile do
|
5
|
+
describe "#profile" do
|
6
|
+
context "when successful" do
|
7
|
+
use_vcr_cassette "express_checkout/recurring/profile/success"
|
8
|
+
let(:paypal) { PayPal::ExpressCheckout::Recurring.new(:profile_id => "I-1RFWFFS16BF4") }
|
9
|
+
subject { paypal.profile }
|
10
|
+
|
11
|
+
it { should_not be_active }
|
12
|
+
|
13
|
+
its(:status) { should == :cancelled }
|
14
|
+
its(:profile_id) { should == "I-1RFWFFS16BF4" }
|
15
|
+
its(:auto_bill_outstanding) { should == :next_billing }
|
16
|
+
its(:description) { should == "Awesome - Monthly Subscription" }
|
17
|
+
its(:subscriber_name) { should == "Chardy%Wang" }
|
18
|
+
its(:reference) { should == "1234" }
|
19
|
+
its(:max_failed_payments) { should == "1" }
|
20
|
+
its(:start_at) { should be_a(Time) }
|
21
|
+
its(:cycles_completed) { should == "1" }
|
22
|
+
its(:cycles_remaining) { should == "18446744073709551615" }
|
23
|
+
its(:outstanding_balance) { should == "0.00" }
|
24
|
+
its(:failed_payment_count) { should == "0" }
|
25
|
+
its(:last_payment_date) { should be_a(Time) }
|
26
|
+
its(:last_payment_amount) { should == "9.00" }
|
27
|
+
its(:period) { should == :monthly }
|
28
|
+
its(:frequency) { should == "1" }
|
29
|
+
its(:currency) { should == "USD" }
|
30
|
+
its(:amount) { should == "9.00" }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when failure" do
|
34
|
+
use_vcr_cassette "express_checkout/recurring/profile/failure"
|
35
|
+
let(:paypal) { PayPal::ExpressCheckout::Recurring.new(:profile_id => "invalid") }
|
36
|
+
subject { paypal.profile }
|
37
|
+
|
38
|
+
it { should_not be_valid }
|
39
|
+
it { should_not be_success }
|
40
|
+
|
41
|
+
its(:errors) { should have(1).item }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Response::Profile do
|
4
|
+
let(:profile_id) { "I-2YXA7FG2X8AJ" }
|
5
|
+
|
6
|
+
context "when successful" do
|
7
|
+
use_vcr_cassette "express_checkout/recurring/update_profile/success"
|
8
|
+
|
9
|
+
let(:paypal) {
|
10
|
+
PayPal::ExpressCheckout::Recurring.new({
|
11
|
+
:description => "Awesome - Monthly Subscription (Updated)",
|
12
|
+
:amount => "10.00",
|
13
|
+
:currency => "BRL",
|
14
|
+
:note => "Changed Plan",
|
15
|
+
:profile_id => profile_id
|
16
|
+
})
|
17
|
+
}
|
18
|
+
|
19
|
+
subject { paypal.update_profile }
|
20
|
+
|
21
|
+
it { should be_valid }
|
22
|
+
its(:profile_id) { should == profile_id }
|
23
|
+
its(:errors) { should be_empty }
|
24
|
+
end
|
25
|
+
|
26
|
+
context "updated profile" do
|
27
|
+
use_vcr_cassette "express_checkout/recurring/update_profile/profile"
|
28
|
+
|
29
|
+
let(:paypal) { PayPal::ExpressCheckout::Recurring.new(:profile_id => profile_id) }
|
30
|
+
subject { paypal.profile }
|
31
|
+
|
32
|
+
its(:amount) { should eql("10.00") }
|
33
|
+
its(:description) { should eql("Awesome - Monthly Subscription (Updated)") }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when failure" do
|
37
|
+
use_vcr_cassette "express_checkout/recurring/update_profile/failure"
|
38
|
+
|
39
|
+
let(:paypal) {
|
40
|
+
PayPal::ExpressCheckout::Recurring.new({
|
41
|
+
:profile_id => profile_id,
|
42
|
+
:amount => "10.00"
|
43
|
+
})
|
44
|
+
}
|
45
|
+
subject { paypal.update_profile }
|
46
|
+
|
47
|
+
it { should_not be_valid }
|
48
|
+
its(:errors) { should have(1).items }
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PayPal::ExpressCheckout::Request do
|
4
|
+
describe "#normalize_params" do
|
5
|
+
let(:request) { PayPal::ExpressCheckout::Request.new }
|
6
|
+
let(:object) { nil }
|
7
|
+
let(:params) { {} }
|
8
|
+
|
9
|
+
subject { request.normalize_params(object, params) }
|
10
|
+
|
11
|
+
context "with survey_choices" do
|
12
|
+
let(:object) { PayPal::ExpressCheckout::Checkout.new }
|
13
|
+
let(:params) {
|
14
|
+
{
|
15
|
+
:survey_choices => [
|
16
|
+
'Very Good',
|
17
|
+
'Good',
|
18
|
+
'Average',
|
19
|
+
'Below Average',
|
20
|
+
'Bad'
|
21
|
+
]
|
22
|
+
}
|
23
|
+
}
|
24
|
+
let(:expected) {
|
25
|
+
{
|
26
|
+
:L_SURVEYCHOICE0 => 'Very Good',
|
27
|
+
:L_SURVEYCHOICE1 => 'Good',
|
28
|
+
:L_SURVEYCHOICE2 => 'Average',
|
29
|
+
:L_SURVEYCHOICE3 => 'Below Average',
|
30
|
+
:L_SURVEYCHOICE4 => 'Bad'
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
it { should eql(expected) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with shipping_options" do
|
38
|
+
let(:object) { PayPal::ExpressCheckout::Checkout.new }
|
39
|
+
let(:params) {
|
40
|
+
{
|
41
|
+
:shipping_options => [
|
42
|
+
ShippingOption.new({
|
43
|
+
:is_default => true,
|
44
|
+
:name => "AIR",
|
45
|
+
:amount => 50.0
|
46
|
+
}),
|
47
|
+
ShippingOption.new({
|
48
|
+
:is_default => false,
|
49
|
+
:name => "SEA",
|
50
|
+
:amount => 25.0
|
51
|
+
})
|
52
|
+
]
|
53
|
+
}
|
54
|
+
}
|
55
|
+
let(:expected) {
|
56
|
+
{
|
57
|
+
:L_SHIPPINGOPTIONISDEFAULT0 => true,
|
58
|
+
:L_SHIPPINGOPTIONNAME0 => "AIR",
|
59
|
+
:L_SHIPPINGOPTIONAMOUNT0 => 50.0,
|
60
|
+
:L_SHIPPINGOPTIONISDEFAULT1 => false,
|
61
|
+
:L_SHIPPINGOPTIONNAME1 => "SEA",
|
62
|
+
:L_SHIPPINGOPTIONAMOUNT1 => 25.0
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
it { should eql(expected) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with payment_items" do
|
70
|
+
let(:object) { PayPal::ExpressCheckout::Payment.new }
|
71
|
+
let(:params) {
|
72
|
+
{
|
73
|
+
:payment_items => [
|
74
|
+
PaymentItem.new({
|
75
|
+
:number => 1,
|
76
|
+
:name => "iPhone 5",
|
77
|
+
:description => "Best iPhone ever",
|
78
|
+
:quantity => 1,
|
79
|
+
:amount => 499,
|
80
|
+
:tax_amount => 2.49,
|
81
|
+
:item_category => "Phone"
|
82
|
+
}),
|
83
|
+
PaymentItem.new({
|
84
|
+
:number => 1,
|
85
|
+
:name => "iPhone 4S",
|
86
|
+
:description => "Siri",
|
87
|
+
:quantity => 1,
|
88
|
+
:amount => 399,
|
89
|
+
:tax_amount => 1.99,
|
90
|
+
:item_category => "Phone"
|
91
|
+
})
|
92
|
+
]
|
93
|
+
}
|
94
|
+
}
|
95
|
+
let(:expected) {
|
96
|
+
{
|
97
|
+
:L_ITEMCATEGORY0 => "Phone",
|
98
|
+
:L_NAME0 => "iPhone 5",
|
99
|
+
:L_DESC0 => "Best iPhone ever",
|
100
|
+
:L_AMT0 => 499,
|
101
|
+
:L_NUMBER0 => 1,
|
102
|
+
:L_QTY0 => 1,
|
103
|
+
:L_TAXAMT0 => 2.49,
|
104
|
+
:L_ITEMCATEGORY1 => "Phone",
|
105
|
+
:L_NAME1 => "iPhone 4S",
|
106
|
+
:L_DESC1 => "Siri",
|
107
|
+
:L_AMT1 => 399,
|
108
|
+
:L_NUMBER1 => 1,
|
109
|
+
:L_QTY1 => 1,
|
110
|
+
:L_TAXAMT1 => 1.99
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
it { should eql(expected) }
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with payments" do
|
118
|
+
let(:object) { PayPal::ExpressCheckout::Checkout.new }
|
119
|
+
let(:params) {
|
120
|
+
{
|
121
|
+
:payments => [
|
122
|
+
PayPal::ExpressCheckout::Payment.new({
|
123
|
+
:invoice_num => "12345",
|
124
|
+
:description => "iPhones",
|
125
|
+
:note_text => "Some notes",
|
126
|
+
:amount => 998,
|
127
|
+
:shipping_amount => 25,
|
128
|
+
:tax_amount => 20.5,
|
129
|
+
:currency => "USD",
|
130
|
+
:ship_to_name => "John Lim",
|
131
|
+
:ship_to_country => "SG",
|
132
|
+
:payment_items => [
|
133
|
+
PaymentItem.new({
|
134
|
+
:number => 1,
|
135
|
+
:name => "iPhone 5",
|
136
|
+
:description => "Best iPhone ever",
|
137
|
+
:quantity => 1,
|
138
|
+
:amount => 499,
|
139
|
+
:tax_amount => 12.25,
|
140
|
+
:item_category => "Physical"
|
141
|
+
}),
|
142
|
+
PaymentItem.new({
|
143
|
+
:number => 2,
|
144
|
+
:name => "iPhone 4S",
|
145
|
+
:description => "Siri",
|
146
|
+
:quantity => 1,
|
147
|
+
:amount => 399,
|
148
|
+
:tax_amount => 8.25,
|
149
|
+
:item_category => "Physical"
|
150
|
+
})
|
151
|
+
]
|
152
|
+
}),
|
153
|
+
PayPal::ExpressCheckout::Payment.new({
|
154
|
+
:invoice_num => "12346",
|
155
|
+
:description => "Apple Gadgets",
|
156
|
+
:note_text => "Some notes",
|
157
|
+
:amount => 599,
|
158
|
+
:shipping_amount => 25,
|
159
|
+
:tax_amount => 12.5,
|
160
|
+
:currency => "USD",
|
161
|
+
:payment_items => [
|
162
|
+
PaymentItem.new({
|
163
|
+
:number => 1,
|
164
|
+
:name => "iPad 4",
|
165
|
+
:description => "Best iPad ever",
|
166
|
+
:quantity => 1,
|
167
|
+
:amount => 599,
|
168
|
+
:tax_amount => 12.5,
|
169
|
+
:item_category => "Physical"
|
170
|
+
})
|
171
|
+
]
|
172
|
+
})
|
173
|
+
]
|
174
|
+
}
|
175
|
+
}
|
176
|
+
let(:expected) {
|
177
|
+
{
|
178
|
+
:PAYMENTREQUEST_0_AMT => 998,
|
179
|
+
:PAYMENTREQUEST_0_CURRENCYCODE => 'USD',
|
180
|
+
:PAYMENTREQUEST_0_SHIPPINGAMT => 25,
|
181
|
+
:PAYMENTREQUEST_0_TAXAMT => 20.5,
|
182
|
+
:PAYMENTREQUEST_0_DESC => "iPhones",
|
183
|
+
:PAYMENTREQUEST_0_INVNUM => "12345",
|
184
|
+
:PAYMENTREQUEST_0_NOTETEXT => "Some notes",
|
185
|
+
:PAYMENTREQUEST_0_SHIPTONAME => "John Lim",
|
186
|
+
:PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE => "SG",
|
187
|
+
:L_PAYMENTREQUEST_0_NAME0 => "iPhone 5",
|
188
|
+
:L_PAYMENTREQUEST_0_DESC0 => "Best iPhone ever",
|
189
|
+
:L_PAYMENTREQUEST_0_AMT0 => 499,
|
190
|
+
:L_PAYMENTREQUEST_0_NUMBER0 => 1,
|
191
|
+
:L_PAYMENTREQUEST_0_QTY0 => 1,
|
192
|
+
:L_PAYMENTREQUEST_0_TAXAMT0 => 12.25,
|
193
|
+
:L_PAYMENTREQUEST_0_ITEMCATEGORY0 => "Physical",
|
194
|
+
:L_PAYMENTREQUEST_0_NAME1 => "iPhone 4S",
|
195
|
+
:L_PAYMENTREQUEST_0_DESC1 => "Siri",
|
196
|
+
:L_PAYMENTREQUEST_0_AMT1 => 399,
|
197
|
+
:L_PAYMENTREQUEST_0_NUMBER1 => 2,
|
198
|
+
:L_PAYMENTREQUEST_0_QTY1 => 1,
|
199
|
+
:L_PAYMENTREQUEST_0_TAXAMT1 => 8.25,
|
200
|
+
:L_PAYMENTREQUEST_0_ITEMCATEGORY1 => "Physical",
|
201
|
+
:PAYMENTREQUEST_1_AMT => 599,
|
202
|
+
:PAYMENTREQUEST_1_CURRENCYCODE => 'USD',
|
203
|
+
:PAYMENTREQUEST_1_SHIPPINGAMT => 25,
|
204
|
+
:PAYMENTREQUEST_1_TAXAMT => 12.5,
|
205
|
+
:PAYMENTREQUEST_1_DESC => "Apple Gadgets",
|
206
|
+
:PAYMENTREQUEST_1_INVNUM => "12346",
|
207
|
+
:PAYMENTREQUEST_1_NOTETEXT => "Some notes",
|
208
|
+
:L_PAYMENTREQUEST_1_NAME0 => "iPad 4",
|
209
|
+
:L_PAYMENTREQUEST_1_DESC0 => "Best iPad ever",
|
210
|
+
:L_PAYMENTREQUEST_1_AMT0 => 599,
|
211
|
+
:L_PAYMENTREQUEST_1_NUMBER0 => 1,
|
212
|
+
:L_PAYMENTREQUEST_1_QTY0 => 1,
|
213
|
+
:L_PAYMENTREQUEST_1_TAXAMT0 => 12.5,
|
214
|
+
:L_PAYMENTREQUEST_1_ITEMCATEGORY0 => "Physical",
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
it { should eql(expected) }
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|