mastercard_merchant_checkout 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/mastercard_merchant_checkout.rb +24 -0
  4. data/lib/mastercard_merchant_checkout/api/express_checkout_api.rb +40 -0
  5. data/lib/mastercard_merchant_checkout/api/pairing_id_api.rb +38 -0
  6. data/lib/mastercard_merchant_checkout/api/payment_data_api.rb +2 -2
  7. data/lib/mastercard_merchant_checkout/api/postback_api.rb +1 -1
  8. data/lib/mastercard_merchant_checkout/api/pre_checkout_data_api.rb +39 -0
  9. data/lib/mastercard_merchant_checkout/models/address.rb +9 -9
  10. data/lib/mastercard_merchant_checkout/models/authentication_options.rb +8 -8
  11. data/lib/mastercard_merchant_checkout/models/card.rb +22 -11
  12. data/lib/mastercard_merchant_checkout/models/contact_info.rb +211 -0
  13. data/lib/mastercard_merchant_checkout/models/cryptogram.rb +209 -0
  14. data/lib/mastercard_merchant_checkout/models/express_checkout_request.rb +244 -0
  15. data/lib/mastercard_merchant_checkout/models/pairing.rb +167 -0
  16. data/lib/mastercard_merchant_checkout/models/payment_data.rb +42 -8
  17. data/lib/mastercard_merchant_checkout/models/personal_info.rb +2 -2
  18. data/lib/mastercard_merchant_checkout/models/postback.rb +20 -9
  19. data/lib/mastercard_merchant_checkout/models/pre_checkout_card.rb +233 -0
  20. data/lib/mastercard_merchant_checkout/models/pre_checkout_data.rb +256 -0
  21. data/lib/mastercard_merchant_checkout/models/recipient_info.rb +178 -0
  22. data/lib/mastercard_merchant_checkout/models/shipping_address.rb +289 -0
  23. data/lib/mastercard_merchant_checkout/models/tokenization.rb +201 -0
  24. data/lib/mastercard_merchant_checkout/tracker/sdk_api_tracker.rb +1 -1
  25. data/lib/mastercard_merchant_checkout/version.rb +1 -1
  26. metadata +17 -5
@@ -0,0 +1,201 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_merchant_checkout/models/cryptogram'
4
+
5
+
6
+ module MastercardMerchantCheckout
7
+ # The tokenized card information.
8
+ class Tokenization
9
+ include ROXML
10
+
11
+ xml_name "Tokenization"
12
+
13
+ # @!attribute f_pan_suffix
14
+ # @return [String] the last digits of the card number. (FPAN) Normally the suffix is the last four digits.
15
+ xml_accessor :f_pan_suffix, :from =>"fPanSuffix"
16
+
17
+ # @!attribute token_requestor_id
18
+ # @return [String] the token requestor id.
19
+ xml_accessor :token_requestor_id, :from =>"tokenRequestorId"
20
+
21
+ # @!attribute payment_account_reference
22
+ # @return [String] the payment account reference.
23
+ xml_accessor :payment_account_reference, :from =>"paymentAccountReference"
24
+
25
+ # @!attribute cryptogram
26
+ # @return [Cryptogram] the cryptogram generated by the consumer's Masterpass wallet.
27
+ xml_accessor :cryptogram, :from =>"cryptogram",:as => Cryptogram
28
+
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :f_pan_suffix => :fPanSuffix ,
34
+ :token_requestor_id => :tokenRequestorId ,
35
+ :payment_account_reference => :paymentAccountReference ,
36
+ :cryptogram => :cryptogram
37
+
38
+ }
39
+ end
40
+
41
+ def initialize(attributes = {})
42
+ return unless attributes.is_a?(Hash)
43
+
44
+ # convert string to symbol for hash key
45
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
46
+
47
+
48
+ if attributes.has_key?(:f_pan_suffix)
49
+ self.f_pan_suffix = attributes[:f_pan_suffix]
50
+ end
51
+
52
+ if attributes.has_key?(:token_requestor_id)
53
+ self.token_requestor_id = attributes[:token_requestor_id]
54
+ end
55
+
56
+ if attributes.has_key?(:payment_account_reference)
57
+ self.payment_account_reference = attributes[:payment_account_reference]
58
+ end
59
+
60
+ if attributes.has_key?(:cryptogram)
61
+ self.cryptogram = attributes[:cryptogram]
62
+ end
63
+
64
+ end
65
+
66
+
67
+
68
+
69
+ # Check equality by comparing each attribute.
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ f_pan_suffix == o.f_pan_suffix &&
74
+ token_requestor_id == o.token_requestor_id &&
75
+ payment_account_reference == o.payment_account_reference &&
76
+ cryptogram == o.cryptogram
77
+ end
78
+
79
+ # @see the `==` method
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculate hash code according to all attributes.
85
+ def hash
86
+ [f_pan_suffix, token_requestor_id, payment_account_reference, cryptogram].hash
87
+ end
88
+
89
+ # build the object from hash
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.datatype_map.each_pair do |key, type|
93
+ if type =~ /^Array<(.*)>/i
94
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
95
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
96
+ else
97
+ #TODO show warning in debug mode
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ else
102
+ # data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+ end
105
+
106
+ self
107
+ end
108
+
109
+ def _deserialize(type, value)
110
+ case type.to_sym
111
+ when :DateTime
112
+ DateTime.parse(value)
113
+ when :Date
114
+ Date.parse(value)
115
+ when :String
116
+ value.to_s
117
+ when :Integer
118
+ value.to_i
119
+ when :Float
120
+ value.to_f
121
+ when :BOOLEAN
122
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
123
+ true
124
+ else
125
+ false
126
+ end
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ _model = MastercardMerchantCheckout.const_get(type).new
140
+ _model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_body (backward compatibility))
149
+ def to_body
150
+ to_hash
151
+ end
152
+
153
+ # return the object in the form of hash
154
+ def to_hash(include_root = false)
155
+ attributes_hash = {}
156
+ hash = {}
157
+ self.class.attribute_map.each_pair do |attr, param|
158
+ value = self.send(attr)
159
+ next if value.nil?
160
+ hash[param] = _to_hash(value)
161
+ end
162
+ attributes_hash = include_root ? { "Tokenization" => hash } : hash
163
+ return attributes_hash
164
+ end
165
+
166
+ # Method to output non-array value in the form of hash
167
+ # For object, use to_hash. Otherwise, just return the value
168
+ def _to_hash(value)
169
+ if value.is_a?(Array)
170
+ value.compact.map{ |v| _to_hash(v) }
171
+ elsif value.is_a?(Hash)
172
+ {}.tap do |hash|
173
+ value.each { |k, v| hash[k] = _to_hash(v) }
174
+ end
175
+ elsif value.respond_to? :to_hash
176
+ value.to_hash
177
+ else
178
+ value
179
+ end
180
+ end
181
+
182
+
183
+ private
184
+ def after_parse
185
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
186
+ end
187
+
188
+ # Attribute datatype mapping.
189
+ def self.datatype_map
190
+ {
191
+ :f_pan_suffix => 'String',
192
+ :token_requestor_id => 'String',
193
+ :payment_account_reference => 'String',
194
+ :cryptogram => 'Cryptogram'
195
+
196
+ }
197
+ end
198
+ end
199
+
200
+
201
+ end
@@ -2,7 +2,7 @@ require 'mastercard_core_sdk'
2
2
 
