-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrefund-payment.rb
43 lines (36 loc) · 1.59 KB
/
refund-payment.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
require 'cybersource_rest_client'
require_relative '../Payments/simple-authorizationinternet.rb'
require_relative '../../../data/Configuration.rb'
public
class Refund_payment
def run()
id = (JSON.parse(Simple_authorizationinternet.new.run(true)))['id']
request_obj = CyberSource::RefundPaymentRequest.new
client_reference_information = CyberSource::Ptsv2paymentsidrefundsClientReferenceInformation.new
client_reference_information.code = "TC50171_3"
request_obj.client_reference_information = client_reference_information
order_information = CyberSource::Ptsv2paymentsidrefundsOrderInformation.new
amount_details = CyberSource::Ptsv2paymentsidcapturesOrderInformationAmountDetails.new
amount_details.total_amount = "10"
amount_details.currency = "USD"
order_information.amount_details = amount_details
request_obj.order_information = order_information
config = MerchantConfiguration.new.merchantConfigProp()
api_client = CyberSource::ApiClient.new
api_instance = CyberSource::RefundApi.new(api_client, config)
data, status_code, headers = api_instance.refund_payment(request_obj, id)
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
Refund_payment.new.run()
end
end