paypal-sdk-merchant 1.98.1 → 1.98.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTliNTI4N2JkM2U2NDNlMjcyYmY4NDYzZDYxNWU3OGMxMGEyZGQ5Yg==
4
+ ZGU2MGE1N2M1OGQ2OTNjY2YzZjljNDRmNjVjMGI3NzViNWY0NTFmOQ==
5
5
  data.tar.gz: !binary |-
6
- MmMwZWE2MTQxNzk1OGQ0YmNhY2Y4YTJjMjg5NGRlZjZmNjc0NjI5Zg==
6
+ YmZjODIyN2FjNmJmZWJiOGZkYjQ1MWMyNTIwOWI0ZWNlZGE3Njc1Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MzBmYTc2ZTQ4NjgxNzI2NDAxOWJiY2Y2Mjk4MWMzZTVkMjU5ZjRkZmZiZjI1
10
- YzA4ZmIxNDZjMzRiYWFiMDcyZThiMmIyMmQwZjZkN2M3ZDFiNGUzOGU5OWY1
11
- M2Q5MWI1ZjAwOTkyODAyZDRkOTU5OGU0YWRjNzA0ZjZhNGIxZDA=
9
+ ZGY5NzlmYzE0NGUwYTM3YzBlZGNkMzU0NjlmNWUzMmFjYzhlZDk5OTI2YWQ3
10
+ MTU0M2Q3NGJiMTEwZGU1MThiYjgwYThkNjExNTQyZTc5MWM1YTRhNDRmZDRl
11
+ NjVhODQ0YTk2YTc1NWNhN2ZkZjQ1OGZhNTAxZmMyNmFlYmM5MTU=
12
12
  data.tar.gz: !binary |-
13
- MzQyZDAxNGIwMzBkYWEyZDU4ZWY2MTU3OTM0NTA3NmMwYTI5YWYyOTIwNjFi
14
- MGE1ZjM3YWUxNDdlNmVmMTRlYjhjNjFmZGY2OWY5YTM5YjM3MmJkNzI3ZDVi
15
- ZDkwMjcwMTg5NGM4MjY0MzkzZjU2OTZiMjAyNDk2NjQ5ZWE1MmU=
13
+ MDUzMTQzYzcwNWE0ZDU4Yjk0OWY0YTg2ZDY3YzQ4M2FmYzQ3MDUxYWY1ZjQ4
14
+ YTcyY2FkOTgwOTQ1OTMzZGNlNmU0YmRkNmY4YzM4ODk3NWIxYzFlMTY2YzY2
15
+ MTg2OWQ1MjcxNzQ5MTY4OTUwNzNmMzM4ODU3ZGNjZWMwYjUxOTQ=
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ if File.exist? File.expand_path('../samples/merchant_samples.gemspec', __FILE__)
8
8
  gem 'merchant_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,110 +6,59 @@ The PayPal Merchant SDK provides Ruby APIs for processing payments, recurring pa
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'paypal-sdk-merchant'
9
+ ```ruby
10
+ gem 'paypal-sdk-merchant'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ ```sh
16
+ $ bundle
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
- $ gem install paypal-sdk-merchant
21
+ ```sh
22
+ $ gem install paypal-sdk-merchant
23
+ ```
18
24
 
19
25
  ## Configuration
20
26
 
21
27
  For Rails application:
22
28
 
