-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathelectronic-check-debits.rb
71 lines (62 loc) · 2.77 KB
/
electronic-check-debits.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'cybersource_rest_client'
require_relative '../../../data/Configuration.rb'
public
class Electronic_check_debits
def run(flag)
request_obj = CyberSource::CreatePaymentRequest.new
client_reference_information = CyberSource::Ptsv2paymentsClientReferenceInformation.new
client_reference_information.code = "TC50171_3"
request_obj.client_reference_information = client_reference_information
processing_information = CyberSource::Ptsv2paymentsProcessingInformation.new
processing_information.capture = false
if flag == true
processing_information.capture = true
end
request_obj.processing_information = processing_information
payment_information = CyberSource::Ptsv2paymentsPaymentInformation.new
bank = CyberSource::Ptsv2paymentsPaymentInformationBank.new
account = CyberSource::Ptsv2paymentsPaymentInformationBankAccount.new
account.type = "C"
account.number = "4100"
bank.account = account
bank.routing_number = "071923284"
payment_information.bank = bank
payment_type = CyberSource::Ptsv2paymentsPaymentInformationPaymentType.new
payment_type.name = "CHECK"
payment_information.payment_type = payment_type
request_obj.payment_information = payment_information
order_information = CyberSource::Ptsv2paymentsOrderInformation.new
amount_details = CyberSource::Ptsv2paymentsOrderInformationAmountDetails.new
amount_details.total_amount = "100"
amount_details.currency = "USD"
order_information.amount_details = amount_details
bill_to = CyberSource::Ptsv2paymentsOrderInformationBillTo.new
bill_to.first_name = "John"
bill_to.last_name = "Doe"
bill_to.address1 = "1 Market St"
bill_to.locality = "san francisco"
bill_to.administrative_area = "CA"
bill_to.postal_code = "94105"
bill_to.country = "US"
bill_to.email = "test@cybs.com"
order_information.bill_to = bill_to
request_obj.order_information = order_information
config = MerchantConfiguration.new.merchantConfigProp()
api_client = CyberSource::ApiClient.new
api_instance = CyberSource::PaymentsApi.new(api_client, config)
data, status_code, headers = api_instance.create_payment(request_obj)
puts data, status_code, headers
write_log_audit(status_code)
return data
rescue StandardError => err
write_log_audit(err.code)
puts err.message
end
def write_log_audit(status)
filename = ($0.split("/")).last.split(".")[0]
puts "[Sample Code Testing] [#{filename}] #{status}"
end
if __FILE__ == $0
Electronic_check_debits.new.run(true)
end
end