paypal-sdk-buttonmanager 1.96.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'paypal-sdk-core', :git => "https://github.com/paypal/sdk-core-ruby.git"
6
+
7
+ if Dir.exist? File.expand_path('../samples', __FILE__)
8
+ gem 'button_manager_samples', :path => 'samples', :require => false
9
+ group :test do
10
+ gem 'rspec-rails', :require => false
11
+ gem 'capybara', :require => false
12
+ end
13
+ end
14
+
15
+ group :test do
16
+ gem 'rspec'
17
+ end
data/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # ButtonManager
2
+
3
+ SDK for ButtonManager.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'paypal-sdk-buttonmanager'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install paypal-sdk-buttonmanager
18
+
19
+ ## Configuration
20
+
21
+ For Rails application:
22
+
23
+ rails g paypal:sdk:install
24
+
25
+ For other ruby application, create a configuration file(`config/paypal.yml`):
26
+
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
+ sandbox_email_address: Platform.sdk.seller@gmail.com
35
+ # # with certificate
36
+ # cert_path: "config/cert_key.pem"
37
+ # # with token authentication
38
+ # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
39
+ # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
40
+ # # with Proxy
41
+ # http_proxy: http://proxy-ipaddress:3129/
42
+ # # with device ip address
43
+ # device_ipaddress: "127.0.0.1"
44
+ test:
45
+ <<: *default
46
+ production:
47
+ <<: *default
48
+ mode: live
49
+
50
+ Load Configurations from specified file:
51
+
52
+ PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
53
+
54
+ ## Create API object
55
+
56
+ Create API object:
57
+
58
+ api = PayPal::SDK::ButtonManager::API.new
59
+
60
+ Override configuration while creating a object:
61
+
62
+ api = PayPal::SDK::ButtonManager::API.new(:development)
63
+ api = PayPal::SDK::ButtonManager::API.new(:development, :app_id => "XYZ")
64
+ api = PayPal::SDK::ButtonManager::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
77
+ bm_create_button_request = api.build_bm_create_button()
78
+
79
+ # To build a request object with default data
80
+ bm_create_button_request = api.build_bm_create_button( :ButtonType => "BUYNOW", :ButtonCode => "HOSTED" )
81
+
82
+ # To build a request object with block
83
+ bm_create_button_request = api.build_bm_create_button do
84
+ self.ButtonType = "BUYNOW"
85
+ self.ButtonCode = "HOSTED"
86
+ end
87
+
88
+ The Build method can be access with camelcase or underscore:
89
+
90
+ api = api.build_bm_create_button()
91
+ # (or)
92
+ api = api.BuildBMCreateButton()
93
+
94
+ ## Assign value to members
95
+
96
+ Members can be access with camelcase or underscore format.
97
+
98
+ bm_create_button_request.ButtonType = "BUYNOW"
99
+ # With underscore
100
+ bm_create_button_request.button_type = "BUYNOW"
101
+
102
+ To Get members list for the given object( For Reference ):
103
+
104
+ bm_create_button_request.members
105
+
106
+ ## Make API Request
107
+
108
+ Make api call with request object:
109
+
110
+ bm_create_button_response = api.bm_create_button(bm_create_button_request)
111
+
112
+ Make api call with hash:
113
+
114
+ bm_create_button_response = api.bm_create_button( :ButtonType => "BUYNOW", :ButtonCode => "HOSTED" )
115
+
116
+ ## Access values from response object
117
+
118
+ To get response status:
119
+
120
+ bm_create_button_response.ack
121
+
122
+ ## Example
123
+
124
+ ```ruby
125
+ require 'paypal-sdk-buttonmanager'
126
+ @api = PayPal::SDK::ButtonManager::API.new
127
+
128
+ # Build request object
129
+ @bm_create_button_request = @api.build_bm_create_button()
130
+ @bm_create_button_request.ButtonType = "BUYNOW"
131
+ @bm_create_button_request.ButtonCode = "HOSTED"
132
+ @bm_create_button_request.ButtonVar = ["item_name=Item","amount=5","return=http//localhost:3000"]
133
+
134
+ # Make API call & get response
135
+ @bm_create_button_response = @api.bm_create_button(@bm_create_button_request)
136
+
137
+ # Access Response
138
+ @bm_create_button_response.Timestamp
139
+ @bm_create_button_response.Ack
140
+ @bm_create_button_response.CorrelationID
141
+ @bm_create_button_response.Version
142
+ @bm_create_button_response.Build
143
+ @bm_create_button_response.Website
144
+ @bm_create_button_response.Email
145
+ @bm_create_button_response.HostedButtonID
146
+ ```
147
+
148
+ ## Samples
149
+
150
+ Add following line in rails `Gemfile`:
151
+
152
+ gem 'paypal-sdk-buttonmanager'
153
+ gem 'button_manager_samples', :git => "https://github.com/paypal/buttonmanager-sdk-ruby.git", :group => :development
154
+
155
+ Configure routes(`config/routes.rb`):
156
+
157
+ mount ButtonManagerSamples::Engine => "/samples" if Rails.env.development?
158
+
159
+ To get default paypal configuration execute:
160
+
161
+ rails g paypal:sdk:install
162
+
163
+ Run `rails server` and check the samples.
164
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Run tests"
4
+ task :rspec do
5
+ cmd = "bundle exec rspec && cd samples && bundle exec rspec"
6
+ system(cmd) || raise("#{cmd} failed")
7
+ end
8
+
9
+ desc "View samples"
10
+ task :samples do
11
+ system("cd samples/spec/dummy && bundle exec rails server")
12
+ end
13
+
14
+ task :default => :rspec
@@ -0,0 +1,21 @@
1
+ require 'paypal-sdk-core'
2
+
3
+ module PayPal
4
+ module SDK
5
+ module ButtonManager
6
+ class API < Core::API::Merchant
7
+ include Services
8
+
9
+ def initialize(environment = nil, options = {})
10
+ super("", environment, options)
11
+ end
12
+
13
+ ADAPTIVE_PAYMENTS_HTTP_HEADER = { "X-PAYPAL-REQUEST-SOURCE" => "buttonmanager-ruby-sdk-#{VERSION}" }
14
+ def default_http_header
15
+ super.merge(ADAPTIVE_PAYMENTS_HTTP_HEADER)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+