paypal-sdk-adaptivepayments 1.100.0 → 1.101.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -1
- data/README.md +71 -99
- data/lib/paypal-sdk/adaptive_payments.rb +1 -0
- data/lib/paypal-sdk/adaptive_payments/api.rb +6 -0
- data/lib/paypal-sdk/adaptive_payments/data_types.rb +36 -0
- data/lib/paypal-sdk/adaptive_payments/urls.rb +26 -0
- data/lib/paypal-sdk/adaptive_payments/version.rb +1 -1
- data/spec/adaptive_payments_examples_spec.rb +75 -32
- metadata +5 -6
- data/spec/adaptive_payments_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmMwODVhNDhjMjQ4ODA2ZDI2ZDU5Yjg4MDE3ODBkYTc1ZGQ1YTA0OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWUzYTk5MDAwM2U3NzE3YzE0NWFmZDBhOWEwMjA4M2MxMjRlNzM2Zg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmI0M2I1YWZhYjI0OGI1Y2YwMzQ2ODI0MWViNTdmYTU4YzQ0YjUyOTZlMjZm
|
10
|
+
Y2NjOGU4YTQzZWI2ZWE1ODM4ODQ4MjAyYjZjMWFmZmE4Zjk0YjNiMTE1ZmM0
|
11
|
+
ZTg1NGJkNGViYzc3ZGY5NmRmY2YyYTU3MDYwZDFhZTZkYzQwMGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzBlZTJjNTJkZmVkNGNjMjgwNzc0OWEyZGVmZjg5Y2QzOTM1OWQ2NzY5NzM0
|
14
|
+
ZmQ5ZDEwMDcyZGVjMmY5NWU0NWJiNGEzZmU4ZjU0YzQzMTg2OWE1OTI5NWMy
|
15
|
+
ZTFhODYwZjZiYmQ0ZmM2OTQ1Y2E5ZTYzNTQ1NjUyM2VmYTA5ZTQ=
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ if File.exist? File.expand_path('../samples/adaptive_payments_samples.gemspec',
|
|
8
8
|
gem 'adaptive_payments_samples', :path => 'samples', :require => false
|
9
9
|
group :test do
|
10
10
|
gem 'rspec-rails', :require => false
|
11
|
-
gem 'capybara', :require => false
|
11
|
+
gem 'capybara', '~> 2.0.3', :require => false
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/README.md
CHANGED
@@ -6,118 +6,76 @@ The PayPal Adaptive Payments SDK provides Ruby APIs to create, process and manag
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'paypal-sdk-adaptivepayments'
|
11
|
+
```
|
10
12
|
|
11
13
|
And then execute:
|
12
14
|
|
13
|
-
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
20
|
|
17
|
-
|
21
|
+
```sh
|
22
|
+
$ gem install paypal-sdk-adaptivepayments
|
23
|
+
```
|
18
24
|
|
19
25
|
## Configuration
|
20
26
|
|
21
27
|
For Rails application:
|
22
28
|
|
23
|
-
|
29
|
+
```sh
|
30
|
+
rails g paypal:sdk:install
|
31
|
+
```
|
24
32
|
|
25
33
|
For other ruby application, create a configuration file(`config/paypal.yml`):
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
35
|
+
```yaml
|
36
|
+
development: &default
|
37
|
+
username: jb-us-seller_api1.paypal.com
|
38
|
+
password: WX4WTU3S8MY44S7F
|
39
|
+
signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
|
40
|
+
app_id: APP-80W284485P519543T
|
41
|
+
http_timeout: 30
|
42
|
+
mode: sandbox
|
43
|
+
sandbox_email_address: Platform.sdk.seller@gmail.com
|
44
|
+
# # with certificate
|
45
|
+
# cert_path: "config/cert_key.pem"
|
46
|
+
# # with token authentication
|
47
|
+
# token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
|
48
|
+
# token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
|
49
|
+
# # with Proxy
|
50
|
+
# http_proxy: http://proxy-ipaddress:3129/
|
51
|
+
# # with device ip address
|
52
|
+
# device_ipaddress: "127.0.0.1"
|
53
|
+
test:
|
54
|
+
<<: *default
|
55
|
+
production:
|
56
|
+
mode: live
|
57
|
+
username: USERNAME
|
58
|
+
password: PASSWORD
|
59
|
+
signature: SIGNATURE
|
60
|
+
app_id: APP_ID
|
61
|
+
```
|
49
62
|
|
50
63
|
Load Configurations from specified file:
|
51
64
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
Create API object:
|
57
|
-
|
58
|
-
api = PayPal::SDK::AdaptivePayments::API.new
|
59
|
-
|
60
|
-
Override configuration while creating a object:
|
61
|
-
|
62
|
-
api = PayPal::SDK::AdaptivePayments::API.new(:development)
|
63
|
-
api = PayPal::SDK::AdaptivePayments::API.new(:development, :app_id => "XYZ")
|
64
|
-
api = PayPal::SDK::AdaptivePayments::API.new(:app_id => "XYZ") # Take default environment.
|
65
|
-
|
66
|
-
Change configuration:
|
67
|
-
|
68
|
-
api.set_config :testing
|
69
|
-
api.set_config :testing, app_id => "XYZ"
|
70
|
-
|
71
|
-
|
72
|
-
## Build Request Object
|
73
|
-
|
74
|
-
To make api request, we need to build a request object.
|
75
|
-
|
76
|
-
# To build a empty request object for convert currency
|
77
|
-
convert_currency_request = api.build_convert_currency()
|
78
|
-
|
79
|
-
# To build a request object with default data
|
80
|
-
convert_currency_request = api.build_convert_currency( :baseAmountList => { :currency => [ { :code => "USD", :amount => "5.0" } ] } )
|
81
|
-
|
82
|
-
The Build method can be access with camelcase or underscore:
|
83
|
-
|
84
|
-
api = api.build_convert_currency()
|
85
|
-
# (or)
|
86
|
-
api = api.BuildConvertCurrency()
|
87
|
-
|
88
|
-
## Assign value to members
|
89
|
-
|
90
|
-
Members can be access with camelcase or underscore format.
|
91
|
-
|
92
|
-
pay_request.receiverList.receiver[0].amount = 1.0
|
93
|
-
# With underscore
|
94
|
-
pay_request.receiver_list.receiver[0].email = "platfo_1255612361_per@gmail.com"
|
95
|
-
|
96
|
-
To Assign multiple values:
|
97
|
-
|
98
|
-
pay_request.receiverList.receiver[0] = { :amount => "1.0", :email => "platfo_1255612361_per@gmail.com" }
|
99
|
-
|
100
|
-
To Get members list for the given object( For Reference ):
|
101
|
-
|
102
|
-
convert_currency_request.members
|
103
|
-
convert_currency_request.baseAmountList.members
|
104
|
-
|
105
|
-
## Make API Request
|
106
|
-
|
107
|
-
Make api call with request object:
|
108
|
-
|
109
|
-
pay_response = api.pay(pay_request)
|
110
|
-
|
111
|
-
Make api call with hash:
|
112
|
-
|
113
|
-
pay_response = api.pay({:baseAmountList => { :currency => [ { :code => "USD", :amount => "5.0" } ] }})
|
114
|
-
|
115
|
-
## Access values from response object
|
116
|
-
|
117
|
-
To get response status:
|
65
|
+
```ruby
|
66
|
+
PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
67
|
+
```
|
118
68
|
|
119
|
-
|
69
|
+
Or without configuration file:
|
120
70
|
|
71
|
+
```ruby
|
72
|
+
@api = PayPal::SDK::AdaptivePayments::API.new(
|
73
|
+
:mode => "sandbox", # Set "live" for production
|
74
|
+
:app_id => "APP-80W284485P519543T",
|
75
|
+
:username => "jb-us-seller_api1.paypal.com",
|
76
|
+
:password => "WX4WTU3S8MY44S7F",
|
77
|
+
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy" )
|
78
|
+
```
|
121
79
|
|
122
80
|
## Example
|
123
81
|
|
@@ -147,23 +105,37 @@ require 'paypal-sdk-adaptivepayments'
|
|
147
105
|
@pay_response = @api.pay(@pay)
|
148
106
|
|
149
107
|
# Access response
|
150
|
-
@pay_response.
|
108
|
+
if @pay_response.success?
|
109
|
+
@pay_response.payKey
|
110
|
+
@api.payment_url(@pay_response) # Url to complete payment
|
111
|
+
else
|
112
|
+
@pay_response.error[0].message
|
113
|
+
end
|
151
114
|
```
|
152
115
|
|
153
|
-
|
116
|
+
For more samples [https://paypal-sdk-samples.herokuapp.com/adaptive_payments/](https://paypal-sdk-samples.herokuapp.com/adaptive_payments/)
|
117
|
+
|
118
|
+
## Samples App
|
154
119
|
|
155
120
|
Add following line in rails `Gemfile`:
|
156
121
|
|
157
|
-
|
158
|
-
|
122
|
+
```ruby
|
123
|
+
gem 'paypal-sdk-adaptivepayments'
|
124
|
+
gem 'adaptive_payments_samples', :git => "https://github.com/paypal/adaptivepayments-sdk-ruby.git", :group => :development
|
125
|
+
```
|
159
126
|
|
160
127
|
Configure routes(`config/routes.rb`):
|
161
128
|
|
162
|
-
|
129
|
+
```ruby
|
130
|
+
mount AdaptivePaymentsSamples::Engine => "/samples" if Rails.env.development?
|
131
|
+
```
|
163
132
|
|
164
133
|
To get default paypal configuration execute:
|
165
134
|
|
166
|
-
|
135
|
+
```sh
|
136
|
+
rails g paypal:sdk:install
|
137
|
+
```
|
167
138
|
|
168
139
|
Run `rails server` and check the samples.
|
169
140
|
|
141
|
+
|
@@ -6,6 +6,7 @@ module PayPal
|
|
6
6
|
autoload :VERSION, "paypal-sdk/adaptive_payments/version"
|
7
7
|
autoload :Services, "paypal-sdk/adaptive_payments/services"
|
8
8
|
autoload :DataTypes, "paypal-sdk/adaptive_payments/data_types"
|
9
|
+
autoload :Urls, "paypal-sdk/adaptive_payments/urls"
|
9
10
|
autoload :API, "paypal-sdk/adaptive_payments/api"
|
10
11
|
|
11
12
|
def self.new(*args)
|
@@ -5,6 +5,7 @@ module PayPal
|
|
5
5
|
module AdaptivePayments
|
6
6
|
class API < Core::API::Platform
|
7
7
|
include Services
|
8
|
+
include Urls
|
8
9
|
|
9
10
|
def initialize(environment = nil, options = {})
|
10
11
|
super(SERVICE_NAME, environment, options)
|
@@ -14,6 +15,11 @@ module PayPal
|
|
14
15
|
def default_http_header
|
15
16
|
super.merge(ADAPTIVE_PAYMENTS_HTTP_HEADER)
|
16
17
|
end
|
18
|
+
|
19
|
+
# Validate IPN message
|
20
|
+
def ipn_valid?(raw_post_data)
|
21
|
+
Core::API::IPN.valid?(raw_post_data, config)
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -14,6 +14,22 @@ module PayPal::SDK
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
module ResponseStatus
|
18
|
+
Status = { :success => ["Success", "SuccessWithWarning"],
|
19
|
+
:warning => ["Warning", "SuccessWithWarning", "FailureWithWarning"],
|
20
|
+
:failure => ["Failure", "FailureWithWarning"] }
|
21
|
+
|
22
|
+
def response_status
|
23
|
+
self.responseEnvelope && self.responseEnvelope.ack
|
24
|
+
end
|
25
|
+
|
26
|
+
Status.keys.each do |status|
|
27
|
+
define_method("#{status}?") do
|
28
|
+
Status[status].include?(self.response_status)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
17
33
|
class EnumType < Core::API::DataTypes::Enum
|
18
34
|
end
|
19
35
|
|
@@ -94,6 +110,7 @@ module PayPal::SDK
|
|
94
110
|
# This specifies a fault, encapsulating error data, with specific error codes.
|
95
111
|
class FaultMessage < DataType
|
96
112
|
def self.load_members
|
113
|
+
include ResponseStatus
|
97
114
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
98
115
|
array_of :error, ErrorData
|
99
116
|
end
|
@@ -562,6 +579,7 @@ module PayPal::SDK
|
|
562
579
|
# The result of the CancelPreapprovalRequest.
|
563
580
|
class CancelPreapprovalResponse < DataType
|
564
581
|
def self.load_members
|
582
|
+
include ResponseStatus
|
565
583
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
566
584
|
array_of :error, ErrorData
|
567
585
|
end
|
@@ -584,6 +602,7 @@ module PayPal::SDK
|
|
584
602
|
# The result of the ConfirmPreapprovalRequest.
|
585
603
|
class ConfirmPreapprovalResponse < DataType
|
586
604
|
def self.load_members
|
605
|
+
include ResponseStatus
|
587
606
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
588
607
|
array_of :error, ErrorData
|
589
608
|
end
|
@@ -608,6 +627,7 @@ module PayPal::SDK
|
|
608
627
|
# A response that contains a table of estimated converted currencies based on the Convert Currency Request.
|
609
628
|
class ConvertCurrencyResponse < DataType
|
610
629
|
def self.load_members
|
630
|
+
include ResponseStatus
|
611
631
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
612
632
|
object_of :estimatedAmountTable, CurrencyConversionTable, :required => true
|
613
633
|
array_of :error, ErrorData
|
@@ -651,6 +671,7 @@ module PayPal::SDK
|
|
651
671
|
# The result of a payment execution.
|
652
672
|
class ExecutePaymentResponse < DataType
|
653
673
|
def self.load_members
|
674
|
+
include ResponseStatus
|
654
675
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
655
676
|
object_of :paymentExecStatus, String, :required => true
|
656
677
|
object_of :payErrorList, PayErrorList
|
@@ -674,6 +695,7 @@ module PayPal::SDK
|
|
674
695
|
# The response to get the backup funding sources available for a preapproval.
|
675
696
|
class GetAllowedFundingSourcesResponse < DataType
|
676
697
|
def self.load_members
|
698
|
+
include ResponseStatus
|
677
699
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
678
700
|
array_of :fundingSource, FundingSource
|
679
701
|
array_of :error, ErrorData
|
@@ -695,6 +717,7 @@ module PayPal::SDK
|
|
695
717
|
# The response message for the GetPaymentOption request
|
696
718
|
class GetPaymentOptionsResponse < DataType
|
697
719
|
def self.load_members
|
720
|
+
include ResponseStatus
|
698
721
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
699
722
|
object_of :initiatingEntity, InitiatingEntity
|
700
723
|
object_of :displayOptions, DisplayOptions
|
@@ -722,6 +745,7 @@ module PayPal::SDK
|
|
722
745
|
# The details of the PayRequest as specified in the Pay operation.
|
723
746
|
class PaymentDetailsResponse < DataType
|
724
747
|
def self.load_members
|
748
|
+
include ResponseStatus
|
725
749
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
726
750
|
object_of :cancelUrl, String, :required => true
|
727
751
|
object_of :currencyCode, String, :required => true
|
@@ -773,10 +797,13 @@ module PayPal::SDK
|
|
773
797
|
# The PayResponse contains the result of the Pay operation. The payKey and execution status of the request should always be provided.
|
774
798
|
class PayResponse < DataType
|
775
799
|
def self.load_members
|
800
|
+
include ResponseStatus
|
776
801
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
777
802
|
object_of :payKey, String, :required => true
|
778
803
|
object_of :paymentExecStatus, String, :required => true
|
779
804
|
object_of :payErrorList, PayErrorList
|
805
|
+
object_of :paymentInfoList, PaymentInfoList, :required => true
|
806
|
+
object_of :sender, SenderIdentifier
|
780
807
|
object_of :defaultFundingPlan, FundingPlan
|
781
808
|
object_of :warningDataList, WarningDataList
|
782
809
|
array_of :error, ErrorData
|
@@ -799,6 +826,7 @@ module PayPal::SDK
|
|
799
826
|
# The details of the Preapproval as specified in the Preapproval operation.
|
800
827
|
class PreapprovalDetailsResponse < DataType
|
801
828
|
def self.load_members
|
829
|
+
include ResponseStatus
|
802
830
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
803
831
|
object_of :approved, Boolean, :required => true
|
804
832
|
object_of :cancelUrl, String, :required => true
|
@@ -865,6 +893,7 @@ module PayPal::SDK
|
|
865
893
|
# The result of the PreapprovalRequest is a preapprovalKey.
|
866
894
|
class PreapprovalResponse < DataType
|
867
895
|
def self.load_members
|
896
|
+
include ResponseStatus
|
868
897
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
869
898
|
object_of :preapprovalKey, String, :required => true
|
870
899
|
array_of :error, ErrorData
|
@@ -890,6 +919,7 @@ module PayPal::SDK
|
|
890
919
|
# The result of a Refund request.
|
891
920
|
class RefundResponse < DataType
|
892
921
|
def self.load_members
|
922
|
+
include ResponseStatus
|
893
923
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
894
924
|
object_of :currencyCode, String, :required => true
|
895
925
|
object_of :refundInfoList, RefundInfoList, :required => true
|
@@ -917,6 +947,7 @@ module PayPal::SDK
|
|
917
947
|
# The response message for the SetPaymentOption request
|
918
948
|
class SetPaymentOptionsResponse < DataType
|
919
949
|
def self.load_members
|
950
|
+
include ResponseStatus
|
920
951
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
921
952
|
array_of :error, ErrorData
|
922
953
|
end
|
@@ -937,6 +968,7 @@ module PayPal::SDK
|
|
937
968
|
# The response to get the funding plans available for a payment.
|
938
969
|
class GetFundingPlansResponse < DataType
|
939
970
|
def self.load_members
|
971
|
+
include ResponseStatus
|
940
972
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
941
973
|
array_of :fundingPlan, FundingPlan
|
942
974
|
array_of :error, ErrorData
|
@@ -959,6 +991,7 @@ module PayPal::SDK
|
|
959
991
|
# The response to get the shipping addresses available for a payment.
|
960
992
|
class GetAvailableShippingAddressesResponse < DataType
|
961
993
|
def self.load_members
|
994
|
+
include ResponseStatus
|
962
995
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
963
996
|
array_of :availableAddress, Address
|
964
997
|
array_of :error, ErrorData
|
@@ -981,6 +1014,7 @@ module PayPal::SDK
|
|
981
1014
|
# The response to get the shipping addresses available for a payment.
|
982
1015
|
class GetShippingAddressesResponse < DataType
|
983
1016
|
def self.load_members
|
1017
|
+
include ResponseStatus
|
984
1018
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
985
1019
|
object_of :selectedAddress, Address
|
986
1020
|
array_of :error, ErrorData
|
@@ -1007,6 +1041,7 @@ module PayPal::SDK
|
|
1007
1041
|
# A response that contains a list of remaining limits
|
1008
1042
|
class GetUserLimitsResponse < DataType
|
1009
1043
|
def self.load_members
|
1044
|
+
include ResponseStatus
|
1010
1045
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
1011
1046
|
array_of :userLimit, UserLimit, :required => true
|
1012
1047
|
object_of :warningDataList, WarningDataList
|
@@ -1105,6 +1140,7 @@ module PayPal::SDK
|
|
1105
1140
|
# GetPrePaymentDisclosureResponse contains the information related to PrePayment disclosure. status : indicates the status of response. If Status = RTR then it means that this is RTR transaction. If Status = NON_RTR then it means that this is non RTR transaction. If Status = MISSING_RECEIVER_COUNTRY_INFORMATION then it means the Receiver country information is not found in PayPal database. So merchant has to call the API again with same set of parameter along with Receiver country code.This is useful in case of Unilateral scenario. where receiver is not holding paypal account. feePayer:Indicates who has agreed to Pay a Fee for the RTR transaction. Merchant can use this information to decide who actually has to pay the fee . senderDisclosure : This Variable Holds the disclosure related to sender. receiverDisclosureList : This list contains the disclosure information related to receivers. Merchant can just parse the details what ever is avaliable in the response and display the same to user.
|
1106
1141
|
class GetPrePaymentDisclosureResponse < DataType
|
1107
1142
|
def self.load_members
|
1143
|
+
include ResponseStatus
|
1108
1144
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
1109
1145
|
object_of :status, Status, :required => true
|
1110
1146
|
object_of :feesPayer, String
|
@@ -0,0 +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
|
@@ -10,67 +10,110 @@ describe "AdaptivePayments" do
|
|
10
10
|
describe "Examples" do
|
11
11
|
it "Pay" do
|
12
12
|
# Build request object
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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" })
|
22
24
|
|
23
25
|
# Make API call & get response
|
24
|
-
@pay_response = @api.pay(@
|
25
|
-
@pay_response.
|
26
|
+
@pay_response = @api.pay(@pay)
|
27
|
+
@pay_response.should be_success
|
26
28
|
|
27
29
|
@payment_details_request = @api.build_payment_details()
|
28
30
|
@payment_details_request.payKey = @pay_response.payKey
|
29
31
|
@payment_details_response = @api.payment_details(@payment_details_request)
|
30
|
-
@payment_details_response.
|
32
|
+
@payment_details_response.should be_success
|
31
33
|
|
32
34
|
# Make API call & get response
|
33
|
-
@pay_response = @api_with_cert.pay(@
|
34
|
-
@pay_response.
|
35
|
+
@pay_response = @api_with_cert.pay(@pay)
|
36
|
+
@pay_response.should be_success
|
35
37
|
|
36
38
|
@payment_details_request = @api_with_cert.build_payment_details()
|
37
39
|
@payment_details_request.payKey = @pay_response.payKey
|
38
40
|
@payment_details_response = @api_with_cert.payment_details(@payment_details_request)
|
39
|
-
@payment_details_response.
|
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
|
40
55
|
end
|
41
56
|
|
42
57
|
it "Preapproval" do
|
43
|
-
|
44
|
-
@
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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" })
|
50
65
|
|
51
66
|
# Make API call & get response
|
52
|
-
@preapproval_response = @api.preapproval(@
|
53
|
-
@preapproval_response.
|
67
|
+
@preapproval_response = @api.preapproval(@preapproval)
|
68
|
+
@preapproval_response.should be_success
|
54
69
|
|
55
70
|
@preapproval_details_request = @api.build_preapproval_details()
|
56
71
|
@preapproval_details_request.preapprovalKey = @preapproval_response.preapprovalKey
|
57
72
|
@preapproval_details_response = @api.preapproval_details(@preapproval_details_request)
|
58
|
-
@preapproval_details_response.
|
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
|
59
97
|
end
|
60
98
|
|
61
99
|
it "Convert currency" do
|
62
100
|
# Build request object
|
63
|
-
@
|
64
|
-
|
65
|
-
|
66
|
-
|
101
|
+
@convert_currency = @api.build_convert_currency({
|
102
|
+
:baseAmountList => {
|
103
|
+
:currency => [{
|
104
|
+
:code => "USD",
|
105
|
+
:amount => 2.0 }] },
|
106
|
+
:convertToCurrencyList => {
|
107
|
+
:currencyCode => ["GBP"] } })
|
67
108
|
|
68
109
|
# Make API call & get response
|
69
|
-
@convert_currency_response = @api.convert_currency(@
|
70
|
-
@convert_currency_response.
|
110
|
+
@convert_currency_response = @api.convert_currency(@convert_currency)
|
111
|
+
@convert_currency_response.should be_success
|
71
112
|
end
|
72
113
|
|
73
|
-
|
114
|
+
it "Validate ipn message" do
|
115
|
+
@api.ipn_valid?("Invalid").should be_false
|
116
|
+
end
|
74
117
|
|
75
118
|
end
|
76
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-sdk-adaptivepayments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.101.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PayPal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paypal-sdk-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.3
|
27
27
|
description: The PayPal Adaptive Payments SDK provides Ruby APIs to create, process
|
28
28
|
and manage simple and complex (parallel and chained) payments, and pre-approvals
|
29
29
|
using the Adaptive Payments API.
|
@@ -38,9 +38,9 @@ files:
|
|
38
38
|
- spec/convert_currency_spec.rb
|
39
39
|
- spec/config/paypal.yml
|
40
40
|
- spec/config/cert_key.pem
|
41
|
-
- spec/adaptive_payments_spec.rb
|
42
41
|
- lib/paypal-sdk-adaptivepayments.rb
|
43
42
|
- lib/paypal-sdk/adaptive_payments/services.rb
|
43
|
+
- lib/paypal-sdk/adaptive_payments/urls.rb
|
44
44
|
- lib/paypal-sdk/adaptive_payments/api.rb
|
45
45
|
- lib/paypal-sdk/adaptive_payments/version.rb
|
46
46
|
- lib/paypal-sdk/adaptive_payments/data_types.rb
|
@@ -77,4 +77,3 @@ test_files:
|
|
77
77
|
- spec/convert_currency_spec.rb
|
78
78
|
- spec/config/paypal.yml
|
79
79
|
- spec/config/cert_key.pem
|
80
|
-
- spec/adaptive_payments_spec.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "AdaptivePayments" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@client = PayPal::SDK::AdaptivePayments::API.new
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "Services" do
|
10
|
-
PayPal::SDK::AdaptivePayments::Services.instance_methods.select{|s| s =~ /^[A-Z]/ and s !~ /^Build/ }.each do |service_method|
|
11
|
-
it "make empty request to #{service_method}" do
|
12
|
-
response = @client.send(service_method, {})
|
13
|
-
response.response_envelope.ack.should_not be_nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "DataTypes" do
|
19
|
-
PayPal::SDK::AdaptivePayments::DataTypes.constants.each do |const_name|
|
20
|
-
it "create object for #{const_name}" do
|
21
|
-
klass = PayPal::SDK::AdaptivePayments::DataTypes.const_get(const_name)
|
22
|
-
klass.new.should be_a klass
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|