-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsale-using-emv-technology-with-contactless.rb
More file actions
59 lines (48 loc) · 2.4 KB
/
Copy pathsale-using-emv-technology-with-contactless.rb
File metadata and controls
59 lines (48 loc) · 2.4 KB
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
require 'cybersource_rest_client'
require_relative '../../../data/Configuration.rb'
public
class Sale_using_emv_technology_with_contactless
def run()
request_obj = CyberSource::CreatePaymentRequest.new
client_reference_information = CyberSource::Ptsv2paymentsClientReferenceInformation.new
client_reference_information.code = "123456"
request_obj.client_reference_information = client_reference_information
processing_information = CyberSource::Ptsv2paymentsProcessingInformation.new
processing_information.capture = false
processing_information.commerce_indicator = "retail"
request_obj.processing_information = processing_information
order_information = CyberSource::Ptsv2paymentsOrderInformation.new
amount_details = CyberSource::Ptsv2paymentsOrderInformationAmountDetails.new
amount_details.total_amount = "100.00"
amount_details.currency = "USD"
order_information.amount_details = amount_details
request_obj.order_information = order_information
point_of_sale_information = CyberSource::Ptsv2paymentsPointOfSaleInformation.new
point_of_sale_information.cat_level = 2
point_of_sale_information.entry_mode = "contactless"
point_of_sale_information.terminal_capability = 2
emv = CyberSource::Ptsv2paymentsPointOfSaleInformationEmv.new
emv.card_sequence_number = "999"
emv.fallback = false
point_of_sale_information.emv = emv
point_of_sale_information.track_data = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"
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
Sale_using_emv_technology_with_contactless.new.run()
end
end