23
- rails g paypal:sdk:install
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
- development: &default
28
- username: jb-us-seller_api1.paypal.com
29
- password: WX4WTU3S8MY44S7F
30
- signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
31
- app_id: APP-80W284485P519543T
32
- http_timeout: 30
33
- mode: sandbox
34
- # # with certificate
35
- # cert_path: "config/cert_key.pem"
36
- # # with token authentication
37
- # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
38
- # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
39
- # # with Proxy
40
- # http_proxy: http://proxy-ipaddress:3129/
41
- test:
42
- <<: *default
43
- production:
44
- <<: *default
45
- mode: live
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
+ # # with certificate
44
+ # cert_path: "config/cert_key.pem"
45
+ # # with token authentication
46
+ # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
47
+ # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
48
+ # # with Proxy
49
+ # http_proxy: http://proxy-ipaddress:3129/
50
+ test:
51
+ <<: *default
52
+ production:
53
+ <<: *default
54
+ mode: live
55
+ ```
46
56
 
47
57
  Load Configurations from specified file:
48
58
 
49
- PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
50
-
51
- ## Create API object
52
-
53
- Create API object:
54
-
55
- api = PayPal::SDK::Merchant::API.new
56
-
57
- Override configuration while creating a object:
58
-
59
- api = PayPal::SDK::Merchant::API.new(:development)
60
- api = PayPal::SDK::Merchant::API.new(:development, :app_id => "XYZ")
61
- api = PayPal::SDK::Merchant::API.new(:app_id => "XYZ") # Take default environment.
62
-
63
- Change configuration:
64
-
65
- api.set_config :testing
66
- api.set_config :testing, app_id => "XYZ"
67
-
68
-
69
- ## Build Request Object
70
-
71
- To make api request, we need to build a request object.
72
-
73
- # To build a empty request object
74
- transaction_search_request = api.build_transaction_search()
75
-
76
- # To build a request object with default data
77
- transaction_search_request = api.build_transaction_search( :StartDate => "2012-11-11T11:30:00+00:00", :EndDate => "2012-11-11T11:31:00+00:00" )
78
-
79
- The Build method can be access with camelcase or underscore:
80
-
81
- api = api.build_transaction_search()
82
- # (or)
83
- api = api.BuildTransactionSearch()
84
-
85
- ## Assign value to members
86
-
87
- Members can be access with camelcase or underscore format.
88
-
89
- transaction_search_request.StartDate = "2012-11-11T11:30:00+00:00"
90
- # With underscore
91
- transaction_search_request.start_date = "2012-11-11T11:30:00+00:00"
92
-
93
- To Get members list for the given object( For Reference ):
94
-
95
- transaction_search_request.members
96
-
97
- ## Make API Request
98
-
99
- Make api call with request object:
100
-
101
- transaction_search_response = api.transaction_search(transaction_search_request)
102
-
103
- Make api call with hash:
104
-
105
- transaction_search_response = api.transaction_search( :StartDate => "2012-11-11T11:30:00+00:00", :EndDate => "2012-11-11T11:31:00+00:00" )
106
-
107
- ## Access values from response object
108
-
109
- To get response status:
110
-
111
- transaction_search_response.ack
112
-
59
+ ```ruby
60
+ PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
61
+ ```
113
62
 
114
63
  ## Example
115
64
 
@@ -142,24 +91,36 @@ require 'paypal-sdk-merchant'
142
91
  @do_direct_payment_response = @api.do_direct_payment(@do_direct_payment)
143
92
 
144
93
  # Access Response
145
- @do_direct_payment_response.Ack
146
- @do_direct_payment_response.TransactionID
94
+ if @do_direct_payment_response.success?
95
+ @do_direct_payment_response.TransactionID
96
+ else
97
+ @do_direct_payment_response.Errors
98
+ end
99
+
147
100
  ```
148
101
 
