-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup code and delete redundant files
- Loading branch information
Showing
3 changed files
with
22 additions
and
91 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
CustomerProfiles/create-customer-profile-from-a-transaction.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
@@ -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." | ||
|
This file was deleted.
Oops, something went wrong.