global_collect 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +11 -0
- data/README.markdown +109 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/examples/cancel_payment.rb +14 -0
- data/examples/convert_amount.rb +14 -0
- data/examples/get_order_status.rb +15 -0
- data/examples/insert_order_with_payment.rb +37 -0
- data/examples/process_challenged.rb +13 -0
- data/examples/set_payment.rb +23 -0
- data/examples/test_connection.rb +13 -0
- data/global_collect.gemspec +170 -0
- data/lib/global_collect/api_client.rb +71 -0
- data/lib/global_collect/builders/do_refund/credit_card_payment.rb +12 -0
- data/lib/global_collect/builders/do_refund/payment.rb +39 -0
- data/lib/global_collect/builders/insert_order_with_payment/credit_card_online_payment.rb +38 -0
- data/lib/global_collect/builders/insert_order_with_payment/hosted_credit_card_online_payment.rb +4 -0
- data/lib/global_collect/builders/insert_order_with_payment/order.rb +75 -0
- data/lib/global_collect/builders/insert_order_with_payment/payment.rb +25 -0
- data/lib/global_collect/builders/set_payment/payment.rb +23 -0
- data/lib/global_collect/const/payment_product.rb +38 -0
- data/lib/global_collect/const/payment_status.rb +90 -0
- data/lib/global_collect/field_validator.rb +47 -0
- data/lib/global_collect/request_models/base.rb +37 -0
- data/lib/global_collect/request_models/do_refund/credit_card_payment.rb +12 -0
- data/lib/global_collect/request_models/do_refund/payment.rb +39 -0
- data/lib/global_collect/request_models/insert_order_with_payment/credit_card_online_payment.rb +44 -0
- data/lib/global_collect/request_models/insert_order_with_payment/hosted_credit_card_online_payment.rb +19 -0
- data/lib/global_collect/request_models/insert_order_with_payment/order.rb +67 -0
- data/lib/global_collect/request_models/insert_order_with_payment/payment.rb +17 -0
- data/lib/global_collect/request_models/set_payment/payment.rb +17 -0
- data/lib/global_collect/requests/base.rb +43 -0
- data/lib/global_collect/requests/cancel_payment.rb +22 -0
- data/lib/global_collect/requests/composite.rb +23 -0
- data/lib/global_collect/requests/convert_amount.rb +29 -0
- data/lib/global_collect/requests/do_refund.rb +8 -0
- data/lib/global_collect/requests/get_order_status.rb +24 -0
- data/lib/global_collect/requests/insert_order_with_payment.rb +10 -0
- data/lib/global_collect/requests/process_challenged.rb +22 -0
- data/lib/global_collect/requests/set_payment.rb +9 -0
- data/lib/global_collect/requests/simple.rb +39 -0
- data/lib/global_collect/requests/test_connection.rb +8 -0
- data/lib/global_collect/responses/base.rb +73 -0
- data/lib/global_collect/responses/convert_amount/response_methods.rb +8 -0
- data/lib/global_collect/responses/do_refund/response_methods.rb +24 -0
- data/lib/global_collect/responses/get_order_status/v1_response_methods.rb +49 -0
- data/lib/global_collect/responses/get_order_status/v2_response_methods.rb +67 -0
- data/lib/global_collect/responses/insert_order_with_payment/credit_card_online_payment_response_methods.rb +31 -0
- data/lib/global_collect/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods.rb +16 -0
- data/lib/global_collect/responses/success_row.rb +15 -0
- data/lib/global_collect.rb +81 -0
- data/spec/api_client_spec.rb +93 -0
- data/spec/builders/do_refund/credit_card_payment_spec.rb +32 -0
- data/spec/builders/do_refund/payment_spec.rb +51 -0
- data/spec/builders/insert_order_with_payment/credit_card_online_payment_spec.rb +59 -0
- data/spec/builders/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb +59 -0
- data/spec/builders/insert_order_with_payment/order_spec.rb +88 -0
- data/spec/builders/insert_order_with_payment/payment_spec.rb +37 -0
- data/spec/builders/set_payment/payment_spec.rb +35 -0
- data/spec/field_validator_spec.rb +79 -0
- data/spec/global_collect_spec.rb +43 -0
- data/spec/request_models/base_spec.rb +31 -0
- data/spec/request_models/insert_order_with_payment/credit_card_online_payment_spec.rb +11 -0
- data/spec/request_models/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb +38 -0
- data/spec/requests/base_spec.rb +40 -0
- data/spec/requests/composite_spec.rb +48 -0
- data/spec/requests/convert_amount.rb +34 -0
- data/spec/requests/insert_order_with_payment_spec.rb +60 -0
- data/spec/requests/simple_spec.rb +37 -0
- data/spec/responses/base_spec.rb +59 -0
- data/spec/responses/convert_amount/response_methods_spec.rb +13 -0
- data/spec/responses/do_refund/response_methods_spec.rb +15 -0
- data/spec/responses/get_order_status/v1_response_methods_spec.rb +28 -0
- data/spec/responses/get_order_status/v2_response_methods_spec.rb +28 -0
- data/spec/responses/insert_order_with_payment/credit_card_online_payment_response_methods_spec.rb +13 -0
- data/spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb +13 -0
- data/spec/responses/succcess_row_spec.rb +26 -0
- data/spec/spec_helper.rb +130 -0
- data/spec/support/challenged_iowp_response.xml +51 -0
- data/spec/support/successful_convert_amount_response.xml +29 -0
- data/spec/support/successful_do_refund_response.xml +36 -0
- data/spec/support/successful_get_order_status_v1_response.xml +72 -0
- data/spec/support/successful_get_order_status_v2_response.xml +50 -0
- data/spec/support/successful_hosted_iowp_response.xml +60 -0
- data/spec/support/successful_iowp_response.xml +49 -0
- data/spec/support/successful_process_challenged_response.xml +26 -0
- data/spec/support/unsuccessful_do_refund_response.xml +29 -0
- data/spec/support/unsuccessful_iowp_response.xml +42 -0
- data/spec/support/unsuccessful_process_challenged_response.xml +30 -0
- metadata +213 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
module GlobalCollect::RequestModels
|
2
|
+
class Base
|
3
|
+
attr_accessor :errors
|
4
|
+
def suggested_response_mixins
|
5
|
+
[]
|
6
|
+
end
|
7
|
+
|
8
|
+
def fields
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
@attributes = {}
|
14
|
+
attributes.each {|k,v| self[k] = v }
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate
|
18
|
+
fields.each do |field, validations|
|
19
|
+
validator = GlobalCollect::FieldValidator.new(*validations)
|
20
|
+
unless validator.validate(@attributes[field])
|
21
|
+
@errors = { field => "is invalid. Should conform to #{validations.inspect}" }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return @errors.blank?
|
25
|
+
end
|
26
|
+
|
27
|
+
def [](key)
|
28
|
+
raise ArgumentError.new("Invalid attribute name '#{key}'!") unless fields.key?(key)
|
29
|
+
@attributes[key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def []=(key, value)
|
33
|
+
raise ArgumentError.new("Invalid attribute name '#{key}'!") unless fields.key?(key)
|
34
|
+
@attributes[key] = value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module GlobalCollect::RequestModels::DoRefund
|
2
|
+
class CreditCardPayment < Payment
|
3
|
+
# WDL §5.16.1 specifies the full list of possible fields
|
4
|
+
def fields
|
5
|
+
super.merge({
|
6
|
+
"PAYMENTPRODUCTID" => ["N5", "O"],
|
7
|
+
"CREDITCARDNUMBER" => ["N19", "O"],
|
8
|
+
"EXPIRYDATE" => ["N4", "O"]
|
9
|
+
})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module GlobalCollect::RequestModels::DoRefund
|
2
|
+
class Payment < GlobalCollect::RequestModels::Base
|
3
|
+
def suggested_response_mixins
|
4
|
+
[
|
5
|
+
GlobalCollect::Responses::SuccessRow,
|
6
|
+
GlobalCollect::Responses::DoRefund::ResponseMethods
|
7
|
+
]
|
8
|
+
end
|
9
|
+
|
10
|
+
# WDL §5.16.1 specifies the full list of possible fields
|
11
|
+
def fields
|
12
|
+
super.merge({
|
13
|
+
"ORDERID" => ["N10", "R"],
|
14
|
+
"EFFORTID" => ["N5", "O"],
|
15
|
+
"MERCHANTREFERENCE" => ["AN30", "R"],
|
16
|
+
"REFERENCEORIGPAYMENT" => ["AN30", "O"],
|
17
|
+
"CURRENCYCODE" => ["AN3", "O"],
|
18
|
+
"AMOUNT" => ["N12", "O"],
|
19
|
+
"COUNTRYCODE" => ["AN2", "O"],
|
20
|
+
"REFUNDDATE" => ["D", "O"],
|
21
|
+
"SURNAME" => ["AN35", "O"],
|
22
|
+
"FIRSTNAME" => ["AN15", "O"],
|
23
|
+
"PREFIXSURNAME" => ["AN15", "O"],
|
24
|
+
"TITLE" => ["AN35", "O"],
|
25
|
+
"COMPANYNAME" => ["AN40", "O"],
|
26
|
+
"COMPANYDATA" => ["AN50", "O"],
|
27
|
+
"STREET" => ["AN50", "O"],
|
28
|
+
"HOUSENUMBER" => ["AN15", "O"],
|
29
|
+
"ADDITIONALADDRESSINFO" => ["AN50", "O"],
|
30
|
+
"ZIP" => ["AN10", "O"],
|
31
|
+
"CITY" => ["AN40", "O"],
|
32
|
+
"STATE" => ["AN35", "O"],
|
33
|
+
"EMAILADDRESS" => ["AN70", "O"],
|
34
|
+
"EMAILTYPEINDICATOR" => ["N1", "O"]
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/lib/global_collect/request_models/insert_order_with_payment/credit_card_online_payment.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module GlobalCollect::RequestModels::InsertOrderWithPayment
|
2
|
+
class CreditCardOnlinePayment < Payment
|
3
|
+
def suggested_response_mixins
|
4
|
+
[
|
5
|
+
GlobalCollect::Responses::SuccessRow,
|
6
|
+
GlobalCollect::Responses::InsertOrderWithPayment::CreditCardOnlinePaymentResponseMethods
|
7
|
+
]
|
8
|
+
end
|
9
|
+
# WDL §5.28.1 TABLE 106 specifies the full list of possible fields
|
10
|
+
def fields
|
11
|
+
super.merge({
|
12
|
+
"EXPIRYDATE" => ['N4', 'R'],
|
13
|
+
"CREDITCARDNUMBER" => ['N19', 'R'],
|
14
|
+
"ISSUENUMBER" => ['N2', 'O'],
|
15
|
+
"CVV" => ['N4', 'O'],
|
16
|
+
"CVVINDICATOR" => ['N1', 'O'],
|
17
|
+
"AVSINDICATOR" => ['N1', 'O'],
|
18
|
+
"AUTHENTICATIONINDICATOR" => ['N1', 'O'],
|
19
|
+
"STTINDICATOR" => ['N1', 'O'],
|
20
|
+
"FIRSTNAME" => ['AN15', 'O'],
|
21
|
+
"PREFIXSURNAME" => ['AN15', 'O'],
|
22
|
+
"SURNAME" => ['AN35', 'O'],
|
23
|
+
"STREET" => ['AN50', 'O'],
|
24
|
+
"HOUSENUMBER" => ['AN15', 'O'],
|
25
|
+
"CUSTOMERIPADDRESS" => ['AN32', 'O'],
|
26
|
+
"ADDITIONALADDRESSINFO" => ['AN50', 'O'],
|
27
|
+
"ZIP" => ['AN10', 'O'],
|
28
|
+
"CITY" => ['AN40', 'O'],
|
29
|
+
"STATE" => ['AN35', 'O'],
|
30
|
+
"PHONENUMBER" => ['AN20', 'O'],
|
31
|
+
"EMAIL" => ['AN70', 'O'],
|
32
|
+
"BIRTHDATE" => ['N8', 'O'],
|
33
|
+
"DCCINDICATOR" => ['N1', 'O'],
|
34
|
+
"ISSUERAMOUNT" => ['N12', 'O'],
|
35
|
+
"ISSUERCURRENCYCODE" => ['AN3', 'O'],
|
36
|
+
"MARGINRATEPERCENTAGE" => ['N6 ', 'O'],
|
37
|
+
"EXCHANGERATESOURCENAME" => ['AN32', 'O'],
|
38
|
+
"EXCHANGERATE" => ['N12', 'O'],
|
39
|
+
"EXCHANGERATEVALIDTO" => ['N14', 'O'],
|
40
|
+
"MAC" => ['AN64', 'O']
|
41
|
+
})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GlobalCollect::RequestModels::InsertOrderWithPayment
|
2
|
+
class HostedCreditCardOnlinePayment < CreditCardOnlinePayment
|
3
|
+
def initialize(attributes)
|
4
|
+
super(attributes)
|
5
|
+
@attributes["HOSTEDINDICATOR"] = "1"
|
6
|
+
end
|
7
|
+
|
8
|
+
def suggested_response_mixins
|
9
|
+
super + [GlobalCollect::Responses::InsertOrderWithPayment::HostedMerchantLinkPaymentResponseMethods]
|
10
|
+
end
|
11
|
+
|
12
|
+
def fields
|
13
|
+
super.merge({
|
14
|
+
"EXPIRYDATE" => ['N4', 'O'],
|
15
|
+
"CREDITCARDNUMBER" => ['N19', 'O']
|
16
|
+
})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module GlobalCollect::RequestModels::InsertOrderWithPayment
|
2
|
+
class Order < GlobalCollect::RequestModels::Base
|
3
|
+
# WDL §5.28.1 First table specifies the full list of possible fields
|
4
|
+
def fields
|
5
|
+
super.merge({
|
6
|
+
"ORDERID" => ["N10" , "R"],
|
7
|
+
"ORDERTYPE" => ["N1" , "O"],
|
8
|
+
"AMOUNT" => ["N12" , "R"],
|
9
|
+
"AMOUNTSIGN" => ["AN1" , "O"],
|
10
|
+
"CURRENCYCODE" => ["AN3" , "R"],
|
11
|
+
"LANGUAGECODE" => ["AN2" , "R"],
|
12
|
+
"COUNTRYCODE" => ["AN2" , "R"],
|
13
|
+
"OVERWRITEPAYMENTREFERNCE" => ["AN12" , "O"],
|
14
|
+
"IPADDRESSCUSTOMER" => ["AN32" , "O"],
|
15
|
+
"CUSTOMERID" => ["AN15" , "O"],
|
16
|
+
"MANDATE" => ["AN10" , "O"],
|
17
|
+
"TITLE" => ["AN35" , "O"],
|
18
|
+
"FIRSTNAME" => ["AN15" , "O"],
|
19
|
+
"PREFIXSURNAME" => ["AN15" , "O"],
|
20
|
+
"SURNAME" => ["AN35" , "O"],
|
21
|
+
"STREET" => ["AN50" , "O"],
|
22
|
+
"HOUSENUMBER" => ["AN15" , "O"],
|
23
|
+
"ADDITIONALADDRESSINFO" => ["AN50" , "O"],
|
24
|
+
"ZIP" => ["AN10" , "O"],
|
25
|
+
"CITY" => ["AN40" , "O"],
|
26
|
+
"STATE" => ["AN35" , "O"],
|
27
|
+
"SHIPPINGTITLE" => ["AN35" , "O"],
|
28
|
+
"SHIPPINGFIRSTNAME" => ["AN15" , "O"],
|
29
|
+
"SHIPPINGPREFIXSURNAME" => ["AN15" , "O"],
|
30
|
+
"SHIPPINGSURNAME" => ["AN35" , "O"],
|
31
|
+
"SHIPPINGSTREET" => ["AN50" , "O"],
|
32
|
+
"SHIPPINGHOUSENUMBER" => ["AN15" , "O"],
|
33
|
+
"SHIPPINGADDITIONALADDRESSINFO" => ["AN50" , "O"],
|
34
|
+
"SHIPPINGZIP" => ["AN10" , "O"],
|
35
|
+
"SHIPPINGCITY" => ["AN40" , "O"],
|
36
|
+
"SHIPPINGSTATE" => ["AN35" , "O"],
|
37
|
+
"SHIPPINGCOUNTRYCODE" => ["AN2" , "O"],
|
38
|
+
"MERCHANTREFERENCE" => ["AN30" , "R"],
|
39
|
+
"DESCRIPTOR" => ["AN50" , "O"],
|
40
|
+
"RESELLERID" => ["N10" , "O"],
|
41
|
+
"EMAIL" => ["AN70" , "O"],
|
42
|
+
"EMAILTYPEINDICATOR" => ["N1" , "O"],
|
43
|
+
"COMPANYNAME" => ["AN40" , "O"],
|
44
|
+
"COMPANYDATA" => ["AN40" , "O"],
|
45
|
+
"SEX" => ["AN1" , "O"],
|
46
|
+
"VATNUMBER" => ["AN17" , "O"],
|
47
|
+
"PHONENUMBER" => ["AN20" , "O"],
|
48
|
+
"FAXNUMBER" => ["AN20" , "O"],
|
49
|
+
"INVOICENUMBER" => ["AN20" , "O"],
|
50
|
+
"INVOICETYPE" => ["AN2" , "O"],
|
51
|
+
"INVOICEDATE" => ["D" , "O"],
|
52
|
+
"INVOICECLASS" => ["AN10" , "O"],
|
53
|
+
"ORDERDATE" => ["D" , "O"],
|
54
|
+
"BIRTHDATE" => ["N8" , "O"],
|
55
|
+
"TEXTQUALIFIER1" => ["AN10" , "O"],
|
56
|
+
"TEXTQUALIFIER2" => ["AN10" , "O"],
|
57
|
+
"TEXTQUALIFIER3" => ["AN10" , "O"],
|
58
|
+
"ADDITIONALDATA" => ["AN500" , "O"],
|
59
|
+
"STARTDATE" => ["N14" , "O"],
|
60
|
+
"ENDDATE" => ["N14" , "O"],
|
61
|
+
"NUMBEROFPAYMENTS" => ["N5" , "O"],
|
62
|
+
"STEPWEEK" => ["N5" , "O"],
|
63
|
+
"STEPMONTH" => ["N5" , "O"]
|
64
|
+
})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GlobalCollect::RequestModels::InsertOrderWithPayment
|
2
|
+
class Payment < GlobalCollect::RequestModels::Base
|
3
|
+
# WDL §5.28.1 TABLE 105 specifies the full list of possible fields
|
4
|
+
def fields
|
5
|
+
super.merge({
|
6
|
+
"PAYMENTPRODUCTID" => ["N5" , "R"],
|
7
|
+
"AMOUNT" => ["N12" , "R"],
|
8
|
+
"AMOUNTSIGN" => ["AN1" , "O"],
|
9
|
+
"CURRENCYCODE" => ["AN3" , "R"],
|
10
|
+
"LANGUAGECODE" => ["AN2" , "R"],
|
11
|
+
"COUNTRYCODE" => ["AN2" , "R"],
|
12
|
+
"HOSTEDINDICATOR" => ["N1" , "O"],
|
13
|
+
"RETURNURL" => ["AN512", "O"]
|
14
|
+
})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GlobalCollect::RequestModels::SetPayment
|
2
|
+
class Payment < GlobalCollect::RequestModels::Base
|
3
|
+
# WDL §5.33.1 specifies the full list of possible fields
|
4
|
+
def fields
|
5
|
+
super.merge({
|
6
|
+
"ORDERID" => ["N10", "R"],
|
7
|
+
"EFFORTID" => ["N5", "O"],
|
8
|
+
"PAYMENTPRODUCTID" => ["N5", "R"],
|
9
|
+
"AMOUNT" => ["N12", "O"],
|
10
|
+
"CURRENCYCODE" => ["AN3", "O"],
|
11
|
+
"DATECOLLECT" => ["D8", "O"]
|
12
|
+
})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class Base
|
3
|
+
attr_accessor :action
|
4
|
+
attr_reader :version
|
5
|
+
attr_reader :suggested_response_mixins
|
6
|
+
|
7
|
+
def initialize(action)
|
8
|
+
@action = action
|
9
|
+
@suggested_response_mixins ||= []
|
10
|
+
@version = GlobalCollect::default_api_version
|
11
|
+
end
|
12
|
+
|
13
|
+
def version=(v)
|
14
|
+
raise ArgumentError.new("Invalid version identifier!") unless %w[1.0 2.0].include?(v)
|
15
|
+
@version = v
|
16
|
+
end
|
17
|
+
|
18
|
+
# WDL §3.1
|
19
|
+
def default_xml_encoding_options
|
20
|
+
{ :encoding => "UTF-8" }
|
21
|
+
end
|
22
|
+
|
23
|
+
# WDL §4
|
24
|
+
def to_xml
|
25
|
+
xml = Builder::XmlMarkup.new
|
26
|
+
xml.instruct!(:xml, default_xml_encoding_options)
|
27
|
+
xml.tag!("XML") do |xml_node|
|
28
|
+
xml_node.tag!("REQUEST") do |req_node|
|
29
|
+
req_node.tag!("ACTION", @action)
|
30
|
+
req_node.tag!("META") do |meta_node|
|
31
|
+
meta_node.tag!("IPADDRESS" , GlobalCollect::ip_address ) if GlobalCollect::authentication_scheme == :ip_check
|
32
|
+
meta_node.tag!("MERCHANTID", GlobalCollect::merchant_id)
|
33
|
+
meta_node.tag!("VERSION" , version)
|
34
|
+
end
|
35
|
+
req_node.tag!("PARAMS") do |params_node|
|
36
|
+
yield(params_node)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
xml.target!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class CancelPayment < GlobalCollect::Requests::Simple
|
3
|
+
# WDL §5.2
|
4
|
+
def initialize(order_id, effort_id, attempt_id)
|
5
|
+
super("CANCEL_PAYMENT", {
|
6
|
+
"ORDERID" => order_id,
|
7
|
+
"EFFORTID" => effort_id,
|
8
|
+
"ATTEMPTID" => attempt_id
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def wrapper; "PAYMENT"; end
|
13
|
+
|
14
|
+
def fields
|
15
|
+
{
|
16
|
+
"ORDERID" => ["N10", "R"],
|
17
|
+
"EFFORTID" => ["N5", "R"],
|
18
|
+
"ATTEMPTID" => ["N5", "R"]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class Composite < GlobalCollect::Requests::Base
|
3
|
+
|
4
|
+
def initialize(action, model_builder_pairs)
|
5
|
+
unless model_builder_pairs.map(&:size).uniq == [2]
|
6
|
+
raise ArgumentError.new("Models and builders must be in array pairs like [[model,builder_class],...]!")
|
7
|
+
end
|
8
|
+
@contents = model_builder_pairs
|
9
|
+
super(action)
|
10
|
+
@suggested_response_mixins = model_builder_pairs.map(&:first).map(&:suggested_response_mixins).flatten.uniq
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_xml
|
14
|
+
super do |params_node|
|
15
|
+
@contents.each do |model,builder_class|
|
16
|
+
raise "Invalid model #{model.inspect}. Errors: #{model.errors.inspect}!" unless model.validate
|
17
|
+
builder = builder_class.new(model)
|
18
|
+
builder.build(params_node)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class ConvertAmount < GlobalCollect::Requests::Simple
|
3
|
+
# WDL §5.7
|
4
|
+
def initialize(amount, source_currency, target_currency)
|
5
|
+
super("CONVERT_AMOUNT", {
|
6
|
+
"AMOUNT" => amount,
|
7
|
+
"SOURCECURRENCYCODE" => source_currency,
|
8
|
+
"TARGETCURRENCYCODE" => target_currency
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def suggested_response_mixins
|
13
|
+
[
|
14
|
+
GlobalCollect::Responses::SuccessRow,
|
15
|
+
GlobalCollect::Responses::ConvertAmount::ResponseMethods
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def wrapper; "GENERAL"; end
|
20
|
+
|
21
|
+
def fields
|
22
|
+
{
|
23
|
+
"AMOUNT" => ["N12", "R"],
|
24
|
+
"SOURCECURRENCYCODE" => ["AN3", "R"],
|
25
|
+
"TARGETCURRENCYCODE" => ["AN3", "R"]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class GetOrderStatus < GlobalCollect::Requests::Simple
|
3
|
+
# WDL §5.23
|
4
|
+
def initialize(order_id)
|
5
|
+
super("GET_ORDERSTATUS", { "ORDERID" => order_id })
|
6
|
+
end
|
7
|
+
|
8
|
+
def suggested_response_mixins
|
9
|
+
case self.version
|
10
|
+
when "1.0" then [GlobalCollect::Responses::GetOrderStatus::V1ResponseMethods]
|
11
|
+
when "2.0" then [GlobalCollect::Responses::GetOrderStatus::V2ResponseMethods]
|
12
|
+
else []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def wrapper; "ORDER"; end
|
17
|
+
|
18
|
+
def fields
|
19
|
+
{
|
20
|
+
"ORDERID" => ["N10", "R"]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class InsertOrderWithPayment < GlobalCollect::Requests::Composite
|
3
|
+
# WDL §5.28 requires ORDER and PAYMENT nodes in PARAMS, but may optionally
|
4
|
+
# include AIRLINEDATA and ORDERLINES, as well.
|
5
|
+
def initialize(order_and_builder, payment_and_builder, *extra_pairs)
|
6
|
+
all_pairs = [order_and_builder, payment_and_builder] + extra_pairs
|
7
|
+
super("INSERT_ORDERWITHPAYMENT", all_pairs)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module GlobalCollect::Requests
|
2
|
+
class ProcessChallenged < GlobalCollect::Requests::Simple
|
3
|
+
# WDL §5.30
|
4
|
+
def initialize(order_id, effort_id=nil, attempt_id=nil)
|
5
|
+
super("PROCESS_CHALLENGED", {
|
6
|
+
"ORDERID" => order_id,
|
7
|
+
"EFFORTID" => effort_id,
|
8
|
+
"ATTEMPTID" => attempt_id
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def wrapper; "PAYMENT"; end
|
13
|
+
|
14
|
+
def fields
|
15
|
+
{
|
16
|
+
"ORDERID" => ["N10", "R"],
|
17
|
+
"EFFORTID" => ["N5", "O"],
|
18
|
+
"ATTEMPTID" => ["N5", "O"]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|