102
+ For more samples [paypal-sdk-samples.herokuapp.com/merchant/](https://paypal-sdk-samples.herokuapp.com/merchant/)
103
+
149
104
  ## Samples
150
105
 
151
106
  Add following line in rails `Gemfile`:
152
107
 
153
- gem 'paypal-sdk-merchant'
154
- gem 'merchant_samples', :git => "https://github.com/paypal/merchant-sdk-ruby.git", :group => :development
108
+ ```ruby
109
+ gem 'paypal-sdk-merchant'
110
+ gem 'merchant_samples', :git => "https://github.com/paypal/merchant-sdk-ruby.git", :group => :development
111
+ ```
155
112
 
156
113
  Configure routes(`config/routes.rb`):
157
114
 
158
- mount MerchantSamples::Engine => "/samples" if Rails.env.development?
115
+ ```ruby
116
+ mount MerchantSamples::Engine => "/samples" if Rails.env.development?
117
+ ```
159
118
 
160
119
  To get default paypal configuration execute:
161
120
 
162
- rails g paypal:sdk:install
121
+ ```sh
122
+ rails g paypal:sdk:install
123
+ ```
163
124
 
164
125
  Run `rails server` and check the samples.
165
126
 
@@ -7,6 +7,7 @@ module PayPal
7
7
  autoload :VERSION, "paypal-sdk/merchant/version"
8
8
  autoload :Services, "paypal-sdk/merchant/services"
9
9
  autoload :DataTypes, "paypal-sdk/merchant/data_types_with_bugfix"
10
+ autoload :Urls, "paypal-sdk/merchant/urls"
10
11
  autoload :API, "paypal-sdk/merchant/api"
11
12
 
12
13
  def self.new(*args)
@@ -5,6 +5,7 @@ module PayPal
5
5
  module Merchant
6
6
  class API < Core::API::Merchant
7
7
  include Services
8
+ include Urls
8
9
 
9
10
  def initialize(environment = nil, options = {})
10
11
  super("", environment, options)
@@ -14,6 +15,11 @@ module PayPal
14
15
  def default_http_header
15
16
  super.merge(MERCHANT_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.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
 
@@ -634,6 +650,7 @@ module PayPal::SDK
634
650
  def self.load_members
635
651
  # This value represents the date and time (GMT) when the response was generated by a service provider (as a result of processing of a request).
636
652
  object_of :Timestamp, DateTime, :namespace => :ebl
653
+ include ResponseStatus
637
654
  # Application level acknowledgement code.
638
655
  object_of :Ack, AckCodeType, :namespace => :ebl
639
656
  # CorrelationID may be used optionally with an application level acknowledgement.
@@ -0,0 +1,20 @@
1
+ module PayPal
2
+ module SDK
3
+ module Merchant
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 express_checkout_url(token)
14
+ token = token.Token if token.respond_to?(:Token)
15
+ redirect_url( :cmd => "_express-checkout", :token => token.to_s )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,7 +1,7 @@
1
1
  module PayPal
2
2
  module SDK
3
3
  module Merchant
4
- VERSION = "1.98.1"
4
+ VERSION = "1.98.2"
5
5
  end
6
6
  end
7
7
  end
@@ -16,10 +16,20 @@ describe "Merchant" do
16
16
 
17
17
  # Make API call & get response
18
18
  @transaction_search_response = @api.transaction_search(@transaction_search)
19
- @transaction_search_response.Ack.should eql "Success"
19
+ @transaction_search_response.should be_success
20
+ @transaction_search_response.should_not be_failure
21
+
22
+ @transaction_search_response = @api.transaction_search({})
23
+ @transaction_search_response.should be_failure
24
+ @transaction_search_response.should_not be_success
20
25
 
21
26
  @transaction_search_response = @api_with_cert.transaction_search(@transaction_search)
22
- @transaction_search_response.Ack.should eql "Success"
27
+ @transaction_search_response.should be_success
28
+ @transaction_search_response.should_not be_failure
29
+
30
+ @transaction_search_response = @api_with_cert.transaction_search({})
31
+ @transaction_search_response.should be_failure
32
+ @transaction_search_response.should_not be_success
23
33
  end
24
34
 
25
35
  it "get balance" do
@@ -30,7 +40,7 @@ describe "Merchant" do
30
40
  # Make API call & get response
31
41
  @get_balance_response = @api.get_balance(@get_balance)
32
42
 
33
- @get_balance_response.Ack.should eql "Success"
43
+ @get_balance_response.should be_success
34
44
  end
35
45
 
36
46
  it "get pal detail" do
@@ -40,7 +50,7 @@ describe "Merchant" do
40
50
  # Make API call & get response
41
51
  @get_pal_details_response = @api.get_pal_details(@get_pal_details)
42
52
 
43
- @get_pal_details_response.Ack.should eql "Success"
53
+ @get_pal_details_response.should be_success
44
54
  end
45
55
 
46
56
  it "Set auth flow param" do
@@ -53,7 +63,7 @@ describe "Merchant" do
53
63
  # Make API call & get response
54
64
  @set_auth_flow_param_response = @api.set_auth_flow_param(@set_auth_flow_param)
55
65
 
56
- @set_auth_flow_param_response.Ack.should eql "Success"
66
+ @set_auth_flow_param_response.should be_success
57
67
  end
58
68
 
59
69
 
@@ -83,11 +93,11 @@ describe "Merchant" do
83
93
 
84
94
  # Make API call & get response
85
95
  @do_direct_payment_response = @api.do_direct_payment(@do_direct_payment)
86
- @do_direct_payment_response.Ack.should eql "Success"
96
+ @do_direct_payment_response.should be_success
87
97
 
88
98
  # Make API call & get response
89
99
  @do_direct_payment_response = @api_with_cert.do_direct_payment(@do_direct_payment)
90
- @do_direct_payment_response.Ack.should eql "Success"
100
+ @do_direct_payment_response.should be_success
91
101
  end
92
102
 
93
103
  it "Mass pay" do
@@ -102,7 +112,12 @@ describe "Merchant" do
102
112
 
103
113
  # Make API call & get response
104
114
  @mass_pay_response = @api.mass_pay(@mass_pay)
105
- @mass_pay_response.Ack.should eql "Success"
115
+ @mass_pay_response.should be_success
106
116
  end
117
+
118
+ it "Validate ipn message" do
119
+ @api.ipn_valid?("Invalid").should be_false
120
+ end
121
+
107
122
  end
108
123
  end
@@ -7,9 +7,9 @@ describe "Merchant" do
7
7
  end
8
8
 
9
9
  describe "Services" do
10
- Actions = PayPal::SDK::Merchant::Services.instance_methods.select{|s| s =~ /^[A-Z]/ and s !~ /^Build/ } -
11
- [ :CompleteRecoup, "CompleteRecoup", :GetIncentiveEvaluation, "GetIncentiveEvaluation" ]
12
- Actions.each do |service_method|
10
+ actions = PayPal::SDK::Merchant::Services.instance_methods.select{|s| s =~ /^[A-Z]/ and s !~ /^Build/ } -
11
+ [ :GetIncentiveEvaluation, "GetIncentiveEvaluation" ]
12
+ actions.each do |service_method|
13
13
  it "make empty request to #{service_method}" do
14
14
  response = @client.send(service_method, {})
15
15
  response.ack.should_not be_nil
@@ -17,13 +17,4 @@ describe "Merchant" do
17
17
  end
18
18
  end
19
19
 
20
- describe "DataTypes" do
21
- PayPal::SDK::Merchant::DataTypes.constants.each do |const_name|
22
- it "create object for #{const_name}" do
23
- klass = PayPal::SDK::Merchant::DataTypes.const_get(const_name)
24
- klass.new.should be_a klass
25
- end
26
- end
27
- end
28
-
29
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-sdk-merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.98.1
4
+ version: 1.98.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-12 00:00:00.000000000 Z
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.0
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.0
26
+ version: 0.2.3
27
27
  description: The PayPal Merchant SDK provides Ruby APIs for processing payments, recurring
28
28
  payments, subscriptions and transactions using PayPal's Merchant APIs, which include
29
29
  Express Checkout, Recurring Payments, Direct Payment and Transactional APIs.
@@ -40,6 +40,7 @@ files:
40
40
  - spec/merchant_spec.rb
41
41
  - lib/paypal-sdk-merchant.rb
42
42
  - lib/paypal-sdk/merchant/services.rb
43
+ - lib/paypal-sdk/merchant/urls.rb
43
44
  - lib/paypal-sdk/merchant/data_types_with_bugfix.rb
44
45
  - lib/paypal-sdk/merchant/api.rb
45
46
  - lib/paypal-sdk/merchant/version.rb