breadmachine 0.0.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.
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/lib/breadmachine/dto/card.rb +22 -0
- data/lib/breadmachine/dto/customer_info.rb +16 -0
- data/lib/breadmachine/dto/order_info.rb +13 -0
- data/lib/breadmachine/dto/three_d_secure_credentials.rb +13 -0
- data/lib/breadmachine/extensions/money.rb +9 -0
- data/lib/breadmachine/extensions.rb +1 -0
- data/lib/breadmachine/secure_trading/auth_request.rb +38 -0
- data/lib/breadmachine/secure_trading/auth_reversal_request.rb +36 -0
- data/lib/breadmachine/secure_trading/auth_reversal_response.rb +6 -0
- data/lib/breadmachine/secure_trading/card_xml.rb +23 -0
- data/lib/breadmachine/secure_trading/config.rb +21 -0
- data/lib/breadmachine/secure_trading/customer_info_auth_xml.rb +40 -0
- data/lib/breadmachine/secure_trading/customer_info_enrolment_xml.rb +21 -0
- data/lib/breadmachine/secure_trading/order_info_xml.rb +21 -0
- data/lib/breadmachine/secure_trading/payment_methods.rb +28 -0
- data/lib/breadmachine/secure_trading/st_3d_auth_request.rb +41 -0
- data/lib/breadmachine/secure_trading/st_3d_auth_response.rb +25 -0
- data/lib/breadmachine/secure_trading/st_3d_card_query_request.rb +37 -0
- data/lib/breadmachine/secure_trading/st_3d_card_query_response.rb +46 -0
- data/lib/breadmachine/secure_trading/three_d_secure_credentials_xml.rb +23 -0
- data/lib/breadmachine/secure_trading/xpay.rb +25 -0
- data/lib/breadmachine/secure_trading/xpay_socket.rb +22 -0
- data/lib/breadmachine/secure_trading.rb +32 -0
- data/lib/breadmachine.rb +27 -0
- data/spec/blueprints.rb +38 -0
- data/spec/breadmachine_spec.rb +5 -0
- data/spec/extensions/money_spec.rb +24 -0
- data/spec/secure_trading/auth_request_spec.rb +58 -0
- data/spec/secure_trading/bread_machine_spec.rb +16 -0
- data/spec/secure_trading/card_xml_spec.rb +56 -0
- data/spec/secure_trading/config_spec.rb +12 -0
- data/spec/secure_trading/customer_info_auth_xml_spec.rb +94 -0
- data/spec/secure_trading/customer_info_enrolment_xml_spec.rb +31 -0
- data/spec/secure_trading/order_info_xml_spec.rb +31 -0
- data/spec/secure_trading/st_3d_auth_request_spec.rb +63 -0
- data/spec/secure_trading/st_3d_auth_response_spec.rb +5 -0
- data/spec/secure_trading/st_3d_card_query_request_spec.rb +63 -0
- data/spec/secure_trading/st_3d_card_query_response_spec.rb +79 -0
- data/spec/secure_trading/st_auth_request_spec.rb +0 -0
- data/spec/secure_trading/st_auth_reversal_request_spec.rb +0 -0
- data/spec/secure_trading/st_refund_request_spec.rb +0 -0
- data/spec/secure_trading/st_refund_reversal_request_spec.rb +0 -0
- data/spec/secure_trading/st_settlement_request_spec.rb +0 -0
- data/spec/secure_trading/three_d_secure_credentials_xml_spec.rb +42 -0
- data/spec/secure_trading/xpay_socket_spec.rb +14 -0
- data/spec/secure_trading/xpay_spec.rb +9 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/matchers/have_tag.rb +112 -0
- metadata +163 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Matt Southerden
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= breadmachine
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Matt Southerden. See LICENSE for details.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
|
3
|
+
class Card
|
4
|
+
|
5
|
+
include BreadMachine::SecureTrading::CardXml
|
6
|
+
|
7
|
+
attr_accessor :issuer
|
8
|
+
attr_accessor :number
|
9
|
+
attr_accessor :expiry_date
|
10
|
+
attr_accessor :start_date
|
11
|
+
attr_accessor :issue
|
12
|
+
attr_accessor :security_code
|
13
|
+
attr_accessor :transaction_verifier
|
14
|
+
attr_accessor :parent_transaction_reference
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
attributes.each { |key, value| send("#{key}=", value) }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
|
3
|
+
class CustomerInfo
|
4
|
+
|
5
|
+
attr_accessor :name_prefix, :first_name, :middle_name, :last_name, :name_suffix,
|
6
|
+
:company, :street, :city, :state, :postcode, :iso_2_country,
|
7
|
+
:telephone, :email,
|
8
|
+
:accept, :user_agent
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
attributes.each { |key, value| send("#{key}=", value) }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'breadmachine/extensions/money'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class AuthRequest
|
5
|
+
|
6
|
+
def initialize(amount, card, customer_info, order_info, settlement_day = 1)
|
7
|
+
@amount = amount
|
8
|
+
@card = card
|
9
|
+
@customer_info = BreadMachine::SecureTrading::CustomerInfoAuthXml.new(customer_info)
|
10
|
+
@order_info = BreadMachine::SecureTrading::OrderInfoXml.new(order_info)
|
11
|
+
@settlement_day = settlement_day
|
12
|
+
end
|
13
|
+
|
14
|
+
def response(xml)
|
15
|
+
St3dAuthResponse.new(xml)
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_xml
|
19
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
20
|
+
xml.Request("Type" => "AUTH") {
|
21
|
+
xml.Operation {
|
22
|
+
xml.Amount @amount.cents
|
23
|
+
xml.Currency BreadMachine::SecureTrading::configuration.currency
|
24
|
+
xml.SiteReference BreadMachine::SecureTrading::configuration.site_reference
|
25
|
+
xml.SettlementDay @settlement_day
|
26
|
+
}
|
27
|
+
xml << @customer_info.to_xml
|
28
|
+
xml.PaymentMethod {
|
29
|
+
xml << @card.to_xml
|
30
|
+
}
|
31
|
+
xml << @order_info.to_xml
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class AuthReversalRequest
|
5
|
+
|
6
|
+
def initialize(transaction, customer_info, order_info)
|
7
|
+
@transaction = transaction
|
8
|
+
@customer_info = BreadMachine::SecureTrading::CustomerInfoAuthXml.new(customer_info)
|
9
|
+
@order_info = BreadMachine::SecureTrading::OrderInfoXml.new(order_info)
|
10
|
+
end
|
11
|
+
|
12
|
+
def response(xml)
|
13
|
+
St3dAuthResponse.new(xml)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_xml
|
17
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
18
|
+
xml.Request("Type" => "AUTHREVERSAL") {
|
19
|
+
xml.Operation {
|
20
|
+
xml.SiteReference BreadMachine::SecureTrading::configuration.site_reference
|
21
|
+
}
|
22
|
+
# xml << @customer_info.to_xml
|
23
|
+
xml.PaymentMethod {
|
24
|
+
xml.CreditCard {
|
25
|
+
xml.ParentTransactionReference @transaction.transaction_reference
|
26
|
+
xml.TransactionVerifier @transaction.transaction_verifier
|
27
|
+
}
|
28
|
+
}
|
29
|
+
# xml << @order_info.to_xml
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
module CardXml
|
5
|
+
|
6
|
+
def to_xml
|
7
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
8
|
+
xml.CreditCard {
|
9
|
+
xml.Type @issuer
|
10
|
+
xml.Number @number
|
11
|
+
xml.ExpiryDate @expiry_date
|
12
|
+
xml.StartDate @start_date
|
13
|
+
xml.Issue @issue
|
14
|
+
xml.SecurityCode @security_code
|
15
|
+
xml.TransactionVerifier @transaction_verifier
|
16
|
+
xml.ParentTransactionReference @parent_transaction_reference
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class Config
|
5
|
+
|
6
|
+
attr_accessor :currency, :site_reference, :term_url, :merchant_name
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def configuration
|
10
|
+
@configuration ||= BreadMachine::SecureTrading::Config.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(&block)
|
14
|
+
yield configuration
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class CustomerInfoAuthXml
|
5
|
+
|
6
|
+
def initialize(customer_info)
|
7
|
+
@customer_info = customer_info
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
12
|
+
xml.CustomerInfo {
|
13
|
+
xml.Postal {
|
14
|
+
xml.Name {
|
15
|
+
xml.NamePrefix @customer_info.name_prefix
|
16
|
+
xml.FirstName @customer_info.first_name
|
17
|
+
xml.MiddleName @customer_info.middle_name
|
18
|
+
xml.LastName @customer_info.last_name
|
19
|
+
xml.NameSuffix @customer_info.name_suffix
|
20
|
+
}
|
21
|
+
xml.Company @customer_info.company
|
22
|
+
xml.Street @customer_info.street
|
23
|
+
xml.City @customer_info.city
|
24
|
+
xml.StateProv @customer_info.state
|
25
|
+
xml.PostalCode @customer_info.postcode
|
26
|
+
xml.CountryCode @customer_info.iso_2_country
|
27
|
+
}
|
28
|
+
xml.Telecom {
|
29
|
+
xml.Phone @customer_info.telephone
|
30
|
+
}
|
31
|
+
xml.Online {
|
32
|
+
xml.Email @customer_info.email
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class CustomerInfoEnrolmentXml
|
5
|
+
|
6
|
+
def initialize(customer_info)
|
7
|
+
@customer_info = customer_info
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
12
|
+
xml.CustomerInfo {
|
13
|
+
xml.Accept @customer_info.accept
|
14
|
+
xml.UserAgent @customer_info.user_agent
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class OrderInfoXml
|
5
|
+
|
6
|
+
def initialize(order_info)
|
7
|
+
@order_info = order_info
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
12
|
+
xml.Order {
|
13
|
+
xml.OrderReference @order_info.order_reference
|
14
|
+
xml.OrderInformation @order_info.order_information
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
module PaymentMethods
|
5
|
+
|
6
|
+
def auth(*args)
|
7
|
+
request = SecureTrading::AuthRequest.new(*args)
|
8
|
+
return SecureTrading::XPay.exchange(request)
|
9
|
+
end
|
10
|
+
|
11
|
+
def three_d_secure_enrolled?(*args)
|
12
|
+
request = SecureTrading::St3dCardQueryRequest.new(*args)
|
13
|
+
return SecureTrading::XPay.exchange(request)
|
14
|
+
end
|
15
|
+
|
16
|
+
def three_d_auth(*args)
|
17
|
+
request = SecureTrading::St3dAuthRequest.new(*args)
|
18
|
+
return SecureTrading::XPay.exchange(request)
|
19
|
+
end
|
20
|
+
|
21
|
+
def reverse(*args)
|
22
|
+
request = SecureTrading::AuthReversalRequest.new(*args)
|
23
|
+
return SecureTrading::XPay.exchange(request)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class St3dAuthRequest
|
5
|
+
|
6
|
+
def initialize(amount, card, customer_info, order_info, three_d_secure, settlement_day = 1)
|
7
|
+
@amount = amount
|
8
|
+
@card = card
|
9
|
+
@card.parent_transaction_reference = three_d_secure.transaction_reference
|
10
|
+
@customer_info = BreadMachine::SecureTrading::CustomerInfoAuthXml.new(customer_info)
|
11
|
+
@order_info = BreadMachine::SecureTrading::OrderInfoXml.new(order_info)
|
12
|
+
@three_d_secure = BreadMachine::SecureTrading::ThreeDSecureCredentialsXml.new(three_d_secure)
|
13
|
+
@settlement_day = settlement_day
|
14
|
+
end
|
15
|
+
|
16
|
+
def response(xml)
|
17
|
+
St3dAuthResponse.new(xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_xml
|
21
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
22
|
+
xml.Request("Type" => "ST3DAUTH") {
|
23
|
+
xml.Operation {
|
24
|
+
xml.Amount @amount.cents
|
25
|
+
xml.Currency BreadMachine::SecureTrading::configuration.currency
|
26
|
+
xml.SiteReference BreadMachine::SecureTrading::configuration.site_reference
|
27
|
+
xml.SettlementDay @settlement_day
|
28
|
+
}
|
29
|
+
xml << @customer_info.to_xml
|
30
|
+
xml.PaymentMethod {
|
31
|
+
xml << @card.to_xml
|
32
|
+
xml << @three_d_secure.to_xml
|
33
|
+
}
|
34
|
+
xml << @order_info.to_xml
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class St3dAuthResponse
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
@xml = Nokogiri::XML.parse(xml)
|
8
|
+
end
|
9
|
+
|
10
|
+
def successful?
|
11
|
+
@xml.xpath('//OperationResponse/Result').text == "1"
|
12
|
+
end
|
13
|
+
|
14
|
+
def transaction_reference
|
15
|
+
@xml.xpath('//OperationResponse/TransactionReference').text
|
16
|
+
end
|
17
|
+
|
18
|
+
def transaction_verifier
|
19
|
+
@xml.xpath('//OperationResponse/TransactionVerifier').text
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class St3dCardQueryRequest
|
5
|
+
|
6
|
+
def initialize(amount, card, customer_info, order_info)
|
7
|
+
@amount = amount
|
8
|
+
@customer_info = BreadMachine::SecureTrading::CustomerInfoEnrolmentXml.new(customer_info)
|
9
|
+
@order_info = BreadMachine::SecureTrading::OrderInfoXml.new(order_info)
|
10
|
+
@card = card
|
11
|
+
end
|
12
|
+
|
13
|
+
def response(xml)
|
14
|
+
St3dCardQueryResponse.new(xml)
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_xml
|
18
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
19
|
+
xml.Request("Type" => "ST3DCARDQUERY") {
|
20
|
+
xml.Operation {
|
21
|
+
xml.Amount @amount.cents
|
22
|
+
xml.Currency BreadMachine::SecureTrading::configuration.currency
|
23
|
+
xml.SiteReference BreadMachine::SecureTrading::configuration.site_reference
|
24
|
+
xml.TermUrl BreadMachine::SecureTrading::configuration.term_url
|
25
|
+
xml.MerchantName BreadMachine::SecureTrading::configuration.merchant_name
|
26
|
+
}
|
27
|
+
xml << @customer_info.to_xml
|
28
|
+
xml.PaymentMethod {
|
29
|
+
xml << @card.to_xml
|
30
|
+
}
|
31
|
+
xml << @order_info.to_xml
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class St3dCardQueryResponse
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
@xml = Nokogiri::XML.parse(xml)
|
8
|
+
end
|
9
|
+
|
10
|
+
def successful?
|
11
|
+
@xml.xpath('//OperationResponse/Result').text == "1"
|
12
|
+
end
|
13
|
+
|
14
|
+
def enrolled
|
15
|
+
{
|
16
|
+
'N/A' => :na,
|
17
|
+
'Y' => :yes,
|
18
|
+
'N' => :no,
|
19
|
+
'U' => :unknown
|
20
|
+
}[@xml.xpath('//OperationResponse/Enrolled').text]
|
21
|
+
end
|
22
|
+
|
23
|
+
def md
|
24
|
+
@xml.xpath('//OperationResponse/MD').text
|
25
|
+
end
|
26
|
+
|
27
|
+
def pa_req
|
28
|
+
@xml.xpath('//OperationResponse/PaReq').text
|
29
|
+
end
|
30
|
+
|
31
|
+
def acs_url
|
32
|
+
@xml.xpath('//OperationResponse/AcsUrl').text
|
33
|
+
end
|
34
|
+
|
35
|
+
def transaction_reference
|
36
|
+
@xml.xpath('//OperationResponse/TransactionReference').text
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth_type
|
40
|
+
BreadMachine::SecureTrading::St3dAuthRequest
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class ThreeDSecureCredentialsXml
|
5
|
+
|
6
|
+
def initialize(credentials)
|
7
|
+
@credentials = credentials
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_xml
|
11
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
12
|
+
xml.ThreeDSecure {
|
13
|
+
xml.Enrolled @credentials.enrolled
|
14
|
+
xml.PaRes @credentials.pa_res
|
15
|
+
xml.MD @credentials.md
|
16
|
+
xml.TransactionReference @credentials.transaction_reference
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
class XPay
|
5
|
+
def self.exchange(request)
|
6
|
+
|
7
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
8
|
+
xml.RequestBlock('Version' => '3.51') do |request_block|
|
9
|
+
request_block << request.to_xml
|
10
|
+
xml.Certificate BreadMachine::SecureTrading::configuration.site_reference
|
11
|
+
end
|
12
|
+
|
13
|
+
response_xml = nil
|
14
|
+
|
15
|
+
XPaySocket.open("localhost", 5000) do |socket|
|
16
|
+
socket.write xml.xml
|
17
|
+
response_xml = socket.read
|
18
|
+
end
|
19
|
+
|
20
|
+
request.response(response_xml)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
module SecureTrading
|
3
|
+
|
4
|
+
# This currently just delegates to TCPSocket, but this is where we will
|
5
|
+
# inject Fake Socket behaviour to disconnect from having the XPay
|
6
|
+
# client running during testing
|
7
|
+
|
8
|
+
class XPaySocket
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def open(*args, &block)
|
13
|
+
TCPSocket.open(*args, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BreadMachine
|
2
|
+
|
3
|
+
module SecureTrading
|
4
|
+
|
5
|
+
autoload :Config, 'breadmachine/secure_trading/config'
|
6
|
+
autoload :PaymentMethods, 'breadmachine/secure_trading/payment_methods'
|
7
|
+
|
8
|
+
autoload :XPay, 'breadmachine/secure_trading/xpay'
|
9
|
+
autoload :XPaySocket, 'breadmachine/secure_trading/xpay_socket'
|
10
|
+
|
11
|
+
autoload :CardXml, 'breadmachine/secure_trading/card_xml'
|
12
|
+
|
13
|
+
autoload :CustomerInfoAuthXml, 'breadmachine/secure_trading/customer_info_auth_xml'
|
14
|
+
autoload :CustomerInfoEnrolmentXml, 'breadmachine/secure_trading/customer_info_enrolment_xml'
|
15
|
+
autoload :ThreeDSecureCredentialsXml, 'breadmachine/secure_trading/three_d_secure_credentials_xml'
|
16
|
+
autoload :OrderInfoXml, 'breadmachine/secure_trading/order_info_xml'
|
17
|
+
|
18
|
+
autoload :St3dCardQueryRequest, 'breadmachine/secure_trading/st_3d_card_query_request'
|
19
|
+
autoload :St3dCardQueryResponse, 'breadmachine/secure_trading/st_3d_card_query_response'
|
20
|
+
|
21
|
+
autoload :St3dAuthRequest, 'breadmachine/secure_trading/st_3d_auth_request'
|
22
|
+
autoload :St3dAuthResponse, 'breadmachine/secure_trading/st_3d_auth_response'
|
23
|
+
|
24
|
+
autoload :AuthReversalRequest, 'breadmachine/secure_trading/auth_reversal_request'
|
25
|
+
autoload :AuthRequest, 'breadmachine/secure_trading/auth_request'
|
26
|
+
# autoload :AuthResponse, 'breadmachine/secure_trading/st_3d_auth_response'
|
27
|
+
|
28
|
+
extend BreadMachine::SecureTrading::Config::ClassMethods
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/breadmachine.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'money'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'builder'
|
4
|
+
|
5
|
+
require 'breadmachine/extensions'
|
6
|
+
|
7
|
+
require 'breadmachine/secure_trading'
|
8
|
+
|
9
|
+
module BreadMachine
|
10
|
+
|
11
|
+
autoload :Card, 'breadmachine/dto/card'
|
12
|
+
autoload :CustomerInfo, 'breadmachine/dto/customer_info'
|
13
|
+
autoload :OrderInfo, 'breadmachine/dto/order_info'
|
14
|
+
autoload :ThreeDSecureCredentials, 'breadmachine/dto/three_d_secure_credentials'
|
15
|
+
|
16
|
+
extend SecureTrading::PaymentMethods
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Builder::XmlBase
|
21
|
+
|
22
|
+
# Make generated xml easier to read by indenting appended xml strings out to
|
23
|
+
# the current indent level.
|
24
|
+
def <<(text)
|
25
|
+
_text(text.indent(@level * @indent))
|
26
|
+
end
|
27
|
+
end
|