|
| 1 | +require 'cybersource_rest_client' |
| 2 | +require_relative '../../data/MerchantBoardingConfiguration.rb' |
| 3 | + |
| 4 | +public |
| 5 | +class Create_registration |
| 6 | + def run() |
| 7 | + |
| 8 | + # Create the request object |
| 9 | + req_obj = CyberSource::PostRegistrationBody.new |
| 10 | + |
| 11 | + # Setup Organization Information |
| 12 | + organization_information = CyberSource::Boardingv1registrationsOrganizationInformation.new |
| 13 | + organization_information.parent_organization_id = "apitester00" |
| 14 | + organization_information.type = "MERCHANT" |
| 15 | + organization_information.configurable = true |
| 16 | + |
| 17 | + # Setup Business Information |
| 18 | + business_information = CyberSource::Boardingv1registrationsOrganizationInformationBusinessInformation.new |
| 19 | + business_information.name = "StuartWickedFastEatz" |
| 20 | + |
| 21 | + address = CyberSource::Boardingv1registrationsOrganizationInformationBusinessInformationAddress.new |
| 22 | + address.country = "US" |
| 23 | + address.address1 = "123456 SandMarket" |
| 24 | + address.locality = "ORMOND BEACH" |
| 25 | + address.administrative_area = "FL" |
| 26 | + address.postal_code = "32176" |
| 27 | + business_information.address = address |
| 28 | + |
| 29 | + business_information.website_url = "https://www.StuartWickedEats.com" |
| 30 | + business_information.phone_number = "6574567813" |
| 31 | + |
| 32 | + # Setup Business Contact |
| 33 | + business_contact = CyberSource::Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact.new |
| 34 | + business_contact.first_name = "Stuart" |
| 35 | + business_contact.last_name = "Stuart" |
| 36 | + business_contact.phone_number = "6574567813" |
| 37 | + business_contact.email = "[email protected]" |
| 38 | + business_information.business_contact = business_contact |
| 39 | + |
| 40 | + business_information.merchant_category_code = "5999" |
| 41 | + organization_information.business_information = business_information |
| 42 | + req_obj.organization_information = organization_information |
| 43 | + |
| 44 | + # Setup Product Information |
| 45 | + product_information = CyberSource::Boardingv1registrationsProductInformation.new |
| 46 | + selected_products = CyberSource::Boardingv1registrationsProductInformationSelectedProducts.new |
| 47 | + payments = CyberSource::PaymentsProducts.new |
| 48 | + |
| 49 | + # Setup Payments Products |
| 50 | + payer_authentication = CyberSource::PaymentsProductsPayerAuthentication.new |
| 51 | + subscription_information = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 52 | + subscription_information.enabled = true |
| 53 | + payer_authentication.subscription_information = subscription_information |
| 54 | + |
| 55 | + configuration_information = CyberSource::PaymentsProductsPayerAuthenticationConfigurationInformation.new |
| 56 | + configurations = CyberSource::PayerAuthConfig.new |
| 57 | + card_types = CyberSource::PayerAuthConfigCardTypes.new |
| 58 | + verified_by_visa = CyberSource::PayerAuthConfigCardTypesVerifiedByVisa.new |
| 59 | + currencies = [] |
| 60 | + currency1 = CyberSource::PayerAuthConfigCardTypesVerifiedByVisaCurrencies.new |
| 61 | + currency1.currency_codes = ["ALL"] |
| 62 | + currency1.acquirer_id = "469216" |
| 63 | + currency1.processor_merchant_id = "678855" |
| 64 | + |
| 65 | + currencies << currency1 |
| 66 | + verified_by_visa.currencies = currencies |
| 67 | + card_types.verified_by_visa = verified_by_visa |
| 68 | + configurations.card_types = card_types |
| 69 | + configuration_information.configurations = configurations |
| 70 | + payer_authentication.configuration_information = configuration_information |
| 71 | + payments.payer_authentication = payer_authentication |
| 72 | + |
| 73 | + # Setup Card Processing |
| 74 | + card_processing = CyberSource::PaymentsProductsCardProcessing.new |
| 75 | + subscription_information2 = CyberSource::PaymentsProductsCardProcessingSubscriptionInformation.new |
| 76 | + subscription_information2.enabled = true |
| 77 | + features = {} |
| 78 | + features['cardNotPresent'] = CyberSource::PaymentsProductsCardProcessingSubscriptionInformationFeatures.new(enabled: true) |
| 79 | + subscription_information2.features = features |
| 80 | + card_processing.subscription_information = subscription_information2 |
| 81 | + |
| 82 | + configuration_information2 = CyberSource::PaymentsProductsCardProcessingConfigurationInformation.new |
| 83 | + configurations2 = CyberSource::CardProcessingConfig.new |
| 84 | + common = CyberSource::CardProcessingConfigCommon.new |
| 85 | + common.merchant_category_code = "1234" |
| 86 | + |
| 87 | + merchant_descriptor_information = CyberSource::CardProcessingConfigCommonMerchantDescriptorInformation.new |
| 88 | + merchant_descriptor_information.name = "r4ef" |
| 89 | + merchant_descriptor_information.city = "Bellevue" |
| 90 | + merchant_descriptor_information.country = "US" |
| 91 | + merchant_descriptor_information.phone = "4255547845" |
| 92 | + merchant_descriptor_information.state = "WA" |
| 93 | + merchant_descriptor_information.street = "StreetName" |
| 94 | + merchant_descriptor_information.zip = "98007" |
| 95 | + common.merchant_descriptor_information = merchant_descriptor_information |
| 96 | + |
| 97 | + processors = {} |
| 98 | + processors['tsys'] = CyberSource::CardProcessingConfigCommonProcessors.new( |
| 99 | + merchant_id: "123456789101", |
| 100 | + terminal_id: "1231", |
| 101 | + industry_code: "D", |
| 102 | + vital_number: "71234567", |
| 103 | + merchant_bin_number: "123456", |
| 104 | + merchant_location_number: "00001", |
| 105 | + store_id: "1234", |
| 106 | + settlement_currency: "USD" |
| 107 | + ) |
| 108 | + common.processors = processors |
| 109 | + configurations2.common = common |
| 110 | + |
| 111 | + features2 = CyberSource::CardProcessingConfigFeatures.new |
| 112 | + card_not_present = CyberSource::CardProcessingConfigFeaturesCardNotPresent.new |
| 113 | + card_not_present.visa_straight_through_processing_only = true |
| 114 | + features2.card_not_present = card_not_present |
| 115 | + configurations2.features = features2 |
| 116 | + configuration_information2.configurations = configurations2 |
| 117 | + card_processing.configuration_information = configuration_information2 |
| 118 | + payments.card_processing = card_processing |
| 119 | + |
| 120 | + # Setup other payment-related products |
| 121 | + virtual_terminal = CyberSource::PaymentsProductsVirtualTerminal.new |
| 122 | + subscription_information3 = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 123 | + subscription_information3.enabled = true |
| 124 | + virtual_terminal.subscription_information = subscription_information3 |
| 125 | + payments.virtual_terminal = virtual_terminal |
| 126 | + |
| 127 | + customer_invoicing = CyberSource::PaymentsProductsTax.new |
| 128 | + subscription_information4 = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 129 | + subscription_information4.enabled = true |
| 130 | + customer_invoicing.subscription_information = subscription_information4 |
| 131 | + payments.customer_invoicing = customer_invoicing |
| 132 | + |
| 133 | + payouts = CyberSource::PaymentsProductsPayouts.new |
| 134 | + subscription_information5 = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 135 | + subscription_information5.enabled = true |
| 136 | + payouts.subscription_information = subscription_information5 |
| 137 | + payments.payouts = payouts |
| 138 | + |
| 139 | + selected_products.payments = payments |
| 140 | + |
| 141 | + # Setup Commerce Solutions |
| 142 | + commerce_solutions = CyberSource::CommerceSolutionsProducts.new |
| 143 | + token_management = CyberSource::CommerceSolutionsProductsTokenManagement.new |
| 144 | + subscription_information6 = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 145 | + subscription_information6.enabled = true |
| 146 | + token_management.subscription_information = subscription_information6 |
| 147 | + commerce_solutions.token_management = token_management |
| 148 | + selected_products.commerce_solutions = commerce_solutions |
| 149 | + |
| 150 | + # Setup Risk Products |
| 151 | + risk = CyberSource::RiskProducts.new |
| 152 | + fraud_management_essentials = CyberSource::RiskProductsFraudManagementEssentials.new |
| 153 | + subscription_information7 = CyberSource::PaymentsProductsPayerAuthenticationSubscriptionInformation.new |
| 154 | + subscription_information7.enabled = true |
| 155 | + fraud_management_essentials.subscription_information = subscription_information7 |
| 156 | + |
| 157 | + configuration_information5 = CyberSource::RiskProductsFraudManagementEssentialsConfigurationInformation.new |
| 158 | + template_id = 'E4EDB280-9DAC-4698-9EB9-9434D40FF60C' |
| 159 | + configuration_information5.template_id = template_id |
| 160 | + fraud_management_essentials.configuration_information = configuration_information5 |
| 161 | + risk.fraud_management_essentials = fraud_management_essentials |
| 162 | + |
| 163 | + selected_products.risk = risk |
| 164 | + |
| 165 | + product_information.selected_products = selected_products |
| 166 | + req_obj.product_information = product_information |
| 167 | + |
| 168 | + config = MerchantBoardingConfiguration.new.merchantBoardingConfigProp() |
| 169 | + api_client = CyberSource::ApiClient.new |
| 170 | + api_instance = CyberSource::MerchantBoardingApi.new(api_client, config) |
| 171 | + |
| 172 | + data, status_code, headers = api_instance.post_registration(req_obj) |
| 173 | + |
| 174 | + puts data, status_code, headers |
| 175 | + write_log_audit(status_code) |
| 176 | + return data |
| 177 | + rescue StandardError => err |
| 178 | + write_log_audit(err.code) |
| 179 | + puts err.message |
| 180 | + end |
| 181 | + |
| 182 | + def write_log_audit(status) |
| 183 | + filename = ($0.split("/")).last.split(".")[0] |
| 184 | + puts "[Sample Code Testing] [#{filename}] #{status}" |
| 185 | + end |
| 186 | + |
| 187 | + if __FILE__ == $0 |
| 188 | + |
| 189 | + Create_registration.new.run() |
| 190 | + end |
| 191 | +end |
0 commit comments