mastercard_merchant_checkout 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/mastercard_merchant_checkout.rb +24 -0
- data/lib/mastercard_merchant_checkout/api/express_checkout_api.rb +40 -0
- data/lib/mastercard_merchant_checkout/api/pairing_id_api.rb +38 -0
- data/lib/mastercard_merchant_checkout/api/payment_data_api.rb +2 -2
- data/lib/mastercard_merchant_checkout/api/postback_api.rb +1 -1
- data/lib/mastercard_merchant_checkout/api/pre_checkout_data_api.rb +39 -0
- data/lib/mastercard_merchant_checkout/models/address.rb +9 -9
- data/lib/mastercard_merchant_checkout/models/authentication_options.rb +8 -8
- data/lib/mastercard_merchant_checkout/models/card.rb +22 -11
- data/lib/mastercard_merchant_checkout/models/contact_info.rb +211 -0
- data/lib/mastercard_merchant_checkout/models/cryptogram.rb +209 -0
- data/lib/mastercard_merchant_checkout/models/express_checkout_request.rb +244 -0
- data/lib/mastercard_merchant_checkout/models/pairing.rb +167 -0
- data/lib/mastercard_merchant_checkout/models/payment_data.rb +42 -8
- data/lib/mastercard_merchant_checkout/models/personal_info.rb +2 -2
- data/lib/mastercard_merchant_checkout/models/postback.rb +20 -9
- data/lib/mastercard_merchant_checkout/models/pre_checkout_card.rb +233 -0
- data/lib/mastercard_merchant_checkout/models/pre_checkout_data.rb +256 -0
- data/lib/mastercard_merchant_checkout/models/recipient_info.rb +178 -0
- data/lib/mastercard_merchant_checkout/models/shipping_address.rb +289 -0
- data/lib/mastercard_merchant_checkout/models/tokenization.rb +201 -0
- data/lib/mastercard_merchant_checkout/tracker/sdk_api_tracker.rb +1 -1
- data/lib/mastercard_merchant_checkout/version.rb +1 -1
- metadata +17 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27bbe228d523693b4108b56ea63ff0dc4fd02772
|
4
|
+
data.tar.gz: e5bb3b93176a29f51303de61dc0a2487a8c0269c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4868a2b3b844b7b8edc95ef40749c2b4ba3e2c27276b18becbd5f8dc3105a56f2eff8591b0e7c0a148ed45cf4fc2a6c932d5424dee58cbed8b290c57650df19
|
7
|
+
data.tar.gz: 491ba2af42fd52ad8115e46c83769a5d5fcc786c559683be9f3183547135ce6ee3ef810edbfb19e4cd2fb86cd7e72d46d03dd27060a51c2b477132dba025db85
|
data/README.md
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
to re-enter payment, shipping or loyalty program details during checkout.
|
9
9
|
The Masterpass solution is simple, secure and easy for merchants to integrate into their existing website or application.
|
10
10
|
|
11
|
-
For more information, refer [Masterpass Merchant Integration](https://developer.mastercard.com/documentation/masterpass-merchant-integration
|
11
|
+
For more information, refer [Masterpass Merchant Integration](https://developer.mastercard.com/documentation/masterpass-merchant-integration).
|
12
12
|
|
13
13
|
## Features
|
14
14
|
|
15
15
|
Simplified merchant checkout flow with new Masterpass checkout API services.
|
16
16
|
|
17
|
-
Supports Masterpass Standard checkout.
|
17
|
+
Supports Masterpass Standard and Express checkout.
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
@@ -14,14 +14,38 @@ require_relative 'mastercard_merchant_checkout/models/personal_info'
|
|
14
14
|
|
15
15
|
require_relative 'mastercard_merchant_checkout/models/postback'
|
16
16
|
|
17
|
+
require_relative 'mastercard_merchant_checkout/models/tokenization'
|
18
|
+
|
19
|
+
require_relative 'mastercard_merchant_checkout/models/cryptogram'
|
20
|
+
|
17
21
|
require_relative 'mastercard_merchant_checkout/models/authentication_options'
|
18
22
|
|
23
|
+
require_relative 'mastercard_merchant_checkout/models/pairing'
|
24
|
+
|
25
|
+
require_relative 'mastercard_merchant_checkout/models/express_checkout_request'
|
26
|
+
|
27
|
+
require_relative 'mastercard_merchant_checkout/models/pre_checkout_data'
|
28
|
+
|
29
|
+
require_relative 'mastercard_merchant_checkout/models/contact_info'
|
30
|
+
|
31
|
+
require_relative 'mastercard_merchant_checkout/models/recipient_info'
|
32
|
+
|
33
|
+
require_relative 'mastercard_merchant_checkout/models/shipping_address'
|
34
|
+
|
35
|
+
require_relative 'mastercard_merchant_checkout/models/pre_checkout_card'
|
36
|
+
|
19
37
|
|
20
38
|
# APIs
|
21
39
|
|
22
40
|
|
41
|
+
require_relative 'mastercard_merchant_checkout/api/pre_checkout_data_api'
|
42
|
+
|
43
|
+
require_relative 'mastercard_merchant_checkout/api/express_checkout_api'
|
44
|
+
|
23
45
|
require_relative 'mastercard_merchant_checkout/api/postback_api'
|
24
46
|
|
47
|
+
require_relative 'mastercard_merchant_checkout/api/pairing_id_api'
|
48
|
+
|
25
49
|
require_relative 'mastercard_merchant_checkout/api/payment_data_api'
|
26
50
|
|
27
51
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'mastercard_core_sdk'
|
3
|
+
require_relative '../../mastercard_merchant_checkout/models/express_checkout_request'
|
4
|
+
require_relative '../../mastercard_merchant_checkout/models/payment_data'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMerchantCheckout
|
8
|
+
module Api
|
9
|
+
|
10
|
+
class ExpressCheckoutApi
|
11
|
+
include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
|
12
|
+
include MastercardMerchantCheckout::Tracker
|
13
|
+
|
14
|
+
|
15
|
+
# ExpressCheckout Service
|
16
|
+
# Use this service to retrieve the consumer's full payment card, shipping address, and recipient personal information from Masterpass when performing an Express Checkout. If the merchant is PCI-compliant, then this API will return the complete payload. If the merchant is not PCI-compliant, then this API will only return non-PCI data. In both cases, a new pairingId will be returned to the merchant. API URL: /masterpass/expresscheckout
|
17
|
+
# @param express_checkout_request Express Checkout Request.
|
18
|
+
# @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
|
19
|
+
# @return [PaymentData]
|
20
|
+
def self.create(express_checkout_request, api_config = nil)
|
21
|
+
path = "/masterpass/expresscheckout"
|
22
|
+
service_request = ServiceRequest.new
|
23
|
+
|
24
|
+
|
25
|
+
service_request.body = express_checkout_request
|
26
|
+
|
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, "POST",PaymentData)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'mastercard_core_sdk'
|
3
|
+
require_relative '../../mastercard_merchant_checkout/models/pairing'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMerchantCheckout
|
7
|
+
module Api
|
8
|
+
|
9
|
+
class PairingIdApi
|
10
|
+
include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
|
11
|
+
include MastercardMerchantCheckout::Tracker
|
12
|
+
|
13
|
+
|
14
|
+
# PairingId Service
|
15
|
+
# Use this service to get a consumer’s pairing identifier from Masterpass when they choose to share the payment and shipping information from their Masterpass wallet for future use in an Express Checkout. API URL: /masterpass/pairingid
|
16
|
+
# @param query_params The query parameters.
|
17
|
+
# @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
|
18
|
+
# @return [Pairing]
|
19
|
+
def self.show(query_params, api_config = nil)
|
20
|
+
path = "/masterpass/pairingid"
|
21
|
+
service_request = ServiceRequest.new
|
22
|
+
|
23
|
+
|
24
|
+
service_request.query_params = query_params
|
25
|
+
service_request.content_type = "application/json"
|
26
|
+
api_client = ApiClient.new(api_config)
|
27
|
+
api_client.api_tracker = SdkApiTracker.new
|
28
|
+
api_client.error_handler = ErrorHandler.new
|
29
|
+
return api_client.call(path, service_request, "GET",Pairing)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
@@ -12,8 +12,8 @@ module MastercardMerchantCheckout
|
|
12
12
|
|
13
13
|
|
14
14
|
# PaymentData Service
|
15
|
-
#
|
16
|
-
# @param transaction_id This is
|
15
|
+
# Use this service to retrieve the consumer's payment card, and shipping details from Masterpass. New or existing Brazil merchants looking for the house number and street name as separate fields should leverage these two additional extension points in their Masterpass checkout integration. Line 4 will provide the house number and line 5 will provide the street name. Brazil merchants should first look for data in lines 4 and 5, and in the case that no data is found there, merchants should then look for data in line 1. API URL: /masterpass/paymentdata/:transaction_id
|
16
|
+
# @param transaction_id Identifies the transaction for which to return the consumer’s payment data. This is the oauth_verifier value sent by Masterpass in the callback URL after the Masterpass UI is closed.
|
17
17
|
# @param query_params The query parameters.
|
18
18
|
# @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
|
19
19
|
# @return [PaymentData]
|
@@ -12,7 +12,7 @@ module MastercardMerchantCheckout
|
|
12
12
|
|
13
13
|
|
14
14
|
# Postback Service
|
15
|
-
#
|
15
|
+
# This is the final step in the transaction and reports the result of their transactions to Masterpass. Postback is required for all transactions (abandoned transactions do not need to be reported). API URL: /masterpass/postback
|
16
16
|
# @param postback This is the merchant's transaction details.
|
17
17
|
# @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
|
18
18
|
# @return [nil]
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'mastercard_core_sdk'
|
3
|
+
require_relative '../../mastercard_merchant_checkout/models/pre_checkout_data'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMerchantCheckout
|
7
|
+
module Api
|
8
|
+
|
9
|
+
class PreCheckoutDataApi
|
10
|
+
include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
|
11
|
+
include MastercardMerchantCheckout::Tracker
|
12
|
+
|
13
|
+
|
14
|
+
# PreCheckout Data Service
|
15
|
+
# Use the consumer’s pairingID to retrieve their shipping and payment information prior to complete an Express Checkout. You can use the data returned from this service to confirm the user’s payment selections before completing the checkout. API URL: /masterpass/precheckoutdata/:pairing_id
|
16
|
+
# @param pairing_id The unique pairing token identifier used to fetch pre-checkout data for a wallet that is paired with a merchant.
|
17
|
+
# @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
|
18
|
+
# @return [PreCheckoutData]
|
19
|
+
def self.show(pairing_id, api_config = nil)
|
20
|
+
path = "/masterpass/precheckoutdata/{pairingId}"
|
21
|
+
service_request = ServiceRequest.new
|
22
|
+
service_request.path_params["pairingId"] = pairing_id
|
23
|
+
|
24
|
+
|
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, "GET",PreCheckoutData)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
@@ -14,35 +14,35 @@ module MastercardMerchantCheckout
|
|
14
14
|
xml_accessor :city, :from =>"city"
|
15
15
|
|
16
16
|
# @!attribute country
|
17
|
-
# @return [String] the cardholder's country as defined by ISO 3166-1 alpha-2
|
17
|
+
# @return [String] the cardholder's country as defined by ISO 3166-1 alpha-2 country codes.
|
18
18
|
xml_accessor :country, :from =>"country"
|
19
19
|
|
20
20
|
# @!attribute subdivision
|
21
|
-
# @return [String] the cardholder's country's subdivision as defined by ISO 3166-1 alpha-2
|
21
|
+
# @return [String] the cardholder's country's subdivision as defined by ISO 3166-1 alpha-2 code for US, CA, AU, JP, and BR. All other countries use a freeform text field.
|
22
22
|
xml_accessor :subdivision, :from =>"subdivision"
|
23
23
|
|
24
24
|
# @!attribute line1
|
25
|
-
# @return [String] the
|
25
|
+
# @return [String] the cardholder’s house number and the street name.
|
26
26
|
xml_accessor :line1, :from =>"line1"
|
27
27
|
|
28
28
|
# @!attribute line2
|
29
|
-
# @return [String] the
|
29
|
+
# @return [String] the cardholder’s apartment number, suite number, etc.
|
30
30
|
xml_accessor :line2, :from =>"line2"
|
31
31
|
|
32
32
|
# @!attribute line3
|
33
|
-
# @return [String] the
|
33
|
+
# @return [String] the cardholder’s remaining address information that does not fit in lines 1 and 2.
|
34
34
|
xml_accessor :line3, :from =>"line3"
|
35
35
|
|
36
36
|
# @!attribute line4
|
37
|
-
# @return [String] the
|
37
|
+
# @return [String] the line4 is only returned for addresses in Brazil, and provides the cardholder’s billing house number. If no data is returned for this field, then reference card.billingAddress.line1
|
38
38
|
xml_accessor :line4, :from =>"line4"
|
39
39
|
|
40
40
|
# @!attribute line5
|
41
|
-
# @return [String] the
|
41
|
+
# @return [String] the line5 is only returned for addresses in Brazil, and provides the cardholder’s billing street name. If no data is returned for this field, then reference card.billingAddress.line1
|
42
42
|
xml_accessor :line5, :from =>"line5"
|
43
43
|
|
44
44
|
# @!attribute postal_code
|
45
|
-
# @return [String] the postal code or zip code
|
45
|
+
# @return [String] the cardholder’s postal code or zip code.
|
46
46
|
xml_accessor :postal_code, :from =>"postalCode"
|
47
47
|
|
48
48
|
|
@@ -168,7 +168,7 @@ module MastercardMerchantCheckout
|
|
168
168
|
when :Float
|
169
169
|
value.to_f
|
170
170
|
when :BOOLEAN
|
171
|
-
if value =~
|
171
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
172
172
|
true
|
173
173
|
else
|
174
174
|
false
|
@@ -3,7 +3,7 @@ require 'roxml'
|
|
3
3
|
|
4
4
|
|
5
5
|
module MastercardMerchantCheckout
|
6
|
-
#
|
6
|
+
# The authentication information required during DSRP.
|
7
7
|
class AuthenticationOptions
|
8
8
|
include ROXML
|
9
9
|
|
@@ -14,27 +14,27 @@ module MastercardMerchantCheckout
|
|
14
14
|
xml_accessor :authenticate_method, :from =>"authenticateMethod"
|
15
15
|
|
16
16
|
# @!attribute card_enrollment_method
|
17
|
-
# @return [String] the method by which the card was added to the wallet. Valid values are: Manual Direct Provisioned 3DS Manual NFC Tap.
|
17
|
+
# @return [String] the method by which the card was added to the wallet. Valid values are: Manual Direct Provisioned 3DS Manual, and NFC Tap.
|
18
18
|
xml_accessor :card_enrollment_method, :from =>"cardEnrollmentMethod"
|
19
19
|
|
20
20
|
# @!attribute c_avv
|
21
|
-
# @return [String] the (CAVV) Cardholder Authentication Verification Value generated by card issuer upon successful authentication of the cardholder. This must be passed in the authorization message.
|
21
|
+
# @return [String] the (CAVV) Cardholder Authentication Verification Value generated by the card issuer upon successful authentication of the cardholder. This must be passed in the authorization message.
|
22
22
|
xml_accessor :c_avv, :from =>"cAvv"
|
23
23
|
|
24
24
|
# @!attribute eci_flag
|
25
|
-
# @return [String] the Electronic commerce indicator (ECI) flag. Possible values are as follows:
|
25
|
+
# @return [String] the Electronic commerce indicator (ECI) flag. Possible values are as follows: Mastercard: 00:No Authentication 01:Attempts (Card Issuer Liability) 02:Authenticated by ACS (Card Issuer Liability) 03:Maestro (MARP) 05:Risk Based Authentication (Issuer, not in use) 06:Risk Based Authentication (Merchant, not in use) Visa: 05:Authenticated (Card Issuer Liability) 06:Attempts (Card Issuer Liability) 07:No 3DS Authentication (Merchant Liability)
|
26
26
|
xml_accessor :eci_flag, :from =>"eciFlag"
|
27
27
|
|
28
28
|
# @!attribute master_card_assigned_id
|
29
|
-
# @return [String] the value assigned by
|
29
|
+
# @return [String] the value assigned by Mastercard and represents programs associated directly with Maestro cards. This field should be supplied in the authorization request by the merchant.
|
30
30
|
xml_accessor :master_card_assigned_id, :from =>"masterCardAssignedID"
|
31
31
|
|
32
32
|
# @!attribute pa_res_status
|
33
|
-
# @return [String] the message formatted, digitally signed, and sent from the ACS (issuer) to the MPI providing the results of the issuer's
|
33
|
+
# @return [String] the message formatted, digitally signed, and sent from the ACS (issuer) to the MPI providing the results of the issuer's Mastercard SecureCode/Verified by Visa cardholder authentication. Possible values are: Y-The card was successfully authenticated via 3-D Secure A-signifies that either (a) the transaction was successfully authenticated via a 3-D Secure attempts transaction or (b)the cardholder was prompted to activate 3-D Secure during shopping but declined (Visa). U-Authentication results were unavailable.
|
34
34
|
xml_accessor :pa_res_status, :from =>"paResStatus"
|
35
35
|
|
36
36
|
# @!attribute sc_enrollment_status
|
37
|
-
# @return [String] the
|
37
|
+
# @return [String] the Mastercard SecureCode Enrollment Status. Indicates if the issuer of the card supports payer authentication for this card. Possible values are as follows: Y-The card is eligible for 3-D Secure authentication. N-The card is not eligible for 3-D Secure authentication. U-Lookup of the card's 3-D Secure eligibility status was either unavailable, or the card is inapplicable (for example, prepaid cards).
|
38
38
|
xml_accessor :sc_enrollment_status, :from =>"scEnrollmentStatus"
|
39
39
|
|
40
40
|
# @!attribute signature_verification
|
@@ -168,7 +168,7 @@ module MastercardMerchantCheckout
|
|
168
168
|
when :Float
|
169
169
|
value.to_f
|
170
170
|
when :BOOLEAN
|
171
|
-
if value =~
|
171
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
172
172
|
true
|
173
173
|
else
|
174
174
|
false
|
@@ -11,15 +11,15 @@ module MastercardMerchantCheckout
|
|
11
11
|
xml_name "Card"
|
12
12
|
|
13
13
|
# @!attribute brand_id
|
14
|
-
# @return [String] the card
|
14
|
+
# @return [String] the card brand id referenced by Masterpass (master, amex, diners, discover, jcb, maestro, visa).
|
15
15
|
xml_accessor :brand_id, :from =>"brandId"
|
16
16
|
|
17
17
|
# @!attribute brand_name
|
18
|
-
# @return [String] the card
|
18
|
+
# @return [String] the card brand full name (Mastercard, American Express, Diners Club, Discover, JCB, Maestro, Visa).
|
19
19
|
xml_accessor :brand_name, :from =>"brandName"
|
20
20
|
|
21
21
|
# @!attribute account_number
|
22
|
-
# @return [String] the PAN
|
22
|
+
# @return [String] the card number, also known as Primary Account Number (PAN)
|
23
23
|
xml_accessor :account_number, :from =>"accountNumber"
|
24
24
|
|
25
25
|
# @!attribute card_holder_name
|
@@ -27,17 +27,21 @@ module MastercardMerchantCheckout
|
|
27
27
|
xml_accessor :card_holder_name, :from =>"cardHolderName"
|
28
28
|
|
29
29
|
# @!attribute expiry_month
|
30
|
-
# @return [Integer] the expiration month
|
30
|
+
# @return [Integer] the PAN expiration month, returned as a two-digit string.
|
31
31
|
xml_accessor :expiry_month, :from =>"expiryMonth"
|
32
32
|
|
33
33
|
# @!attribute expiry_year
|
34
|
-
# @return [Integer] the expiration year
|
34
|
+
# @return [Integer] the PAN expiration year, returned as a two-digit string (for the year 2020, Masterpass will return 20).
|
35
35
|
xml_accessor :expiry_year, :from =>"expiryYear"
|
36
36
|
|
37
37
|
# @!attribute billing_address
|
38
|
-
# @return [Address] the
|
38
|
+
# @return [Address] the billing address associated with the card.
|
39
39
|
xml_accessor :billing_address, :from =>"billingAddress",:as => Address
|
40
40
|
|
41
|
+
# @!attribute last_four
|
42
|
+
# @return [String] the last four digits of the PAN.
|
43
|
+
xml_accessor :last_four, :from =>"lastFour"
|
44
|
+
|
41
45
|
|
42
46
|
# Attribute mapping from ruby-style variable name to JSON key.
|
43
47
|
def self.attribute_map
|
@@ -48,7 +52,8 @@ module MastercardMerchantCheckout
|
|
48
52
|
:card_holder_name => :cardHolderName ,
|
49
53
|
:expiry_month => :expiryMonth ,
|
50
54
|
:expiry_year => :expiryYear ,
|
51
|
-
:billing_address => :billingAddress
|
55
|
+
:billing_address => :billingAddress ,
|
56
|
+
:last_four => :lastFour
|
52
57
|
|
53
58
|
}
|
54
59
|
end
|
@@ -88,6 +93,10 @@ module MastercardMerchantCheckout
|
|
88
93
|
self.billing_address = attributes[:billing_address]
|
89
94
|
end
|
90
95
|
|
96
|
+
if attributes.has_key?(:last_four)
|
97
|
+
self.last_four = attributes[:last_four]
|
98
|
+
end
|
99
|
+
|
91
100
|
end
|
92
101
|
|
93
102
|
|
@@ -103,7 +112,8 @@ module MastercardMerchantCheckout
|
|
103
112
|
card_holder_name == o.card_holder_name &&
|
104
113
|
expiry_month == o.expiry_month &&
|
105
114
|
expiry_year == o.expiry_year &&
|
106
|
-
billing_address == o.billing_address
|
115
|
+
billing_address == o.billing_address &&
|
116
|
+
last_four == o.last_four
|
107
117
|
end
|
108
118
|
|
109
119
|
# @see the `==` method
|
@@ -113,7 +123,7 @@ module MastercardMerchantCheckout
|
|
113
123
|
|
114
124
|
# Calculate hash code according to all attributes.
|
115
125
|
def hash
|
116
|
-
[brand_id, brand_name, account_number, card_holder_name, expiry_month, expiry_year, billing_address].hash
|
126
|
+
[brand_id, brand_name, account_number, card_holder_name, expiry_month, expiry_year, billing_address, last_four].hash
|
117
127
|
end
|
118
128
|
|
119
129
|
# build the object from hash
|
@@ -149,7 +159,7 @@ module MastercardMerchantCheckout
|
|
149
159
|
when :Float
|
150
160
|
value.to_f
|
151
161
|
when :BOOLEAN
|
152
|
-
if value =~
|
162
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
153
163
|
true
|
154
164
|
else
|
155
165
|
false
|
@@ -224,7 +234,8 @@ module MastercardMerchantCheckout
|
|
224
234
|
:card_holder_name => 'String',
|
225
235
|
:expiry_month => 'Integer',
|
226
236
|
:expiry_year => 'Integer',
|
227
|
-
:billing_address => 'Address'
|
237
|
+
:billing_address => 'Address',
|
238
|
+
:last_four => 'String'
|
228
239
|
|
229
240
|
}
|
230
241
|
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
|
4
|
+
|
5
|
+
module MastercardMerchantCheckout
|
6
|
+
# The contact info details for the wallet user.
|
7
|
+
class ContactInfo
|
8
|
+
include ROXML
|
9
|
+
|
10
|
+
xml_name "ContactInfo"
|
11
|
+
|
12
|
+
# @!attribute first_name
|
13
|
+
# @return [String] the first name associated with the wallet user.
|
14
|
+
xml_accessor :first_name, :from =>"firstName"
|
15
|
+
|
16
|
+
# @!attribute last_name
|
17
|
+
# @return [String] the last name associated with the wallet user.
|
18
|
+
xml_accessor :last_name, :from =>"lastName"
|
19
|
+
|
20
|
+
# @!attribute country
|
21
|
+
# @return [String] the country associated with the wallet user.
|
22
|
+
xml_accessor :country, :from =>"country"
|
23
|
+
|
24
|
+
# @!attribute email_address
|
25
|
+
# @return [String] the email address associated with the wallet user.
|
26
|
+
xml_accessor :email_address, :from =>"emailAddress"
|
27
|
+
|
28
|
+
# @!attribute phone_number
|
29
|
+
# @return [String] the phone number associated with the wallet user.
|
30
|
+
xml_accessor :phone_number, :from =>"phoneNumber"
|
31
|
+
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:first_name => :firstName ,
|
37
|
+
:last_name => :lastName ,
|
38
|
+
:country => :country ,
|
39
|
+
:email_address => :emailAddress ,
|
40
|
+
:phone_number => :phoneNumber
|
41
|
+
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(attributes = {})
|
46
|
+
return unless attributes.is_a?(Hash)
|
47
|
+
|
48
|
+
# convert string to symbol for hash key
|
49
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
50
|
+
|
51
|
+
|
52
|
+
if attributes.has_key?(:first_name)
|
53
|
+
self.first_name = attributes[:first_name]
|
54
|
+
end
|
55
|
+
|
56
|
+
if attributes.has_key?(:last_name)
|
57
|
+
self.last_name = attributes[:last_name]
|
58
|
+
end
|
59
|
+
|
60
|
+
if attributes.has_key?(:country)
|
61
|
+
self.country = attributes[:country]
|
62
|
+
end
|
63
|
+
|
64
|
+
if attributes.has_key?(:email_address)
|
65
|
+
self.email_address = attributes[:email_address]
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.has_key?(:phone_number)
|
69
|
+
self.phone_number = attributes[:phone_number]
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
# Check equality by comparing each attribute.
|
78
|
+
def ==(o)
|
79
|
+
return true if self.equal?(o)
|
80
|
+
self.class == o.class &&
|
81
|
+
first_name == o.first_name &&
|
82
|
+
last_name == o.last_name &&
|
83
|
+
country == o.country &&
|
84
|
+
email_address == o.email_address &&
|
85
|
+
phone_number == o.phone_number
|
86
|
+
end
|
87
|
+
|
88
|
+
# @see the `==` method
|
89
|
+
def eql?(o)
|
90
|
+
self == o
|
91
|
+
end
|
92
|
+
|
93
|
+
# Calculate hash code according to all attributes.
|
94
|
+
def hash
|
95
|
+
[first_name, last_name, country, email_address, phone_number].hash
|
96
|
+
end
|
97
|
+
|
98
|
+
# build the object from hash
|
99
|
+
def build_from_hash(attributes)
|
100
|
+
return nil unless attributes.is_a?(Hash)
|
101
|
+
self.class.datatype_map.each_pair do |key, type|
|
102
|
+
if type =~ /^Array<(.*)>/i
|
103
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
104
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
105
|
+
else
|
106
|
+
#TODO show warning in debug mode
|
107
|
+
end
|
108
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
109
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
110
|
+
else
|
111
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
def _deserialize(type, value)
|
119
|
+
case type.to_sym
|
120
|
+
when :DateTime
|
121
|
+
DateTime.parse(value)
|
122
|
+
when :Date
|
123
|
+
Date.parse(value)
|
124
|
+
when :String
|
125
|
+
value.to_s
|
126
|
+
when :Integer
|
127
|
+
value.to_i
|
128
|
+
when :Float
|
129
|
+
value.to_f
|
130
|
+
when :BOOLEAN
|
131
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
132
|
+
true
|
133
|
+
else
|
134
|
+
false
|
135
|
+
end
|
136
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
137
|
+
inner_type = Regexp.last_match[:inner_type]
|
138
|
+
value.map { |v| _deserialize(inner_type, v) }
|
139
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
140
|
+
k_type = Regexp.last_match[:k_type]
|
141
|
+
v_type = Regexp.last_match[:v_type]
|
142
|
+
{}.tap do |hash|
|
143
|
+
value.each do |k, v|
|
144
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else # model
|
148
|
+
_model = MastercardMerchantCheckout.const_get(type).new
|
149
|
+
_model.build_from_hash(value)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def to_s
|
154
|
+
to_hash.to_s
|
155
|
+
end
|
156
|
+
|
157
|
+
# to_body is an alias to to_body (backward compatibility))
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
# return the object in the form of hash
|
163
|
+
def to_hash(include_root = false)
|
164
|
+
attributes_hash = {}
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
attributes_hash = include_root ? { "ContactInfo" => hash } : hash
|
172
|
+
return attributes_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Method to output non-array value in the form of hash
|
176
|
+
# For object, use to_hash. Otherwise, just return the value
|
177
|
+
def _to_hash(value)
|
178
|
+
if value.is_a?(Array)
|
179
|
+
value.compact.map{ |v| _to_hash(v) }
|
180
|
+
elsif value.is_a?(Hash)
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
183
|
+
end
|
184
|
+
elsif value.respond_to? :to_hash
|
185
|
+
value.to_hash
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
private
|
193
|
+
def after_parse
|
194
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
195
|
+
end
|
196
|
+
|
197
|
+
# Attribute datatype mapping.
|
198
|
+
def self.datatype_map
|
199
|
+
{
|
200
|
+
:first_name => 'String',
|
201
|
+
:last_name => 'String',
|
202
|
+
:country => 'String',
|
203
|
+
:email_address => 'String',
|
204
|
+
:phone_number => 'String'
|
205
|
+
|
206
|
+
}
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
end
|