From e722dcd187f9715a54f61e018957a35670da22af Mon Sep 17 00:00:00 2001 From: gnongsie Date: Tue, 23 Jul 2024 23:23:30 +0530 Subject: [PATCH 1/3] Modifications to keep up to date --- .../create-customer-payment-profile.rb | 2 +- Gemfile | 2 +- ...eate-subscription-from-customer-profile.rb | 8 +- spec/sample_code_spec.rb | 234 +++++++++--------- 4 files changed, 123 insertions(+), 123 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.rb b/CustomerProfiles/create-customer-payment-profile.rb index fd70404..eaed9f1 100644 --- a/CustomerProfiles/create-customer-payment-profile.rb +++ b/CustomerProfiles/create-customer-payment-profile.rb @@ -12,7 +12,7 @@ def create_customer_payment_profile(customerProfileId = '1813343337') # Build the payment object payment = PaymentType.new(CreditCardType.new) payment.creditCard.cardNumber = '4111111111111111' - payment.creditCard.expirationDate = '2022-05' + payment.creditCard.expirationDate = '2045-05' # Build an address object billTo = CustomerAddressType.new diff --git a/Gemfile b/Gemfile index 6c8e19c..429e415 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source 'https://rubygems.org' gem "rspec" , '~> 3.9.0' gem "rake" , '~> 12.3', '>= 12.3.3' -gem "authorizenet" , '~> 1.9.7' +gem "authorizenet" , '> 1.9.7' diff --git a/RecurringBilling/create-subscription-from-customer-profile.rb b/RecurringBilling/create-subscription-from-customer-profile.rb index e9bfb90..48ccbd5 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.rb +++ b/RecurringBilling/create-subscription-from-customer-profile.rb @@ -25,13 +25,13 @@ def create_subscription_from_customer_profile(profileId = "123213", paymentProfi request.subscription.amount = random_amount request.subscription.trialAmount = 0.00 - request.subscription.profile = CustomerProfileIdType.new - request.subscription.profile.customerProfileId = profileId + request.subscription.profile = CustomerProfileIdType.new + request.subscription.profile.customerProfileId = profileId request.subscription.profile.customerPaymentProfileId = paymentProfileId request.subscription.profile.customerAddressId = addressId - + response = transaction.create_subscription(request) - + if response != nil if response.messages.resultCode == MessageTypeEnum::Ok puts "Successfully created a subscription with ID #{response.subscriptionId}." diff --git a/spec/sample_code_spec.rb b/spec/sample_code_spec.rb index 3129552..2c6d74d 100644 --- a/spec/sample_code_spec.rb +++ b/spec/sample_code_spec.rb @@ -14,13 +14,13 @@ include AuthorizeNet::API describe "SampleCode Testing" do - + before :all do begin Dir.glob(dirpath + "**/*.rb") do |item| # note one extra "*" next if item == '.' or item == '..' item = item[0..-4] - + if item != specpath + 'sample_code_spec' puts "working on: #{item}" require item @@ -49,235 +49,235 @@ def validate_response(response= nil) expect(response.messages.resultCode).not_to eq(nil) expect(response.messages.resultCode).to eq(MessageTypeEnum::Ok) end - + it "should be able to run all Customer Profile sample code" do puts "START - Customer Profiles" - + response = create_customer_profile() validate_response(response) customerProfileId = response.customerProfileId - + response = create_customer_payment_profile(customerProfileId) validate_response(response) customerPaymentProfileId = response.customerPaymentProfileId - + response = create_customer_shipping_address(customerProfileId) validate_response(response) customerAddressId = response.customerAddressId - #response = validate_customer_payment_profile(customerProfileId, customerPaymentProfileId) - #validate_response(response) - -# create_transaction_for_profile = authorize_credit_card() -# validate_response(response) -# response = create_customer_profile_from_a_transaction(create_transaction_for_profile.transactionResponse.transId) -# validate_response(response) - + # response = validate_customer_payment_profile(customerProfileId, customerPaymentProfileId) + # validate_response(response) + + # create_transaction_for_profile = authorize_credit_card() + # validate_response(response) + # response = create_customer_profile_from_a_transaction(create_transaction_for_profile.transactionResponse.transId) + # validate_response(response) + response = get_customer_payment_profile(customerProfileId, customerPaymentProfileId) validate_response(response) - + response = get_customer_payment_profile_list() validate_response(response) - + response = get_customer_profile(customerProfileId) validate_response(response) - + response = get_customer_profile_ids() validate_response(response) - + response = get_customer_shipping_address(customerProfileId, customerAddressId) validate_response(response) - + response = get_accept_customer_profile_page(customerProfileId) validate_response(response) - + response = update_customer_payment_profile(customerProfileId, customerPaymentProfileId) validate_response(response) - + response = update_customer_profile(customerProfileId) validate_response(response) - + response = update_customer_shipping_address(customerProfileId, customerAddressId) validate_response(response) response = delete_customer_shipping_address(customerProfileId, customerAddressId) validate_response(response) - + response = delete_customer_payment_profile(customerProfileId, customerPaymentProfileId) validate_response(response) response = delete_customer_profile(customerProfileId) validate_response(response) - + end - + it "should be able to run all Recurring Billing sample code" do puts "START - Recurring Billing" - + response = create_Subscription() validate_response(response) subscriptionId = response.subscriptionId - - #Create subscription from customer profile - profile_response = create_customer_profile() - payment_response = create_customer_payment_profile(profile_response.customerProfileId) - shipping_response = create_customer_shipping_address(profile_response.customerProfileId) - - #waiting for creating customer profile. + + # Create subscription from customer profile + profile_response = create_customer_profile() + payment_response = create_customer_payment_profile(profile_response.customerProfileId) + shipping_response = create_customer_shipping_address(profile_response.customerProfileId) + + # waiting for creating customer profile. puts "Waiting for creation of customer profile..." sleep 50 puts "Proceeding" - - response = create_subscription_from_customer_profile(profile_response.customerProfileId, payment_response.customerPaymentProfileId, shipping_response.customerAddressId) - validate_response(response) - - cancel_subscription(response.subscriptionId) - delete_customer_profile(profile_response.customerProfileId) - - #End of create subscription from customer profile - + + response = create_subscription_from_customer_profile(profile_response.customerProfileId, payment_response.customerPaymentProfileId, shipping_response.customerAddressId) + validate_response(response) + + cancel_subscription(response.subscriptionId) + delete_customer_profile(profile_response.customerProfileId) + + # End of create subscription from customer profile + response = get_subscription(subscriptionId) validate_response(response) - + response = get_list_of_subscriptions() validate_response(response) - + response = get_subscription_status(subscriptionId) validate_response(response) - + response = update_subscription(subscriptionId) validate_response(response) - + response = cancel_subscription(subscriptionId) validate_response(response) - + end - - + + it "should be able to run all Payment Transaction sample code" do puts "START - Payment Transactions" response = authorize_credit_card() validate_response(response) - + response = capture_funds_authorized_through_another_channel() validate_response(response) - -# response = capture_only() -# validate_response(response) - + + # response = capture_only() + # validate_response(response) + response = capture_funds_authorized_through_another_channel() validate_response(response) - + response = capture_previously_authorized_amount() validate_response(response) - + response = charge_credit_card() validate_response(response) - - #create customer profile + + # create customer profile response = create_customer_profile() validate_response(response) customerProfileId = response.customerProfileId - - #create customer payment profile + + # create customer payment profile response = create_customer_payment_profile(customerProfileId) validate_response(response) customerPaymentProfileId = response.customerPaymentProfileId - + response = charge_customer_profile(customerProfileId, customerPaymentProfileId) validate_response(response) - + response = charge_tokenized_credit_card() validate_response(response) - + response = credit_bank_account() validate_response(response) - + response = debit_bank_account() validate_response(response) - -# response = refund_transaction() -# validate_response(response) - + + # response = refund_transaction() + # validate_response(response) + response = update_split_tender_group() validate_response(response) - + response = void_transaction() validate_response(response) end - - + + it "should be able to run all PayPal Express Checkout sample code" do puts "START - PayPal Express Checkout" - + puts "TEST - authorization and capture" response = authorization_and_capture() validate_response(response) -# response = authorization_and_capture_continued() -# validate_response(response) - + # response = authorization_and_capture_continued() + # validate_response(response) + puts "TEST - authorization only" response = authorization_only() validate_response(response) authTransId = response.transactionResponse.transId puts "TransId to be used for AuthOnlyContinued, GetDetails & Void : #{authTransId}" - + puts "TEST - authorization only continued" response = authorization_only_continued(authTransId) validate_response(response) - -# response = credit() -# validate_response(response) - + + # response = credit() + # validate_response(response) + puts "TEST - Get Details" response = get_details(authTransId) validate_response(response) - + puts "TEST - prior authorization and capture" response = prior_authorization_capture() validate_response(response) - -# puts "TEST - Void" -# authTransId = get_transId() -# response = void(authTransId) -# validate_response(response) - + + # puts "TEST - Void" + # authTransId = get_transId() + # response = void(authTransId) + # validate_response(response) + end - + it "should be able to run all Transaction Reporting sample code" do puts "START - Transaction Reporting" - + response = get_settled_batch_List() validate_response(response) - - #Start Get Batch Statistics - batchId = response.batchList.batch[0].batchId - - response = get_batch_Statistics(batchId) + + # Start Get Batch Statistics + batchId = response.batchList.batch[0].batchId + + response = get_batch_Statistics(batchId) validate_response(response) - #End Get Batch Statistics - + # End Get Batch Statistics + response = get_transaction_Details() validate_response(response) - + response = get_transaction_List() validate_response(response) - + response = get_unsettled_transaction_List() validate_response(response) - + response = get_Transaction_List_For_Customer() validate_response(response) - + end - + it "should be able to run Merchant Details sample code" do puts "START - Transaction Reporting / Merchant Details" - + response = get_merchant_details() validate_response(response) @@ -286,26 +286,26 @@ def validate_response(response= nil) it "should be able to run all Visa Checkout sample code" do puts "START - Visa Checkout" - -# response = create_visa_src_transaction() -# validate_response(response) - - response = decrypt_visa_src_data() - validate_response(response) - + + # response = create_visa_src_transaction() + # validate_response(response) + + # response = decrypt_visa_src_data() + # validate_response(response) + end - + it "should be able to run all Apple Pay sample code" do -# response = create_an_apple_pay_transaction() -# validate_response(response) -# + # response = create_an_apple_pay_transaction() + # validate_response(response) + end it "should be able to run Update Held Transaction sample code" do - #response = update_held_transaction("12345") - #validate_response(response) + # response = update_held_transaction("12345") + # validate_response(response) end @@ -315,6 +315,6 @@ def validate_response(response= nil) validate_response(response) end - - + + end From be3209f1ca9a34828bbcaad844bdc844b1bbb76a Mon Sep 17 00:00:00 2001 From: gnongsie Date: Wed, 24 Jul 2024 11:18:42 +0530 Subject: [PATCH 2/3] Randomized names --- CustomerProfiles/create-customer-payment-profile.rb | 8 ++++---- CustomerProfiles/create-customer-shipping-address.rb | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CustomerProfiles/create-customer-payment-profile.rb b/CustomerProfiles/create-customer-payment-profile.rb index eaed9f1..54904d0 100644 --- a/CustomerProfiles/create-customer-payment-profile.rb +++ b/CustomerProfiles/create-customer-payment-profile.rb @@ -16,8 +16,8 @@ def create_customer_payment_profile(customerProfileId = '1813343337') # Build an address object billTo = CustomerAddressType.new - billTo.firstName = "Jerry" - billTo.lastName = "Johnson" + billTo.firstName = "Jerry" + (0...8).map { (65 + rand(26)).chr }.join + billTo.lastName = "Johnson" + (0...8).map { (65 + rand(26)).chr }.join billTo.company = "Souveniropolis" billTo.address = "14 Main Street" billTo.city = "Pecan Springs" @@ -38,7 +38,7 @@ def create_customer_payment_profile(customerProfileId = '1813343337') request = CreateCustomerPaymentProfileRequest.new request.paymentProfile = paymentProfile request.customerProfileId = customerProfileId - request.validationMode = ValidationModeEnum::LiveMode + request.validationMode = ValidationModeEnum::LiveMode response = transaction.create_customer_payment_profile(request) @@ -46,7 +46,7 @@ def create_customer_payment_profile(customerProfileId = '1813343337') if response.messages.resultCode == MessageTypeEnum::Ok puts "Successfully created a customer payment profile with id: #{response.customerPaymentProfileId}." else - puts response.messages.messages[0].code + puts response.messages.messages[0].code puts response.messages.messages[0].text puts "Failed to create a new customer payment profile." end diff --git a/CustomerProfiles/create-customer-shipping-address.rb b/CustomerProfiles/create-customer-shipping-address.rb index 0a45e36..fe8287b 100644 --- a/CustomerProfiles/create-customer-shipping-address.rb +++ b/CustomerProfiles/create-customer-shipping-address.rb @@ -10,18 +10,17 @@ def create_customer_shipping_address(customerProfileId = '1813343337') transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox) - + request = CreateCustomerShippingAddressRequest.new - + request.address = CustomerAddressType.new('John','Doe') request.customerProfileId = customerProfileId response = transaction.create_customer_shipping_profile(request) - if response.messages.resultCode == MessageTypeEnum::Ok puts "Successfully created a customer shipping address with id: #{response.customerAddressId}." else - puts "Failed to create a new customer shipping address: #{response.messages.messages[0].text}" + puts "Failed to create a new customer shipping address: #{response.messages.messages[0].text}" end return response end From ed4db9c0fc8efe96936f6550d8b5a09eaa90b87b Mon Sep 17 00:00:00 2001 From: gnongsie Date: Mon, 2 Sep 2024 19:44:58 +0530 Subject: [PATCH 3/3] Reverted comments --- spec/sample_code_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/sample_code_spec.rb b/spec/sample_code_spec.rb index 2c6d74d..7326e0b 100644 --- a/spec/sample_code_spec.rb +++ b/spec/sample_code_spec.rb @@ -65,13 +65,13 @@ def validate_response(response= nil) validate_response(response) customerAddressId = response.customerAddressId - # response = validate_customer_payment_profile(customerProfileId, customerPaymentProfileId) - # validate_response(response) + response = validate_customer_payment_profile(customerProfileId, customerPaymentProfileId) + validate_response(response) - # create_transaction_for_profile = authorize_credit_card() - # validate_response(response) - # response = create_customer_profile_from_a_transaction(create_transaction_for_profile.transactionResponse.transId) - # validate_response(response) + create_transaction_for_profile = authorize_credit_card() + validate_response(response) + response = create_customer_profile_from_a_transaction(create_transaction_for_profile.transactionResponse.transId) + validate_response(response) response = get_customer_payment_profile(customerProfileId, customerPaymentProfileId) validate_response(response)