|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'cybersource_rest_client' |
| 4 | +require_relative '../../data/Configuration' |
| 5 | + |
| 6 | +public |
| 7 | +class Create_instrument_identifier_card_enroll_for_network_token |
| 8 | + def run(profile_id = nil ) |
| 9 | + if profile_id == nil? |
| 10 | + profile_id = '93B32398-AD51-4CC2-A682-EA3E93614EB1' |
| 11 | + end |
| 12 | + request_obj = CyberSource::PostInstrumentIdentifierRequest.new |
| 13 | + request_obj.type = "enrollable card" |
| 14 | + card = CyberSource::Tmsv2customersEmbeddedDefaultPaymentInstrumentEmbeddedInstrumentIdentifierCard.new |
| 15 | + card.number = "5204245750003216" |
| 16 | + card.expiration_month = "12" |
| 17 | + card.expiration_year = "2025" |
| 18 | + request_obj.card = card |
| 19 | + |
| 20 | + opts = {} |
| 21 | + opts[:"profile-id"] = profile_id |
| 22 | + |
| 23 | + config = MerchantConfiguration.new.merchantConfigProp() |
| 24 | + api_client = CyberSource::ApiClient.new |
| 25 | + api_instance = CyberSource::InstrumentIdentifierApi.new(api_client, config) |
| 26 | + data, status_code, headers = api_instance.post_instrument_identifier(request_obj, opts) |
| 27 | + puts data, status_code, headers |
| 28 | + write_log_audit(status_code) |
| 29 | + return data |
| 30 | + rescue StandardError => err |
| 31 | + write_log_audit(err.code) |
| 32 | + puts err.message |
| 33 | + end |
| 34 | + |
| 35 | + def write_log_audit(status) |
| 36 | + filename = ($0.split("/")).last.split(".")[0] |
| 37 | + puts "[Sample Code Testing] [#{filename}] #{status}" |
| 38 | + end |
| 39 | + |
| 40 | + if __FILE__ == $0 |
| 41 | + profileid = '93B32398-AD51-4CC2-A682-EA3E93614EB1' |
| 42 | + Create_instrument_identifier_card_enroll_for_network_token.new.run(profileid) |
| 43 | + end |
| 44 | +end |
0 commit comments