mastercard_masterpass_api 0.0.1
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 +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/data/414d686c777974526d2f71367141505a68304673746b633d.p12 +0 -0
- data/data/MTFMCOpenAPI.p12 +0 -0
- data/data/Sandbox-Profile.ini +22 -0
- data/data/SandboxMCOpenAPI.p12 +0 -0
- data/data/Stage-Profile.ini +19 -0
- data/data/StageMCOpenAPI.p12 +0 -0
- data/data/merchantInit.xml +5 -0
- data/data/preCheckoutRequest.xml +14 -0
- data/data/shoppingCart.xml +32 -0
- data/lib/mastercard_masterpass_api.rb +5 -0
- data/lib/mastercard_masterpass_api/access_token_response.rb +7 -0
- data/lib/mastercard_masterpass_api/masterpass_service.rb +145 -0
- data/lib/mastercard_masterpass_api/request_token_response.rb +7 -0
- data/lib/mastercard_masterpass_api/version.rb +3 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f6db9d701a78343ca7a180c1133648ee33ec0d77
|
4
|
+
data.tar.gz: 4f11bfb8b97ad84572515277c1e026d93bf51228
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3327b4416fce36334ceeb96fbae136dda73124618b44276c88d40c97cb10cf70b680513f6c0b7ac65f3b6bc6c0547b46212cf0a70a6c05e5729e17ed5afc5a96
|
7
|
+
data.tar.gz: 8cdf22a3b0e58301c973f2d439cb61009fc7aebe9c7b0c799686ccbdf86f5bd0de3bb8b9150c14231029fbe77c808cb082e0f832ab91525862d844a64aa571ea
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brady Georgen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MastercardMasterpassApi
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mastercard_masterpass_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mastercard_masterpass_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
Binary file
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
requesturl = "https://sandbox.api.mastercard.com/oauth/consumer/v1/request_token"
|
2
|
+
shoppingcarturl = "https://sandbox.api.mastercard.com/masterpass/v6/shopping-cart"
|
3
|
+
accessurl = "https://sandbox.api.mastercard.com/oauth/consumer/v1/access_token"
|
4
|
+
postbackurl = "https://sandbox.api.mastercard.com/masterpass/v6/transaction"
|
5
|
+
precheckouturl = "https://sandbox.api.mastercard.com/masterpass/v6/precheckout"
|
6
|
+
expresscheckouturl = "https://sandbox.api.mastercard.com/masterpass/v6/expresscheckout"
|
7
|
+
merchantiniturl = "https://sandbox.api.mastercard.com/masterpass/v6/merchant-initialization"
|
8
|
+
pairingcallbackpath = "/PairingCallback"
|
9
|
+
expresscallbackpath = "/PairingCallback?express=true"
|
10
|
+
callbackdomain = "http://ech-0a9d8282.corp.mastercard.test"
|
11
|
+
callbackpath = "/OauthCallbackServlet"
|
12
|
+
consumerkey = "cLb0tKkEJhGTITp_6ltDIibO5Wgbx4rIldeXM_jRd4b0476c!414f4859446c4a366c726a327474695545332b353049303d"
|
13
|
+
checkoutidentifier = "a4a6x1ywxlkxzhensyvad1hepuouaesuv"
|
14
|
+
keystorepath = "Certs/SandboxMCOpenAPI.p12"
|
15
|
+
keystorepassword = "changeit"
|
16
|
+
realm = "eWallet"
|
17
|
+
auth_level_basic = "false"
|
18
|
+
xmlVersion = "v2"
|
19
|
+
shippingSuppression = "false"
|
20
|
+
shippingprofiles = "US,CA,FR,MEX,NA,UK"
|
21
|
+
lightboxurl = "https://sandbox.masterpass.com/lightbox/Switch/integration/MasterPass.client.js"
|
22
|
+
standbycallback = "http://ech-0a9d8282.corp.mastercard.test"
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
requesturl = "https://stage.api.mastercard.com/oauth/consumer/v1/request_token"
|
2
|
+
shoppingcarturl = "https://stage.api.mastercard.com/masterpass/v6/shopping-cart"
|
3
|
+
accessurl = "https://stage.api.mastercard.com/oauth/consumer/v1/access_token"
|
4
|
+
postbackurl = "https://stage.api.mastercard.com/masterpass/v6/transaction"
|
5
|
+
precheckouturl = "https://stage.api.mastercard.com/masterpass/v6/precheckout"
|
6
|
+
expresscheckouturl = "https://stage.api.mastercard.com/masterpass/v6/expresscheckout"
|
7
|
+
merchantiniturl = "https://stage.api.mastercard.com/masterpass/v6/merchant-initialization"
|
8
|
+
pairingcallbackpath = "/PairingCallback"
|
9
|
+
callbackdomain = "http://projectabc.com"
|
10
|
+
callbackpath = "/OauthCallbackServlet"
|
11
|
+
consumerkey = "ca8orIOSNsSoGW2hfJ6aeDI4sQzUaWLg_JBuw0xF8b6e9e20!414d465850522b6d70504a64764c43436f325078565a493d"
|
12
|
+
checkoutidentifier = "a4d6x6r6zhak9hvkkkl091hvofxxmat4y"
|
13
|
+
keystorepath = "Certs/StageMCOpenAPI.p12"
|
14
|
+
keystorepassword = "lepassword"
|
15
|
+
realm = "eWallet"
|
16
|
+
auth_level_basic = "false"
|
17
|
+
xmlVersion = "v2"
|
18
|
+
shippingSuppression = "false"
|
19
|
+
shippingprofiles="US,CA,FR,MEX,NA,UK"
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<PrecheckoutDataRequest>
|
3
|
+
<PairingDataTypes>
|
4
|
+
<PairingDataType>
|
5
|
+
<Type>ADDRESS</Type>
|
6
|
+
</PairingDataType>
|
7
|
+
<PairingDataType>
|
8
|
+
<Type>PROFILE</Type>
|
9
|
+
</PairingDataType>
|
10
|
+
<PairingDataType>
|
11
|
+
<Type>CARD</Type>
|
12
|
+
</PairingDataType>
|
13
|
+
</PairingDataTypes>
|
14
|
+
</PrecheckoutDataRequest>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ShoppingCartRequest>
|
3
|
+
<OAuthToken></OAuthToken>
|
4
|
+
<ShoppingCart>
|
5
|
+
<CurrencyCode>USD</CurrencyCode>
|
6
|
+
<Subtotal>74996</Subtotal>
|
7
|
+
<ShoppingCartItem>
|
8
|
+
<Description>XBøx 360©</Description>
|
9
|
+
<Quantity>1</Quantity>
|
10
|
+
<Value>29999</Value>
|
11
|
+
<ImageURL>http://projectabc.com/images/xbox.jpg</ImageURL>
|
12
|
+
</ShoppingCartItem>
|
13
|
+
<ShoppingCartItem>
|
14
|
+
<Description>Cell Phonè™</Description>
|
15
|
+
<Quantity>1</Quantity>
|
16
|
+
<Value>4999</Value>
|
17
|
+
<ImageURL>http://projectabc.com/images/Cell Phone.jpg</ImageURL>
|
18
|
+
</ShoppingCartItem>
|
19
|
+
<ShoppingCartItem>
|
20
|
+
<Description>27" Moñitor</Description>
|
21
|
+
<Quantity>1</Quantity>
|
22
|
+
<Value>24999</Value>
|
23
|
+
<ImageURL>http://projectabc.com/images/monitor.jpg</ImageURL>
|
24
|
+
</ShoppingCartItem>
|
25
|
+
<ShoppingCartItem>
|
26
|
+
<Description>Ĝarmin ĜPS</Description>
|
27
|
+
<Quantity>1</Quantity>
|
28
|
+
<Value>14999</Value>
|
29
|
+
<ImageURL>http://projectabc.com/images/garmin.jpg</ImageURL>
|
30
|
+
</ShoppingCartItem>
|
31
|
+
</ShoppingCart>
|
32
|
+
</ShoppingCartRequest>
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require "mastercard_api"
|
2
|
+
require "rexml/document"
|
3
|
+
|
4
|
+
module Mastercard
|
5
|
+
module Masterpass
|
6
|
+
class MasterpassService < Mastercard::Common::Connector
|
7
|
+
|
8
|
+
include REXML
|
9
|
+
|
10
|
+
attr_accessor :origin_url
|
11
|
+
|
12
|
+
OAUTH_TOKEN = 'oauth_token'
|
13
|
+
OAUTH_VERIFIER = 'oauth_verifier'
|
14
|
+
OAUTH_TOKEN_SECRET = 'oauth_token_secret'
|
15
|
+
OAUTH_CALLBACK = 'oauth_callback'
|
16
|
+
OAUTH_CALLBACK_CONFIRMED = 'oauth_callback_confirmed'
|
17
|
+
OAUTH_EXPIRES_IN = 'oauth_expires_in'
|
18
|
+
REALM = "realm"
|
19
|
+
REALM_TYPE = "eWallet"
|
20
|
+
ORIGIN_URL = "originUrl"
|
21
|
+
|
22
|
+
REQUEST_AUTH_URL = "xoauth_request_auth_url"
|
23
|
+
URL_FORMAT = "?oauth_token%s&acceptable_cards=%s&checkout_identifier=%s&version=%s"
|
24
|
+
|
25
|
+
SUPPRESS_SHIPPING_URL_PARAMETER = "&suppress_shipping_address="
|
26
|
+
AUTH_LEVEL_BASIC_URL_PARAMETER = "&auth_level=basic"
|
27
|
+
ACCEPT_REWARD_PROGRAM = "accept_reward_program"
|
28
|
+
SHIPPING_LOCATION_PROFILE = "shipping_location_profile"
|
29
|
+
|
30
|
+
DEFAULT_VERSION = "v1"
|
31
|
+
XML_VERSION_REGEX = "v[0-9]+"
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def initialize(consumer_key, private_key, origin_url, environment)
|
36
|
+
super(consumer_key, private_key)
|
37
|
+
@environment = environment
|
38
|
+
@origin_url = origin_url
|
39
|
+
end
|
40
|
+
|
41
|
+
def oauth_parameters_factory
|
42
|
+
params = super
|
43
|
+
params.add_parameter REALM, REALM_TYPE
|
44
|
+
params
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_request_token(request_url, callback_url)
|
48
|
+
params = self.oauth_parameters_factory
|
49
|
+
params.add_parameter OAUTH_CALLBACK, callback_url
|
50
|
+
|
51
|
+
response = parse_request_token_response(do_request(request_url, POST, EMPTY_STRING, params))
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_access_token(access_url, request_token, oauth_verifier)
|
55
|
+
params = self.oauth_parameters_factory
|
56
|
+
params.add_parameter OAUTH_TOKEN, request_token
|
57
|
+
params.add_parameter OAUTH_VERIFIER, oauth_verifier
|
58
|
+
response = parse_access_token_response(do_request(access_url, POST, EMPTY_STRING, params))
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_pairing_token(request_url, callback_url)
|
62
|
+
response = get_request_token(request_url, callback_url)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_long_access_token(access_url, request_token, oauth_verifier)
|
66
|
+
response = get_access_token(access_url, request_token, oauth_verifier)
|
67
|
+
end
|
68
|
+
|
69
|
+
def post_shopping_cart_data(shopping_cart_url, shopping_cart_xml)
|
70
|
+
response = post_xml_data(shopping_cart_url, shopping_cart_xml)
|
71
|
+
end
|
72
|
+
|
73
|
+
def post_merchant_init_data(merchant_init_url, merchant_init_xml)
|
74
|
+
response = post_xml_data(merchant_init_url, merchant_init_xml)
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_precheckout_data(precheckout_url, precheckout_xml, access_token)
|
78
|
+
params = self.oauth_parameters_factory
|
79
|
+
params.add_parameter OAUTH_TOKEN, access_token
|
80
|
+
|
81
|
+
response = post_xml_data(precheckout_url, precheckout_xml, params)
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_payment_shipping_resource(checkout_resource_url, access_token)
|
85
|
+
if (checkout_resource_url == nil || access_token ==nil)
|
86
|
+
raise "cannot process payment shipping resource request without url and token"
|
87
|
+
end
|
88
|
+
|
89
|
+
params = self.oauth_parameters_factory
|
90
|
+
params.add_parameter OAUTH_TOKEN, access_token
|
91
|
+
response = do_request(checkout_resource_url, GET, nil, params)
|
92
|
+
end
|
93
|
+
|
94
|
+
def post_checkout_transaction(postback_url, merchant_transactions_xml)
|
95
|
+
response = post_xml_data(postback_url, merchant_transactions_xml.to_s)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_express_checkout_data(express_checkout_url, express_checkout_request_xml, access_token)
|
99
|
+
params = self.oauth_parameters_factory
|
100
|
+
params.add_parameter OAUTH_TOKEN, access_token
|
101
|
+
response = do_request(express_checkout_url, POST, express_checkout_request_xml, params)
|
102
|
+
response
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def parse_request_token_response(response)
|
108
|
+
vars = CGI::parse(response)
|
109
|
+
response_token = Mastercard::Masterpass::RequestTokenResponse.new
|
110
|
+
vars.each do |v|
|
111
|
+
method = v[0]
|
112
|
+
value = vars[method][0]
|
113
|
+
response_token.class.send(:define_method, method.to_sym) do
|
114
|
+
value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
response_token
|
118
|
+
end
|
119
|
+
|
120
|
+
def parse_access_token_response(response)
|
121
|
+
vars = CGI::parse(response)
|
122
|
+
response_token = Mastercard::Masterpass::AccessTokenResponse.new
|
123
|
+
vars.each do |v|
|
124
|
+
method = v[0]
|
125
|
+
value = vars[method][0]
|
126
|
+
response_token.class.send(:define_method, method.to_sym) do
|
127
|
+
value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
response_token
|
131
|
+
end
|
132
|
+
|
133
|
+
def post_xml_data(url, xml_data, params=nil)
|
134
|
+
if (xml_data == nil)
|
135
|
+
raise "XML Data cannot be nil"
|
136
|
+
end
|
137
|
+
params = oauth_parameters_factory if !params
|
138
|
+
response = do_request(url,POST,xml_data,params)
|
139
|
+
return response
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mastercard_masterpass_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brady Georgen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Masterpass Ruby API
|
42
|
+
email:
|
43
|
+
- pbradygeorgen@me.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE.txt
|
49
|
+
- README.md
|
50
|
+
- data/414d686c777974526d2f71367141505a68304673746b633d.p12
|
51
|
+
- data/MTFMCOpenAPI.p12
|
52
|
+
- data/Sandbox-Profile.ini
|
53
|
+
- data/SandboxMCOpenAPI.p12
|
54
|
+
- data/Stage-Profile.ini
|
55
|
+
- data/StageMCOpenAPI.p12
|
56
|
+
- data/merchantInit.xml
|
57
|
+
- data/preCheckoutRequest.xml
|
58
|
+
- data/shoppingCart.xml
|
59
|
+
- lib/mastercard_masterpass_api.rb
|
60
|
+
- lib/mastercard_masterpass_api/access_token_response.rb
|
61
|
+
- lib/mastercard_masterpass_api/masterpass_service.rb
|
62
|
+
- lib/mastercard_masterpass_api/request_token_response.rb
|
63
|
+
- lib/mastercard_masterpass_api/version.rb
|
64
|
+
homepage: ''
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.3
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Masterpass Ruby API
|
88
|
+
test_files: []
|