-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpartial-authorization.rb
70 lines (61 loc) · 2.73 KB
/
partial-authorization.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
require 'cybersource_rest_client'
require_relative '../../../data/Configuration.rb'
public
class Partial_authorization
def run()
request_obj = CyberSource::CreatePaymentRequest.new
client_reference_information = CyberSource::Ptsv2paymentsClientReferenceInformation.new
client_reference_information.code = "1234567890"
request_obj.client_reference_information = client_reference_information
payment_information = CyberSource::Ptsv2paymentsPaymentInformation.new
card = CyberSource::Ptsv2paymentsPaymentInformationCard.new
card.number = "4111111111111111"
card.expiration_month = "12"
card.expiration_year = "2031"
card.security_code = "123"
payment_information.card = card
request_obj.payment_information = payment_information
order_information = CyberSource::Ptsv2paymentsOrderInformation.new
amount_details = CyberSource::Ptsv2paymentsOrderInformationAmountDetails.new
amount_details.total_amount = "7012.00"
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"
bill_to.phone_number = "4158880000"
order_information.bill_to = bill_to
request_obj.order_information = order_information
point_of_sale_information = CyberSource::Ptsv2paymentsPointOfSaleInformation.new
point_of_sale_information.cat_level = 6
point_of_sale_information.terminal_capability = 4
emv = CyberSource::Ptsv2paymentsPointOfSaleInformationEmv.new
emv.fallback = false
emv.fallback_condition = 1
point_of_sale_information.emv = emv
request_obj.point_of_sale_information = point_of_sale_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
Partial_authorization.new.run()
end
end