mastercard_merchant_checkout 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d3013606b83bbc5205c1fb604e17c3bc39c09ad
4
+ data.tar.gz: dce52cdb88b5ebb3f90fd24cb85661a3450f45d0
5
+ SHA512:
6
+ metadata.gz: 087a2cd184634dde1a36585a2b66e866157c607ebd12ecab21a7b6698e0ab5851886f726455701e3137f6f04fe95db0dbcabe36002a8b790b0625dbd57483b54
7
+ data.tar.gz: 82282ca011385ef0952a1ab19b75f077865af73fd5fb3ecd95d46933be272bfa6db528d270108507e6efc629763e5981793f7e17e0233e8e1b4f4510a66a33a8
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2017, MasterCard International Incorporated
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are
5
+ permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of
8
+ conditions and the following disclaimer.
9
+ Redistributions in binary form must reproduce the above copyright notice, this list of
10
+ conditions and the following disclaimer in the documentation and/or other materials
11
+ provided with the distribution.
12
+ Neither the name of the MasterCard International Incorporated nor the names of its
13
+ contributors may be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
18
+ SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
@@ -0,0 +1,73 @@
1
+ # MastercardMerchantCheckout
2
+ Masterpass™ is Mastercard’s integrated digital wallet and checkout solution.
3
+ Masterpass enables consumers to store and manage their payment, shipping, and loyalty program information
4
+ in their Masterpass Wallet, and to quickly and seamlessly access this information to make secure payments
5
+ wherever they see the "Buy with MasterPass" button on a merchant website or mobile application.
6
+
7
+ From a cardholder's perspective, Masterpass significantly speeds up the checkout process, removing the need
8
+ to re-enter payment, shipping or loyalty program details during checkout.
9
+ The Masterpass solution is simple, secure and easy for merchants to integrate into their existing website or application.
10
+
11
+ For more information, refer [Masterpass Merchant Integration](https://developer.mastercard.com/documentation/masterpass-merchant-integration/v7).
12
+
13
+ ## Features
14
+
15
+ Simplified merchant checkout flow with new Masterpass checkout API services.
16
+
17
+ Supports Masterpass Standard checkout.
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'mastercard_merchant_checkout'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install mastercard_merchant_checkout
34
+
35
+ ## Usage
36
+ Set configurations for Consumer Key & Private Key from [Mastercard's developer's site](https://developer.mastercard.com/) to call Mastercard's checkout APIs:
37
+
38
+ ```
39
+ require 'mastercard_core_sdk'
40
+ require 'mastercard_merchant_checkout'
41
+
42
+ MasterCardApiConfiguration.consumer_key = <Consumer Key>
43
+ MasterCardApiConfiguration.private_key = OpenSSL::PKCS12.new(File.open(<Path to P12 file>), <Password>).key
44
+ MasterCardApiConfiguration.sandbox = false #By default Sandbox environment is set to true, Set sandbox to false to use Production environment.
45
+ ```
46
+
47
+ ## Copyright
48
+ Copyright (c) 2017, Mastercard International Incorporated. See LICENSE for details.
49
+
50
+ ## LICENSE
51
+ Copyright (c) 2017, Mastercard International Incorporated. All rights reserved.
52
+
53
+ Redistribution and use in source and binary forms, with or without modification, are
54
+ permitted provided that the following conditions are met:
55
+
56
+ Redistributions of source code must retain the above copyright notice, this list of
57
+ conditions and the following disclaimer.
58
+ Redistributions in binary form must reproduce the above copyright notice, this list of
59
+ conditions and the following disclaimer in the documentation and/or other materials
60
+ provided with the distribution.
61
+ Neither the name of the Mastercard International Incorporated nor the names of its
62
+ contributors may be used to endorse or promote products derived from this software
63
+ without specific prior written permission.
64
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
65
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
66
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
67
+ SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
68
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
69
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
70
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
71
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
72
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73
+ SUCH DAMAGE.
@@ -0,0 +1,32 @@
1
+ # Common files
2
+ require_relative 'mastercard_merchant_checkout/version'
3
+ require_relative 'mastercard_merchant_checkout/tracker/sdk_api_tracker'
4
+
5
+ # Models
6
+
7
+ require_relative 'mastercard_merchant_checkout/models/payment_data'
8
+
9
+ require_relative 'mastercard_merchant_checkout/models/card'
10
+
11
+ require_relative 'mastercard_merchant_checkout/models/address'
12
+
13
+ require_relative 'mastercard_merchant_checkout/models/personal_info'
14
+
15
+ require_relative 'mastercard_merchant_checkout/models/postback'
16
+
17
+ require_relative 'mastercard_merchant_checkout/models/authentication_options'
18
+
19
+
20
+ # APIs
21
+
22
+
23
+ require_relative 'mastercard_merchant_checkout/api/postback_api'
24
+
25
+ require_relative 'mastercard_merchant_checkout/api/payment_data_api'
26
+
27
+
28
+
29
+
30
+ module MastercardMerchantCheckout
31
+
32
+ end
@@ -0,0 +1,40 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_merchant_checkout/models/payment_data'
4
+
5
+
6
+ module MastercardMerchantCheckout
7
+ module Api
8
+
9
+ class PaymentDataApi
10
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
11
+ include MastercardMerchantCheckout::Tracker
12
+
13
+
14
+ # PaymentData Service
15
+ # This service is used to retrieve the consumer's payment, shipping address, and recipient personal information from Masterpass.
16
+ # @param transaction_id This is a transaction identifier.
17
+ # @param query_params The query parameters.
18
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
19
+ # @return [PaymentData]
20
+ def self.show(transaction_id, query_params, api_config = nil)
21
+ path = "/masterpass/paymentdata/{transactionId}"
22
+ service_request = ServiceRequest.new
23
+ service_request.path_params["transactionId"] = transaction_id
24
+
25
+
26
+ service_request.query_params = query_params
27
+ service_request.content_type = "application/json"
28
+ api_client = ApiClient.new(api_config)
29
+ api_client.api_tracker = SdkApiTracker.new
30
+ api_client.error_handler = ErrorHandler.new
31
+ return api_client.call(path, service_request, "GET",PaymentData)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+
40
+
@@ -0,0 +1,39 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_merchant_checkout/models/postback'
4
+
5
+
6
+ module MastercardMerchantCheckout
7
+ module Api
8
+
9
+ class PostbackApi
10
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
11
+ include MastercardMerchantCheckout::Tracker
12
+
13
+
14
+ # Postback Service
15
+ # The final step of the Masterpass transaction, Masterpass Postback is a service call from the merchant to Masterpass communicating the result of the transaction (success or failure). This is a mandatory step. Abandoned transactions do not need to be reported.
16
+ # @param postback This is the merchant's transaction details.
17
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
18
+ # @return [nil]
19
+ def self.create(postback, api_config = nil)
20
+ path = "/masterpass/postback"
21
+ service_request = ServiceRequest.new
22
+
23
+
24
+ service_request.body = postback
25
+
26
+ service_request.content_type = "application/json"
27
+ api_client = ApiClient.new(api_config)
28
+ api_client.api_tracker = SdkApiTracker.new
29
+ api_client.error_handler = ErrorHandler.new
30
+ return api_client.call(path, service_request, "POST",nil)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+
39
+
@@ -0,0 +1,255 @@
1
+ require 'date'
2
+ require 'roxml'
3
+
4
+
5
+ module MastercardMerchantCheckout
6
+ # This class contains methods to get the consumer's address details.
7
+ class Address
8
+ include ROXML
9
+
10
+ xml_name "Address"
11
+
12
+ # @!attribute city
13
+ # @return [String] the cardholder's city.
14
+ xml_accessor :city, :from =>"city"
15
+
16
+ # @!attribute country
17
+ # @return [String] the cardholder's country as defined by ISO 3166-1 alpha-2 digit country codes; for example, US is the United States, AU is Australia, CA is Canada, GB is the United Kingdom, and so on.
18
+ xml_accessor :country, :from =>"country"
19
+
20
+ # @!attribute subdivision
21
+ # @return [String] the cardholder's country's subdivision as defined by ISO 3166-1 alpha-2 digit code; for example, US-VA is Virginia, US-OH is Ohio, and so on.
22
+ xml_accessor :subdivision, :from =>"subdivision"
23
+
24
+ # @!attribute line1
25
+ # @return [String] the address in line 1 is used for the street number and the street name.
26
+ xml_accessor :line1, :from =>"line1"
27
+
28
+ # @!attribute line2
29
+ # @return [String] the address in line 2 is used for the apartment number, suite Number, and so on.
30
+ xml_accessor :line2, :from =>"line2"
31
+
32
+ # @!attribute line3
33
+ # @return [String] the address in line 3 is used to enter the remaining address information if it does not fit in lines 1 and 2.
34
+ xml_accessor :line3, :from =>"line3"
35
+
36
+ # @!attribute line4
37
+ # @return [String] the address in line 4 is used to enter the remaining address information if it does not fit in lines 1, 2 and 3.
38
+ xml_accessor :line4, :from =>"line4"
39
+
40
+ # @!attribute line5
41
+ # @return [String] the address in line 5 is used to enter the remaining address information if it does not fit in line 1,2,3 and 4.
42
+ xml_accessor :line5, :from =>"line5"
43
+
44
+ # @!attribute postal_code
45
+ # @return [String] the postal code or zip code appended to the mailing address for the purpose of sorting mail.
46
+ xml_accessor :postal_code, :from =>"postalCode"
47
+
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :city => :city ,
53
+ :country => :country ,
54
+ :subdivision => :subdivision ,
55
+ :line1 => :line1 ,
56
+ :line2 => :line2 ,
57
+ :line3 => :line3 ,
58
+ :line4 => :line4 ,
59
+ :line5 => :line5 ,
60
+ :postal_code => :postalCode
61
+
62
+ }
63
+ end
64
+
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
70
+
71
+
72
+ if attributes.has_key?(:city)
73
+ self.city = attributes[:city]
74
+ end
75
+
76
+ if attributes.has_key?(:country)
77
+ self.country = attributes[:country]
78
+ end
79
+
80
+ if attributes.has_key?(:subdivision)
81
+ self.subdivision = attributes[:subdivision]
82
+ end
83
+
84
+ if attributes.has_key?(:line1)
85
+ self.line1 = attributes[:line1]
86
+ end
87
+
88
+ if attributes.has_key?(:line2)
89
+ self.line2 = attributes[:line2]
90
+ end
91
+
92
+ if attributes.has_key?(:line3)
93
+ self.line3 = attributes[:line3]
94
+ end
95
+
96
+ if attributes.has_key?(:line4)
97
+ self.line4 = attributes[:line4]
98
+ end
99
+
100
+ if attributes.has_key?(:line5)
101
+ self.line5 = attributes[:line5]
102
+ end
103
+
104
+ if attributes.has_key?(:postal_code)
105
+ self.postal_code = attributes[:postal_code]
106
+ end
107
+
108
+ end
109
+
110
+
111
+
112
+
113
+ # Check equality by comparing each attribute.
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ city == o.city &&
118
+ country == o.country &&
119
+ subdivision == o.subdivision &&
120
+ line1 == o.line1 &&
121
+ line2 == o.line2 &&
122
+ line3 == o.line3 &&
123
+ line4 == o.line4 &&
124
+ line5 == o.line5 &&
125
+ postal_code == o.postal_code
126
+ end
127
+
128
+ # @see the `==` method
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculate hash code according to all attributes.
134
+ def hash
135
+ [city, country, subdivision, line1, line2, line3, line4, line5, postal_code].hash
136
+ end
137
+
138
+ # build the object from hash
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.datatype_map.each_pair do |key, type|
142
+ if type =~ /^Array<(.*)>/i
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
145
+ else
146
+ #TODO show warning in debug mode
147
+ end
148
+ elsif !attributes[self.class.attribute_map[key]].nil?
149
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
150
+ else
151
+ # data not found in attributes(hash), not an issue as the data can be optional
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :DateTime
161
+ DateTime.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :BOOLEAN
171
+ if value =~ /^(true|t|yes|y|1)$/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ _model = MastercardMerchantCheckout.const_get(type).new
189
+ _model.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_body (backward compatibility))
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # return the object in the form of hash
203
+ def to_hash(include_root = false)
204
+ attributes_hash = {}
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ next if value.nil?
209
+ hash[param] = _to_hash(value)
210
+ end
211
+ attributes_hash = include_root ? { "Address" => hash } : hash
212
+ return attributes_hash
213
+ end
214
+
215
+ # Method to output non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map{ |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+
232
+ private
233
+ def after_parse
234
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
235
+ end
236
+
237
+ # Attribute datatype mapping.
238
+ def self.datatype_map
239
+ {
240
+ :city => 'String',
241
+ :country => 'String',
242
+ :subdivision => 'String',
243
+ :line1 => 'String',
244
+ :line2 => 'String',
245
+ :line3 => 'String',
246
+ :line4 => 'String',
247
+ :line5 => 'String',
248
+ :postal_code => 'String'
249
+
250
+ }
251
+ end
252
+ end
253
+
254
+
255
+ end