3
3
  module MastercardMerchantCheckout
4
4
  module Tracker
5
- # Provides tracking api information and user-agent information.
5
+ # Provides tracking API information and user-agent information.
6
6
  class SdkApiTracker
7
7
  include MastercardCoreSdk, MastercardCoreSdk::Core, MastercardCoreSdk::Tracker::ApiTracker
8
8
 
@@ -1,3 +1,3 @@
1
1
  module MastercardMerchantCheckout
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastercard_merchant_checkout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mastercard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mastercard_core_sdk
@@ -124,7 +124,7 @@ dependencies:
124
124
  - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '5.0'
127
- description: Mastercard Masterpass Merchant V7 Checkout SDK.
127
+ description: Mastercard Masterpass Merchant Checkout SDK. See https://developer.mastercard.com/documentation/masterpass-merchant-integration
128
128
  email:
129
129
  - support@masterpass.com
130
130
  - merchant_support@masterpass.com
@@ -137,17 +137,29 @@ files:
137
137
  - LICENSE.txt
138
138
  - README.md
139
139
  - lib/mastercard_merchant_checkout.rb
140
+ - lib/mastercard_merchant_checkout/api/express_checkout_api.rb
141
+ - lib/mastercard_merchant_checkout/api/pairing_id_api.rb
140
142
  - lib/mastercard_merchant_checkout/api/payment_data_api.rb
141
143
  - lib/mastercard_merchant_checkout/api/postback_api.rb
144
+ - lib/mastercard_merchant_checkout/api/pre_checkout_data_api.rb
142
145
  - lib/mastercard_merchant_checkout/models/address.rb
143
146
  - lib/mastercard_merchant_checkout/models/authentication_options.rb
144
147
  - lib/mastercard_merchant_checkout/models/card.rb
148
+ - lib/mastercard_merchant_checkout/models/contact_info.rb
149
+ - lib/mastercard_merchant_checkout/models/cryptogram.rb
150
+ - lib/mastercard_merchant_checkout/models/express_checkout_request.rb
151
+ - lib/mastercard_merchant_checkout/models/pairing.rb
145
152
  - lib/mastercard_merchant_checkout/models/payment_data.rb
146
153
  - lib/mastercard_merchant_checkout/models/personal_info.rb
147
154
  - lib/mastercard_merchant_checkout/models/postback.rb
155
+ - lib/mastercard_merchant_checkout/models/pre_checkout_card.rb
156
+ - lib/mastercard_merchant_checkout/models/pre_checkout_data.rb
157
+ - lib/mastercard_merchant_checkout/models/recipient_info.rb
158
+ - lib/mastercard_merchant_checkout/models/shipping_address.rb
159
+ - lib/mastercard_merchant_checkout/models/tokenization.rb
148
160
  - lib/mastercard_merchant_checkout/tracker/sdk_api_tracker.rb
149
161
  - lib/mastercard_merchant_checkout/version.rb
150
- homepage: https://developer.mastercard.com/documentation/masterpass-merchant-integration/v7
162
+ homepage: https://developer.mastercard.com/documentation/masterpass-merchant-integration
151
163
  licenses:
152
164
  - Mastercard
153
165
  metadata: {}
@@ -170,5 +182,5 @@ rubyforge_project:
170
182
  rubygems_version: 2.4.5.1
171
183
  signing_key:
172
184
  specification_version: 4
173
- summary: Mastercard Masterpass Merchant V7 Checkout SDK.
185
+ summary: Mastercard Masterpass Merchant Checkout SDK.
174
186
  test_files: []