eway_rapid 1.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.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -0
- data/LICENSE.md +21 -0
- data/README.md +96 -0
- data/Rakefile +14 -0
- data/eway_rapid.gemspec +26 -0
- data/lib/eway_rapid.rb +78 -0
- data/lib/eway_rapid/constants.rb +126 -0
- data/lib/eway_rapid/entities/cancel_authorisation_request.rb +9 -0
- data/lib/eway_rapid/entities/cancel_authorisation_response.rb +34 -0
- data/lib/eway_rapid/entities/capture_payment_request.rb +11 -0
- data/lib/eway_rapid/entities/capture_payment_response.rb +34 -0
- data/lib/eway_rapid/entities/create_access_code_request.rb +35 -0
- data/lib/eway_rapid/entities/create_access_code_response.rb +128 -0
- data/lib/eway_rapid/entities/create_access_code_shared_request.rb +53 -0
- data/lib/eway_rapid/entities/create_access_code_shared_response.rb +40 -0
- data/lib/eway_rapid/entities/create_customer_response.rb +8 -0
- data/lib/eway_rapid/entities/direct_customer_search_request.rb +9 -0
- data/lib/eway_rapid/entities/direct_customer_search_response.rb +23 -0
- data/lib/eway_rapid/entities/direct_payment_request.rb +29 -0
- data/lib/eway_rapid/entities/direct_payment_response.rb +58 -0
- data/lib/eway_rapid/entities/direct_refund_request.rb +26 -0
- data/lib/eway_rapid/entities/direct_refund_response.rb +44 -0
- data/lib/eway_rapid/entities/transaction_search_response.rb +23 -0
- data/lib/eway_rapid/exceptions.rb +51 -0
- data/lib/eway_rapid/message/convert/customer_to_internal_customer.rb +70 -0
- data/lib/eway_rapid/message/convert/direct_payment_to_trans_status.rb +47 -0
- data/lib/eway_rapid/message/convert/direct_refund_to_trans_status.rb +33 -0
- data/lib/eway_rapid/message/convert/internal_customer_to_customer.rb +41 -0
- data/lib/eway_rapid/message/convert/internal_trans_to_trans.rb +62 -0
- data/lib/eway_rapid/message/convert/internal_transaction_to_address.rb +27 -0
- data/lib/eway_rapid/message/convert/internal_transaction_to_status.rb +55 -0
- data/lib/eway_rapid/message/convert/payment_to_payment_details.rb +25 -0
- data/lib/eway_rapid/message/convert/request/refund_to_direct_refund_req.rb +41 -0
- data/lib/eway_rapid/message/convert/request/transaction_to_capture_payment.rb +28 -0
- data/lib/eway_rapid/message/convert/request/transaction_to_create_access_code_request.rb +58 -0
- data/lib/eway_rapid/message/convert/request/transaction_to_create_access_code_shared_request.rb +54 -0
- data/lib/eway_rapid/message/convert/request/transaction_to_direct_payment.rb +45 -0
- data/lib/eway_rapid/message/convert/response/access_code_shared_to_create_cust.rb +23 -0
- data/lib/eway_rapid/message/convert/response/access_code_shared_to_create_trans.rb +28 -0
- data/lib/eway_rapid/message/convert/response/access_code_to_create_cust.rb +24 -0
- data/lib/eway_rapid/message/convert/response/access_code_to_create_trans.rb +27 -0
- data/lib/eway_rapid/message/convert/response/cancel_authorisation_to_refund.rb +37 -0
- data/lib/eway_rapid/message/convert/response/capture_payment_to_create_transaction.rb +43 -0
- data/lib/eway_rapid/message/convert/response/direct_customer_to_query_customer.rb +55 -0
- data/lib/eway_rapid/message/convert/response/direct_payment_to_create_cust.rb +23 -0
- data/lib/eway_rapid/message/convert/response/direct_payment_to_create_trans.rb +32 -0
- data/lib/eway_rapid/message/convert/response/direct_refund_to_refund_response.rb +28 -0
- data/lib/eway_rapid/message/convert/response/search_to_query_trans.rb +30 -0
- data/lib/eway_rapid/message/convert/shipping_details_to_address.rb +35 -0
- data/lib/eway_rapid/message/convert/transaction_shipping_address.rb +37 -0
- data/lib/eway_rapid/message/convert/transaction_to_arr_line_item.rb +14 -0
- data/lib/eway_rapid/message/convert/transaction_to_arr_option.rb +25 -0
- data/lib/eway_rapid/message/convert/transaction_to_payment.rb +29 -0
- data/lib/eway_rapid/message/convert/verification_to_verification_result.rb +33 -0
- data/lib/eway_rapid/message/process/customer_process.rb +255 -0
- data/lib/eway_rapid/message/process/refund_process.rb +76 -0
- data/lib/eway_rapid/message/process/rest_process.rb +87 -0
- data/lib/eway_rapid/message/process/transaction_process.rb +139 -0
- data/lib/eway_rapid/models/enums.rb +126 -0
- data/lib/eway_rapid/models/internal_models.rb +431 -0
- data/lib/eway_rapid/models/models.rb +334 -0
- data/lib/eway_rapid/output/create_transaction_response.rb +24 -0
- data/lib/eway_rapid/output/query_customer_response.rb +25 -0
- data/lib/eway_rapid/output/query_transaction_response.rb +16 -0
- data/lib/eway_rapid/output/refund_response.rb +9 -0
- data/lib/eway_rapid/output/response_output.rb +14 -0
- data/lib/eway_rapid/rapid_client.rb +444 -0
- data/lib/eway_rapid/rapid_logger.rb +40 -0
- data/lib/eway_rapid/resources/err_code_resource_en.yml +237 -0
- data/lib/eway_rapid/resources/rapid-api.yml +4 -0
- data/lib/eway_rapid/version.rb +3 -0
- metadata +201 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CapturePaymentRequest
|
3
|
+
attr_accessor :transaction_id
|
4
|
+
attr_accessor :payment
|
5
|
+
|
6
|
+
def to_json(options={})
|
7
|
+
{Constants::REQUEST_TRANSACTION_ID => transaction_id,
|
8
|
+
Constants::PAYMENT => InternalModels::Payment.to_hash(payment)}.to_json
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CapturePaymentResponse
|
3
|
+
attr_accessor :response_code
|
4
|
+
attr_accessor :response_message
|
5
|
+
attr_accessor :transaction_id
|
6
|
+
attr_accessor :transaction_status
|
7
|
+
attr_accessor :errors
|
8
|
+
|
9
|
+
alias_method :transaction_status?, :transaction_status
|
10
|
+
|
11
|
+
def to_json(options={})
|
12
|
+
{Constants::RESPONSE_CODE => response_code,
|
13
|
+
Constants::RESPONSE_MESSAGE => response_message,
|
14
|
+
Constants::TRANSACTION_ID => transaction_id,
|
15
|
+
Constants::TRANSACTION_STATUS => transaction_status,
|
16
|
+
Constants::ERRORS => errors}.to_json
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.from_json(json)
|
20
|
+
hash = JSON.parse(json)
|
21
|
+
from_hash(hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.from_hash(hash)
|
25
|
+
capture_payment_response = CapturePaymentResponse.new
|
26
|
+
capture_payment_response.response_code = hash[Constants::RESPONSE_CODE]
|
27
|
+
capture_payment_response.response_message = hash[Constants::RESPONSE_MESSAGE]
|
28
|
+
capture_payment_response.transaction_id = hash[Constants::TRANSACTION_ID]
|
29
|
+
capture_payment_response.transaction_status = hash[Constants::TRANSACTION_STATUS]
|
30
|
+
capture_payment_response.errors = hash[Constants::ERRORS_CAPITALIZED]
|
31
|
+
capture_payment_response
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CreateAccessCodeRequest
|
3
|
+
attr_accessor :customer
|
4
|
+
attr_accessor :shipping_address
|
5
|
+
attr_accessor :shipping_method
|
6
|
+
attr_accessor :items
|
7
|
+
attr_accessor :options
|
8
|
+
attr_accessor :payment
|
9
|
+
attr_accessor :redirect_url
|
10
|
+
attr_accessor :method
|
11
|
+
attr_accessor :customer_ip
|
12
|
+
attr_accessor :device_id
|
13
|
+
attr_accessor :checkout_payment
|
14
|
+
attr_accessor :checkout_url
|
15
|
+
attr_accessor :transaction_type
|
16
|
+
attr_accessor :partner_id
|
17
|
+
|
18
|
+
def to_json(opts={})
|
19
|
+
{Constants::CUSTOMER => InternalModels::Customer.to_hash(customer),
|
20
|
+
Constants::SHIPPING_ADDRESS => InternalModels::ShippingAddress.to_hash(shipping_address),
|
21
|
+
Constants::SHIPPING_METHOD => shipping_method,
|
22
|
+
Constants::ITEMS => Models::LineItem.to_array(items),
|
23
|
+
Constants::OPTIONS => InternalModels::Option.to_array(options),
|
24
|
+
Constants::PAYMENT => InternalModels::Payment.to_hash(payment),
|
25
|
+
Constants::REDIRECT_URL => redirect_url,
|
26
|
+
Constants::METHOD => method,
|
27
|
+
Constants::CUSTOMER_DEVICE_IP => customer_ip,
|
28
|
+
Constants::DEVICE_ID => device_id,
|
29
|
+
Constants::CHECKOUT_PAYMENT => checkout_payment,
|
30
|
+
Constants::CHECKOUT_URL => checkout_url,
|
31
|
+
Constants::TRANSACTION_TYPE => transaction_type,
|
32
|
+
Constants::PARTNER_ID => partner_id}.to_json
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CreateAccessCodeResponse
|
3
|
+
attr_accessor :customer
|
4
|
+
attr_accessor :payment
|
5
|
+
attr_accessor :access_code
|
6
|
+
attr_accessor :form_action_url
|
7
|
+
attr_accessor :errors
|
8
|
+
attr_accessor :complete_checkout_url
|
9
|
+
attr_accessor :total_amount
|
10
|
+
attr_accessor :invoice_number
|
11
|
+
attr_accessor :invoice_description
|
12
|
+
attr_accessor :invoice_reference
|
13
|
+
attr_accessor :currency_code
|
14
|
+
attr_accessor :token_customer_id
|
15
|
+
attr_accessor :reference
|
16
|
+
attr_accessor :title
|
17
|
+
attr_accessor :first_name
|
18
|
+
attr_accessor :last_name
|
19
|
+
attr_accessor :company_name
|
20
|
+
attr_accessor :job_description
|
21
|
+
attr_accessor :street1
|
22
|
+
attr_accessor :street2
|
23
|
+
attr_accessor :city
|
24
|
+
attr_accessor :state
|
25
|
+
attr_accessor :postal_code
|
26
|
+
attr_accessor :country
|
27
|
+
attr_accessor :email
|
28
|
+
attr_accessor :phone
|
29
|
+
attr_accessor :mobile
|
30
|
+
attr_accessor :comments
|
31
|
+
attr_accessor :fax
|
32
|
+
attr_accessor :url
|
33
|
+
attr_accessor :card_number
|
34
|
+
attr_accessor :card_name
|
35
|
+
attr_accessor :card_expiry_month
|
36
|
+
attr_accessor :card_expiry_year
|
37
|
+
attr_accessor :card_start_month
|
38
|
+
attr_accessor :card_start_year
|
39
|
+
attr_accessor :card_issue_number
|
40
|
+
|
41
|
+
def to_json(options={})
|
42
|
+
{Constants::CUSTOMER => customer,
|
43
|
+
Constants::PAYMENT => payment,
|
44
|
+
Constants::ACCESS_CODE => access_code,
|
45
|
+
Constants::FORM_ACTION_URL => form_action_url,
|
46
|
+
Constants::ERRORS_CAPITALIZED => errors,
|
47
|
+
Constants::COMPLETE_CHECKOUT_URL => complete_checkout_url,
|
48
|
+
Constants::TOTAL_AMOUNT => total_amount,
|
49
|
+
Constants::INVOICE_NUMBER => invoice_number,
|
50
|
+
Constants::INVOICE_DESCRIPTION => invoice_description,
|
51
|
+
Constants::INVOICE_REFERENCE => invoice_reference,
|
52
|
+
Constants::CURRENCY_CODE => currency_code,
|
53
|
+
Constants::TOKEN_CUSTOMER_ID => token_customer_id,
|
54
|
+
Constants::REFERENCE => reference,
|
55
|
+
Constants::TITLE => title,
|
56
|
+
Constants::FIRST_NAME => first_name,
|
57
|
+
Constants::LAST_NAME => last_name,
|
58
|
+
Constants::COMPANY_NAME => company_name,
|
59
|
+
Constants::JOB_DESCRIPTION => job_description,
|
60
|
+
Constants::STREET1 => street1,
|
61
|
+
Constants::STREET2 => street2,
|
62
|
+
Constants::CITY => city,
|
63
|
+
Constants::STATE => state,
|
64
|
+
Constants::POSTAL_CODE => postal_code,
|
65
|
+
Constants::COUNTRY => country,
|
66
|
+
Constants::EMAIL => email,
|
67
|
+
Constants::PHONE => phone,
|
68
|
+
Constants::MOBILE => mobile,
|
69
|
+
Constants::COMMENTS => comments,
|
70
|
+
Constants::FAX => fax,
|
71
|
+
Constants::URL => url,
|
72
|
+
Constants::CARD_NUMBER => card_number,
|
73
|
+
Constants::CARD_NAME => card_name,
|
74
|
+
Constants::CARD_EXPIRY_MONTH => card_expiry_month,
|
75
|
+
Constants::CARD_EXPIRY_YEAR => card_expiry_year,
|
76
|
+
Constants::CARD_START_MONTH => card_start_month,
|
77
|
+
Constants::CARD_START_YEAR => card_start_year,
|
78
|
+
Constants::CARD_ISSUE_NUMBER => card_issue_number}.to_json
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.from_json(json)
|
82
|
+
hash = JSON.parse(json)
|
83
|
+
from_hash(hash)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.from_hash(hash)
|
87
|
+
create_access_code_response = CreateAccessCodeResponse.new
|
88
|
+
create_access_code_response.customer = InternalModels::Customer.from_hash(hash[Constants::CUSTOMER])
|
89
|
+
create_access_code_response.payment = InternalModels::Payment.from_hash(hash[Constants::PAYMENT])
|
90
|
+
create_access_code_response.access_code = hash[Constants::ACCESS_CODE]
|
91
|
+
create_access_code_response.form_action_url = hash[Constants::FORM_ACTION_URL]
|
92
|
+
create_access_code_response.errors = hash[Constants::ERRORS_CAPITALIZED]
|
93
|
+
create_access_code_response.complete_checkout_url = hash[Constants::COMPLETE_CHECKOUT_URL]
|
94
|
+
create_access_code_response.total_amount = hash[Constants::TOTAL_AMOUNT]
|
95
|
+
create_access_code_response.invoice_number = hash[Constants::INVOICE_NUMBER]
|
96
|
+
create_access_code_response.invoice_description = hash[Constants::INVOICE_DESCRIPTION]
|
97
|
+
create_access_code_response.invoice_reference = hash[Constants::INVOICE_REFERENCE]
|
98
|
+
create_access_code_response.currency_code = hash[Constants::CURRENCY_CODE]
|
99
|
+
create_access_code_response.token_customer_id = hash[Constants::TOKEN_CUSTOMER_ID]
|
100
|
+
create_access_code_response.reference = hash[Constants::REFERENCE]
|
101
|
+
create_access_code_response.title = hash[Constants::TITLE]
|
102
|
+
create_access_code_response.first_name = hash[Constants::FIRST_NAME]
|
103
|
+
create_access_code_response.last_name = hash[Constants::LAST_NAME]
|
104
|
+
create_access_code_response.company_name = hash[Constants::COMPANY_NAME]
|
105
|
+
create_access_code_response.job_description = hash[Constants::JOB_DESCRIPTION]
|
106
|
+
create_access_code_response.street1 = hash[Constants::STREET1]
|
107
|
+
create_access_code_response.street2 = hash[Constants::STREET2]
|
108
|
+
create_access_code_response.city = hash[Constants::CITY]
|
109
|
+
create_access_code_response.state = hash[Constants::STATE]
|
110
|
+
create_access_code_response.postal_code = hash[Constants::POSTAL_CODE]
|
111
|
+
create_access_code_response.country = hash[Constants::COUNTRY]
|
112
|
+
create_access_code_response.email = hash[Constants::EMAIL]
|
113
|
+
create_access_code_response.phone = hash[Constants::PHONE]
|
114
|
+
create_access_code_response.mobile = hash[Constants::MOBILE]
|
115
|
+
create_access_code_response.comments = hash[Constants::COMMENTS]
|
116
|
+
create_access_code_response.fax = hash[Constants::FAX]
|
117
|
+
create_access_code_response.url = hash[Constants::URL]
|
118
|
+
create_access_code_response.card_number = hash[Constants::CARD_NUMBER]
|
119
|
+
create_access_code_response.card_name = hash[Constants::CARD_NAME]
|
120
|
+
create_access_code_response.card_expiry_month = hash[Constants::CARD_EXPIRY_MONTH]
|
121
|
+
create_access_code_response.card_expiry_year = hash[Constants::CARD_EXPIRY_YEAR]
|
122
|
+
create_access_code_response.card_start_month = hash[Constants::CARD_START_MONTH]
|
123
|
+
create_access_code_response.card_start_year = hash[Constants::CARD_START_YEAR]
|
124
|
+
create_access_code_response.card_issue_number = hash[Constants::CARD_ISSUE_NUMBER]
|
125
|
+
create_access_code_response
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CreateAccessCodeSharedRequest
|
3
|
+
attr_accessor :customer
|
4
|
+
attr_accessor :shipping_address
|
5
|
+
attr_accessor :shipping_method
|
6
|
+
attr_accessor :items
|
7
|
+
attr_accessor :options
|
8
|
+
attr_accessor :payment
|
9
|
+
attr_accessor :redirect_url
|
10
|
+
attr_accessor :cancel_url
|
11
|
+
attr_accessor :checkout_url
|
12
|
+
attr_accessor :method
|
13
|
+
attr_accessor :device_id
|
14
|
+
attr_accessor :customer_ip
|
15
|
+
attr_accessor :transaction_type
|
16
|
+
attr_accessor :logo_url
|
17
|
+
attr_accessor :header_text
|
18
|
+
attr_accessor :partner_id
|
19
|
+
attr_accessor :language
|
20
|
+
attr_accessor :customer_read_only
|
21
|
+
attr_accessor :custom_view
|
22
|
+
attr_accessor :verify_customer_phone
|
23
|
+
attr_accessor :verify_customer_email
|
24
|
+
attr_accessor :checkout_payment
|
25
|
+
|
26
|
+
def to_json(opts={})
|
27
|
+
{
|
28
|
+
Constants::CUSTOMER => InternalModels::Customer.to_hash(customer),
|
29
|
+
Constants::SHIPPING_ADDRESS => InternalModels::ShippingAddress.to_hash(shipping_address),
|
30
|
+
Constants::SHIPPING_METHOD => shipping_method,
|
31
|
+
Constants::ITEMS => Models::LineItem.to_array(items),
|
32
|
+
Constants::OPTIONS => InternalModels::Option.to_array(options),
|
33
|
+
Constants::PAYMENT => InternalModels::Payment.to_hash(payment),
|
34
|
+
Constants::REDIRECT_URL => redirect_url,
|
35
|
+
Constants::CANCEL_URL => cancel_url,
|
36
|
+
Constants::CHECKOUT_URL => checkout_url,
|
37
|
+
Constants::METHOD => method,
|
38
|
+
Constants::DEVICE_ID => device_id,
|
39
|
+
Constants::CUSTOMER_DEVICE_IP => customer_ip,
|
40
|
+
Constants::TRANSACTION_TYPE => transaction_type,
|
41
|
+
Constants::LOGO_URL => logo_url,
|
42
|
+
Constants::HEADER_TEXT => header_text,
|
43
|
+
Constants::PARTNER_ID => partner_id,
|
44
|
+
Constants::LANGUAGE => language,
|
45
|
+
Constants::CUSTOMER_READ_ONLY => customer_read_only,
|
46
|
+
Constants::CUSTOMER_VIEW => custom_view,
|
47
|
+
Constants::VERIFY_CUSTOMER_PHONE => verify_customer_phone,
|
48
|
+
Constants::VERIFY_CUSTOMER_EMAIL => verify_customer_email,
|
49
|
+
Constants::CHECKOUT_PAYMENT => checkout_payment
|
50
|
+
}.to_json
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class CreateAccessCodeSharedResponse
|
3
|
+
attr_accessor :customer
|
4
|
+
attr_accessor :payment
|
5
|
+
attr_accessor :access_code
|
6
|
+
attr_accessor :form_action_url
|
7
|
+
attr_accessor :errors
|
8
|
+
attr_accessor :shared_payment_url
|
9
|
+
attr_accessor :complete_checkout_url
|
10
|
+
|
11
|
+
def to_json(options={})
|
12
|
+
{
|
13
|
+
Constants::CUSTOMER => customer,
|
14
|
+
Constants::PAYMENT => payment,
|
15
|
+
Constants::ACCESS_CODE => access_code,
|
16
|
+
Constants::FORM_ACTION_URL => form_action_url,
|
17
|
+
Constants::ERRORS_CAPITALIZED => errors,
|
18
|
+
Constants::SHARED_PAYMENT_URL => shared_payment_url,
|
19
|
+
Constants::COMPLETE_CHECKOUT_URL => complete_checkout_url
|
20
|
+
}.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.from_json(json)
|
24
|
+
hash = JSON.parse(json)
|
25
|
+
from_hash(hash)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.from_hash(hash)
|
29
|
+
create_access_code = CreateAccessCodeSharedResponse.new
|
30
|
+
create_access_code.customer = InternalModels::Customer.from_hash(hash[Constants::CUSTOMER])
|
31
|
+
create_access_code.payment = InternalModels::Payment.from_hash(hash[Constants::PAYMENT])
|
32
|
+
create_access_code.access_code = hash[Constants::ACCESS_CODE]
|
33
|
+
create_access_code.form_action_url = hash[Constants::FORM_ACTION_URL]
|
34
|
+
create_access_code.errors = hash[Constants::ERRORS_CAPITALIZED]
|
35
|
+
create_access_code.shared_payment_url = hash[Constants::SHARED_PAYMENT_URL]
|
36
|
+
create_access_code.complete_checkout_url = hash[Constants::COMPLETE_CHECKOUT_URL]
|
37
|
+
create_access_code
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class DirectCustomerSearchResponse
|
3
|
+
attr_accessor :customers
|
4
|
+
attr_accessor :errors
|
5
|
+
|
6
|
+
def to_json(options={})
|
7
|
+
{Constants::CUSTOMERS => customers,
|
8
|
+
Constants::ERRORS => errors}.to_json
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.from_json(json)
|
12
|
+
hash = JSON.parse(json)
|
13
|
+
from_hash(hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.from_hash(hash)
|
17
|
+
response = DirectCustomerSearchResponse.new
|
18
|
+
response.customers = InternalModels::Customer.from_array(hash[Constants::CUSTOMERS])
|
19
|
+
response.errors = hash[Constants::ERRORS_CAPITALIZED]
|
20
|
+
response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class DirectPaymentRequest
|
3
|
+
attr_accessor :customer
|
4
|
+
attr_accessor :shipping_address
|
5
|
+
attr_accessor :items
|
6
|
+
attr_accessor :options
|
7
|
+
attr_accessor :payment
|
8
|
+
attr_accessor :method
|
9
|
+
attr_accessor :transaction_type
|
10
|
+
attr_accessor :customer_ip
|
11
|
+
attr_accessor :device_id
|
12
|
+
attr_accessor :partner_id
|
13
|
+
attr_accessor :redirect_url
|
14
|
+
|
15
|
+
def to_json(opts={})
|
16
|
+
{Constants::CUSTOMER => InternalModels::Customer.to_hash(customer),
|
17
|
+
Constants::SHIPPING_ADDRESS => InternalModels::ShippingAddress.to_hash(shipping_address),
|
18
|
+
Constants::ITEMS => Models::LineItem.to_array(items),
|
19
|
+
Constants::OPTIONS => InternalModels::Option.to_array(options),
|
20
|
+
Constants::PAYMENT => InternalModels::Payment.to_hash(payment),
|
21
|
+
Constants::METHOD => method,
|
22
|
+
Constants::TRANSACTION_TYPE => transaction_type,
|
23
|
+
Constants::CUSTOMER_DEVICE_IP => customer_ip,
|
24
|
+
Constants::DEVICE_ID => device_id,
|
25
|
+
Constants::PARTNER_ID => partner_id,
|
26
|
+
Constants::REDIRECT_URL => redirect_url}.to_json
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module EwayRapid
|
2
|
+
class DirectPaymentResponse
|
3
|
+
attr_accessor :authorisation_code
|
4
|
+
attr_accessor :response_code
|
5
|
+
attr_accessor :response_message
|
6
|
+
attr_accessor :transaction_id
|
7
|
+
attr_accessor :transaction_status
|
8
|
+
attr_accessor :transaction_type
|
9
|
+
attr_accessor :beagle_score
|
10
|
+
attr_accessor :errors
|
11
|
+
attr_accessor :transaction_captured
|
12
|
+
attr_accessor :fraud_action
|
13
|
+
attr_accessor :verification
|
14
|
+
attr_accessor :customer
|
15
|
+
attr_accessor :payment
|
16
|
+
|
17
|
+
alias_method :transaction_status?, :transaction_status
|
18
|
+
|
19
|
+
def to_json(options={})
|
20
|
+
{Constants::AUTHORISATION_CODE => authorisation_code,
|
21
|
+
Constants::RESPONSE_CODE => response_code,
|
22
|
+
Constants::RESPONSE_MESSAGE => response_message,
|
23
|
+
Constants::TRANSACTION_ID => transaction_id,
|
24
|
+
Constants::TRANSACTION_STATUS => transaction_status,
|
25
|
+
Constants::TRANSACTION_TYPE => transaction_type,
|
26
|
+
Constants::BEAGLE_SCORE => beagle_score,
|
27
|
+
Constants::ERRORS_CAPITALIZED => errors,
|
28
|
+
Constants::TRANSACTION_CAPTURED => transaction_captured,
|
29
|
+
Constants::FRAUD_ACTION => fraud_action,
|
30
|
+
Constants::VERIFICATION => verification,
|
31
|
+
Constants::CUSTOMER => customer,
|
32
|
+
Constants::PAYMENT => payment}.to_json
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.from_json(json)
|
36
|
+
hash = JSON.parse(json)
|
37
|
+
from_hash(hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.from_hash(hash)
|
41
|
+
direct_payment_response = DirectPaymentResponse.new
|
42
|
+
direct_payment_response.authorisation_code = hash[Constants::AUTHORISATION_CODE]
|
43
|
+
direct_payment_response.response_code = hash[Constants::RESPONSE_CODE]
|
44
|
+
direct_payment_response.response_message = hash[Constants::RESPONSE_MESSAGE]
|
45
|
+
direct_payment_response.transaction_id = hash[Constants::TRANSACTION_ID]
|
46
|
+
direct_payment_response.transaction_status = hash[Constants::TRANSACTION_STATUS]
|
47
|
+
direct_payment_response.transaction_type = hash[Constants::TRANSACTION_TYPE]
|
48
|
+
direct_payment_response.beagle_score = hash[Constants::BEAGLE_SCORE]
|
49
|
+
direct_payment_response.errors = hash[Constants::ERRORS_CAPITALIZED]
|
50
|
+
direct_payment_response.transaction_captured = hash[Constants::TRANSACTION_CAPTURED]
|
51
|
+
direct_payment_response.fraud_action = hash[Constants::FRAUD_ACTION]
|
52
|
+
direct_payment_response.verification = InternalModels::Verification.from_hash(hash[Constants::VERIFICATION]) if hash[Constants::VERIFICATION]
|
53
|
+
direct_payment_response.customer = InternalModels::Customer.from_hash(hash[Constants::CUSTOMER])
|
54
|
+
direct_payment_response.payment = InternalModels::Payment.from_hash(hash[Constants::PAYMENT])
|
55
|
+
direct_payment_response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|