Skip to content

Commit

Permalink
cleanup code and delete redundant files
Browse files Browse the repository at this point in the history
  • Loading branch information
adavidw committed Oct 11, 2017
1 parent ae24cea commit 20954c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 91 deletions.
30 changes: 0 additions & 30 deletions CustomerProfiles/create-customer-profile-from-a-transaction.rb

This file was deleted.

33 changes: 22 additions & 11 deletions CustomerProfiles/create-customer-profile-from-transaction.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'rubygems'
require 'yaml'
require 'authorizenet'
require 'securerandom'
require 'yaml'
require 'authorizenet'
require 'securerandom'

include AuthorizeNet::API

def create_customer_profile_from_a_transaction(transId = 2242762682)
def create_customer_profile_from_a_transaction(transId = 60031516226)
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")

transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
Expand All @@ -14,20 +14,31 @@ def create_customer_profile_from_a_transaction(transId = 2242762682)
request = CreateCustomerProfileFromTransactionRequest.new
request.transId = transId

#You can either specify the customer information in form of customerProfileBaseType object
request.customer = CustomerProfileBaseType.new
request.customer.merchantCustomerId = "1231232"
# You can either specify the customer information to create a new customer profile
# or, specify an existing customer profile ID to create a new customer payment profile
# attached to the existing customer profile. If no profile information is specified,
# a new profile will still be created as long as either an ID or email exists in the
# original transaction that can be used to identify a new profile.
#
# To create a new customer profile containing a payment profile with this transaction's
# payment information, submit the new profile information in the form of a
# customerProfileBaseType object
request.customer = CustomerProfileBaseType.new
request.customer.merchantCustomerId = "1231232"
request.customer.description = "This is a sample customer profile"
request.customer.email = "[email protected]"
# OR
# You can just provide the customer Profile ID
# customerProfileId = "123343"
# -OR- to create a payment profile under an existing customer profile,
# just provide the customer Profile ID
# customerProfileId = "123343"

response = transaction.create_customer_profile_from_transaction(request)


if response.messages.resultCode == MessageTypeEnum::Ok
puts "Successfully created a customer profile from the transaction id #{response.customerProfileId}"
puts "Successfully created a customer profile from transaction ID #{transId}"
puts "Customer profile ID: #{response.customerProfileId}"
puts "New customer payment profile ID: #{response.customerPaymentProfileIdList.numericString[0]}"
puts "New customer shipping profile ID (if created): #{response.customerShippingAddressIdList.numericString[0]}"
else
puts response.messages.messages[0].text
raise "Failed to create a customer profile from an existing transaction."
Expand Down
50 changes: 0 additions & 50 deletions CustomerProfiles/create-customer-profile-with-accept.rb

This file was deleted.

0 comments on commit 20954c0

Please sign in to comment.