paypal-sdk-adaptivepayments 1.105.0 → 1.110.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +19 -19
- data/README.md +141 -141
- data/lib/paypal-sdk/adaptive_payments.rb +17 -17
- data/lib/paypal-sdk/adaptive_payments/api.rb +27 -27
- data/lib/paypal-sdk/adaptive_payments/data_types.rb +1215 -1214
- data/lib/paypal-sdk/adaptive_payments/services.rb +343 -343
- data/lib/paypal-sdk/adaptive_payments/urls.rb +26 -26
- data/lib/paypal-sdk/adaptive_payments/version.rb +7 -7
- data/spec/adaptive_payments_examples_spec.rb +119 -119
- data/spec/config/paypal.yml +22 -22
- metadata +7 -11
@@ -1,26 +1,26 @@
|
|
1
|
-
module PayPal
|
2
|
-
module SDK
|
3
|
-
module AdaptivePayments
|
4
|
-
module Urls
|
5
|
-
REDIRECT_ENDPOINTS = {
|
6
|
-
:live => "https://www.paypal.com/webscr",
|
7
|
-
:sandbox => "https://www.sandbox.paypal.com/webscr" }
|
8
|
-
|
9
|
-
def redirect_url(params = {})
|
10
|
-
"#{REDIRECT_ENDPOINTS[api_mode]}?#{encode_www_form(params)}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def payment_url(key)
|
14
|
-
key = key.payKey if key.respond_to?(:payKey)
|
15
|
-
redirect_url(:cmd => "_ap-payment", :paykey => key.to_s)
|
16
|
-
end
|
17
|
-
alias_method :pay_url, :payment_url
|
18
|
-
|
19
|
-
def preapproval_url(key)
|
20
|
-
key = key.preapprovalKey if key.respond_to?(:preapprovalKey)
|
21
|
-
redirect_url(:cmd => "_ap-preapproval", :preapprovalkey => key.to_s)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module PayPal
|
2
|
+
module SDK
|
3
|
+
module AdaptivePayments
|
4
|
+
module Urls
|
5
|
+
REDIRECT_ENDPOINTS = {
|
6
|
+
:live => "https://www.paypal.com/webscr",
|
7
|
+
:sandbox => "https://www.sandbox.paypal.com/webscr" }
|
8
|
+
|
9
|
+
def redirect_url(params = {})
|
10
|
+
"#{REDIRECT_ENDPOINTS[api_mode]}?#{encode_www_form(params)}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def payment_url(key)
|
14
|
+
key = key.payKey if key.respond_to?(:payKey)
|
15
|
+
redirect_url(:cmd => "_ap-payment", :paykey => key.to_s)
|
16
|
+
end
|
17
|
+
alias_method :pay_url, :payment_url
|
18
|
+
|
19
|
+
def preapproval_url(key)
|
20
|
+
key = key.preapprovalKey if key.respond_to?(:preapprovalKey)
|
21
|
+
redirect_url(:cmd => "_ap-preapproval", :preapprovalkey => key.to_s)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module PayPal
|
2
|
-
module SDK
|
3
|
-
module AdaptivePayments
|
4
|
-
VERSION = "1.
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module PayPal
|
2
|
+
module SDK
|
3
|
+
module AdaptivePayments
|
4
|
+
VERSION = "1.110.0"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
@@ -1,119 +1,119 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "AdaptivePayments" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@api = PayPal::SDK::AdaptivePayments::API.new
|
7
|
-
@api_with_cert = PayPal::SDK::AdaptivePayments::API.new(:with_certificate)
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "Examples" do
|
11
|
-
it "Pay" do
|
12
|
-
# Build request object
|
13
|
-
@pay = @api.build_pay({
|
14
|
-
:actionType => "PAY",
|
15
|
-
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
|
16
|
-
:currencyCode => "USD",
|
17
|
-
:feesPayer => "SENDER",
|
18
|
-
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
|
19
|
-
:receiverList => {
|
20
|
-
:receiver => [{
|
21
|
-
:amount => 1.0,
|
22
|
-
:email => "platfo_1255612361_per@gmail.com" }] },
|
23
|
-
:returnUrl => "http://localhost:3000/samples/adaptive_payments/pay" })
|
24
|
-
|
25
|
-
# Make API call & get response
|
26
|
-
@pay_response = @api.pay(@pay)
|
27
|
-
@pay_response.should be_success
|
28
|
-
|
29
|
-
@payment_details_request = @api.build_payment_details()
|
30
|
-
@payment_details_request.payKey = @pay_response.payKey
|
31
|
-
@payment_details_response = @api.payment_details(@payment_details_request)
|
32
|
-
@payment_details_response.should be_success
|
33
|
-
|
34
|
-
# Make API call & get response
|
35
|
-
@pay_response = @api_with_cert.pay(@pay)
|
36
|
-
@pay_response.should be_success
|
37
|
-
|
38
|
-
@payment_details_request = @api_with_cert.build_payment_details()
|
39
|
-
@payment_details_request.payKey = @pay_response.payKey
|
40
|
-
@payment_details_response = @api_with_cert.payment_details(@payment_details_request)
|
41
|
-
@payment_details_response.should be_success
|
42
|
-
end
|
43
|
-
|
44
|
-
it "Get Payment details" do
|
45
|
-
@payment_details_response = @api.payment_details({
|
46
|
-
:payKey => "AP-5S482348KH512131U" })
|
47
|
-
@payment_details_response.should be_success
|
48
|
-
@payment_details_response.should_not be_failure
|
49
|
-
@payment_details_response.should_not be_warning
|
50
|
-
|
51
|
-
@payment_details_response = @api.payment_details({})
|
52
|
-
@payment_details_response.should be_failure
|
53
|
-
@payment_details_response.should_not be_success
|
54
|
-
@payment_details_response.should_not be_warning
|
55
|
-
end
|
56
|
-
|
57
|
-
it "Preapproval" do
|
58
|
-
|
59
|
-
@preapproval = @api.build_preapproval({
|
60
|
-
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/preapproval",
|
61
|
-
:currencyCode => "USD",
|
62
|
-
:returnUrl => "http://localhost:3000/samples/adaptive_payments/preapproval",
|
63
|
-
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
|
64
|
-
:startingDate => "2015-10-10T00:00:00+00:00" })
|
65
|
-
|
66
|
-
# Make API call & get response
|
67
|
-
@preapproval_response = @api.preapproval(@preapproval)
|
68
|
-
@preapproval_response.should be_success
|
69
|
-
|
70
|
-
@preapproval_details_request = @api.build_preapproval_details()
|
71
|
-
@preapproval_details_request.preapprovalKey = @preapproval_response.preapprovalKey
|
72
|
-
@preapproval_details_response = @api.preapproval_details(@preapproval_details_request)
|
73
|
-
@preapproval_details_response.should be_success
|
74
|
-
end
|
75
|
-
|
76
|
-
it "Cancel Preapproval" do
|
77
|
-
@cancel_preapproval_response = @api.cancel_preapproval({
|
78
|
-
:preapprovalKey => "PA-2T305990ET0354039" })
|
79
|
-
@cancel_preapproval_response.should be_success
|
80
|
-
end
|
81
|
-
|
82
|
-
it "Refund" do
|
83
|
-
@refund_response = @api.refund({
|
84
|
-
:currencyCode => "USD",
|
85
|
-
:payKey => "AP-5S482348KH512131U",
|
86
|
-
:receiverList => {
|
87
|
-
:receiver => [{
|
88
|
-
:amount => 1.0,
|
89
|
-
:email => "platfo_1255612361_per@gmail.com" }] } })
|
90
|
-
@refund_response.should be_success
|
91
|
-
end
|
92
|
-
|
93
|
-
it "Get Payment option" do
|
94
|
-
@get_payment_options_response = @api.get_payment_options({
|
95
|
-
:payKey => "AP-5S482348KH512131U" })
|
96
|
-
@get_payment_options_response.should be_success
|
97
|
-
end
|
98
|
-
|
99
|
-
it "Convert currency" do
|
100
|
-
# Build request object
|
101
|
-
@convert_currency = @api.build_convert_currency({
|
102
|
-
:baseAmountList => {
|
103
|
-
:currency => [{
|
104
|
-
:code => "USD",
|
105
|
-
:amount => 2.0 }] },
|
106
|
-
:convertToCurrencyList => {
|
107
|
-
:currencyCode => ["GBP"] } })
|
108
|
-
|
109
|
-
# Make API call & get response
|
110
|
-
@convert_currency_response = @api.convert_currency(@convert_currency)
|
111
|
-
@convert_currency_response.should be_success
|
112
|
-
end
|
113
|
-
|
114
|
-
it "Validate ipn message" do
|
115
|
-
@api.ipn_valid?("Invalid").should be_false
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "AdaptivePayments" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@api = PayPal::SDK::AdaptivePayments::API.new
|
7
|
+
@api_with_cert = PayPal::SDK::AdaptivePayments::API.new(:with_certificate)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "Examples" do
|
11
|
+
it "Pay" do
|
12
|
+
# Build request object
|
13
|
+
@pay = @api.build_pay({
|
14
|
+
:actionType => "PAY",
|
15
|
+
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
|
16
|
+
:currencyCode => "USD",
|
17
|
+
:feesPayer => "SENDER",
|
18
|
+
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
|
19
|
+
:receiverList => {
|
20
|
+
:receiver => [{
|
21
|
+
:amount => 1.0,
|
22
|
+
:email => "platfo_1255612361_per@gmail.com" }] },
|
23
|
+
:returnUrl => "http://localhost:3000/samples/adaptive_payments/pay" })
|
24
|
+
|
25
|
+
# Make API call & get response
|
26
|
+
@pay_response = @api.pay(@pay)
|
27
|
+
@pay_response.should be_success
|
28
|
+
|
29
|
+
@payment_details_request = @api.build_payment_details()
|
30
|
+
@payment_details_request.payKey = @pay_response.payKey
|
31
|
+
@payment_details_response = @api.payment_details(@payment_details_request)
|
32
|
+
@payment_details_response.should be_success
|
33
|
+
|
34
|
+
# Make API call & get response
|
35
|
+
@pay_response = @api_with_cert.pay(@pay)
|
36
|
+
@pay_response.should be_success
|
37
|
+
|
38
|
+
@payment_details_request = @api_with_cert.build_payment_details()
|
39
|
+
@payment_details_request.payKey = @pay_response.payKey
|
40
|
+
@payment_details_response = @api_with_cert.payment_details(@payment_details_request)
|
41
|
+
@payment_details_response.should be_success
|
42
|
+
end
|
43
|
+
|
44
|
+
it "Get Payment details" do
|
45
|
+
@payment_details_response = @api.payment_details({
|
46
|
+
:payKey => "AP-5S482348KH512131U" })
|
47
|
+
@payment_details_response.should be_success
|
48
|
+
@payment_details_response.should_not be_failure
|
49
|
+
@payment_details_response.should_not be_warning
|
50
|
+
|
51
|
+
@payment_details_response = @api.payment_details({})
|
52
|
+
@payment_details_response.should be_failure
|
53
|
+
@payment_details_response.should_not be_success
|
54
|
+
@payment_details_response.should_not be_warning
|
55
|
+
end
|
56
|
+
|
57
|
+
it "Preapproval" do
|
58
|
+
|
59
|
+
@preapproval = @api.build_preapproval({
|
60
|
+
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/preapproval",
|
61
|
+
:currencyCode => "USD",
|
62
|
+
:returnUrl => "http://localhost:3000/samples/adaptive_payments/preapproval",
|
63
|
+
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
|
64
|
+
:startingDate => "2015-10-10T00:00:00+00:00" })
|
65
|
+
|
66
|
+
# Make API call & get response
|
67
|
+
@preapproval_response = @api.preapproval(@preapproval)
|
68
|
+
@preapproval_response.should be_success
|
69
|
+
|
70
|
+
@preapproval_details_request = @api.build_preapproval_details()
|
71
|
+
@preapproval_details_request.preapprovalKey = @preapproval_response.preapprovalKey
|
72
|
+
@preapproval_details_response = @api.preapproval_details(@preapproval_details_request)
|
73
|
+
@preapproval_details_response.should be_success
|
74
|
+
end
|
75
|
+
|
76
|
+
it "Cancel Preapproval" do
|
77
|
+
@cancel_preapproval_response = @api.cancel_preapproval({
|
78
|
+
:preapprovalKey => "PA-2T305990ET0354039" })
|
79
|
+
@cancel_preapproval_response.should be_success
|
80
|
+
end
|
81
|
+
|
82
|
+
it "Refund" do
|
83
|
+
@refund_response = @api.refund({
|
84
|
+
:currencyCode => "USD",
|
85
|
+
:payKey => "AP-5S482348KH512131U",
|
86
|
+
:receiverList => {
|
87
|
+
:receiver => [{
|
88
|
+
:amount => 1.0,
|
89
|
+
:email => "platfo_1255612361_per@gmail.com" }] } })
|
90
|
+
@refund_response.should be_success
|
91
|
+
end
|
92
|
+
|
93
|
+
it "Get Payment option" do
|
94
|
+
@get_payment_options_response = @api.get_payment_options({
|
95
|
+
:payKey => "AP-5S482348KH512131U" })
|
96
|
+
@get_payment_options_response.should be_success
|
97
|
+
end
|
98
|
+
|
99
|
+
it "Convert currency" do
|
100
|
+
# Build request object
|
101
|
+
@convert_currency = @api.build_convert_currency({
|
102
|
+
:baseAmountList => {
|
103
|
+
:currency => [{
|
104
|
+
:code => "USD",
|
105
|
+
:amount => 2.0 }] },
|
106
|
+
:convertToCurrencyList => {
|
107
|
+
:currencyCode => ["GBP"] } })
|
108
|
+
|
109
|
+
# Make API call & get response
|
110
|
+
@convert_currency_response = @api.convert_currency(@convert_currency)
|
111
|
+
@convert_currency_response.should be_success
|
112
|
+
end
|
113
|
+
|
114
|
+
it "Validate ipn message" do
|
115
|
+
@api.ipn_valid?("Invalid").should be_false
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
data/spec/config/paypal.yml
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
test: &default
|
2
|
-
username: jb-us-seller_api1.paypal.com
|
3
|
-
password: WX4WTU3S8MY44S7F
|
4
|
-
signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
|
5
|
-
app_id: APP-80W284485P519543T
|
6
|
-
http_timeout: 30
|
7
|
-
mode: sandbox
|
8
|
-
development:
|
9
|
-
<<: *default
|
10
|
-
|
11
|
-
with_certificate:
|
12
|
-
<<: *default
|
13
|
-
username: platfo_1255170694_biz_api1.gmail.com
|
14
|
-
password: 2DPPKUPKB7DQLXNR
|
15
|
-
signature:
|
16
|
-
cert_path: "spec/config/cert_key.pem"
|
17
|
-
app_id: APP-80W284485P519543T
|
18
|
-
|
19
|
-
with_oauth_token:
|
20
|
-
<<: *default
|
21
|
-
token: H2kLxjm9lCxQdnOYxkH29I53TpZyIXez4GtHhAVGpiU3DiVTz5eNPQ
|
22
|
-
token_secret: MnZ-iPdDqGLEfQIuTIfUN4uK9lU
|
1
|
+
test: &default
|
2
|
+
username: jb-us-seller_api1.paypal.com
|
3
|
+
password: WX4WTU3S8MY44S7F
|
4
|
+
signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
|
5
|
+
app_id: APP-80W284485P519543T
|
6
|
+
http_timeout: 30
|
7
|
+
mode: sandbox
|
8
|
+
development:
|
9
|
+
<<: *default
|
10
|
+
|
11
|
+
with_certificate:
|
12
|
+
<<: *default
|
13
|
+
username: platfo_1255170694_biz_api1.gmail.com
|
14
|
+
password: 2DPPKUPKB7DQLXNR
|
15
|
+
signature:
|
16
|
+
cert_path: "spec/config/cert_key.pem"
|
17
|
+
app_id: APP-80W284485P519543T
|
18
|
+
|
19
|
+
with_oauth_token:
|
20
|
+
<<: *default
|
21
|
+
token: H2kLxjm9lCxQdnOYxkH29I53TpZyIXez4GtHhAVGpiU3DiVTz5eNPQ
|
22
|
+
token_secret: MnZ-iPdDqGLEfQIuTIfUN4uK9lU
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-sdk-adaptivepayments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.110.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- PayPal
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: paypal-sdk-core
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -53,27 +50,26 @@ files:
|
|
53
50
|
- Gemfile
|
54
51
|
homepage: https://developer.paypal.com
|
55
52
|
licenses: []
|
53
|
+
metadata: {}
|
56
54
|
post_install_message:
|
57
55
|
rdoc_options: []
|
58
56
|
require_paths:
|
59
57
|
- lib
|
60
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
59
|
requirements:
|
63
|
-
- -
|
60
|
+
- - '>='
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: '0'
|
66
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
64
|
requirements:
|
69
|
-
- -
|
65
|
+
- - '>='
|
70
66
|
- !ruby/object:Gem::Version
|
71
67
|
version: '0'
|
72
68
|
requirements: []
|
73
69
|
rubyforge_project:
|
74
|
-
rubygems_version:
|
70
|
+
rubygems_version: 2.0.3
|
75
71
|
signing_key:
|
76
|
-
specification_version:
|
72
|
+
specification_version: 4
|
77
73
|
summary: PayPal Adaptive Payments SDK
|
78
74
|
test_files:
|
79
75
|
- spec/adaptive_payments_examples_spec.rb
|