cancel
Showing results for 
Search instead for 
Did you mean: 

Create Shipping Address in CIM, C#

Hi,

 

I would like to create a new customer profile, which includes the customer's shipping address. Do you have code that I can use? I can create the profile and add the billing info, however, I don't know how to add the shipping info:

 

 

 public static long CreateCustomerPaymentProfile(long profile_id){
         CustomerProfileWS.CustomerPaymentProfileType new_payment_profile = new CustomerProfileWS.CustomerPaymentProfileType();
         CustomerProfileWS.PaymentType new_payment = new CustomerProfileWS.PaymentType();
         
         //BankAccountType new_bank = new BankAccountType();
         //new_bank.accountNumber = "4111111";

         CustomerProfileWS.CreditCardType new_card = new CustomerProfileWS.CreditCardType();
         new_card.cardNumber = "4111111111111111";
         new_card.expirationDate = "2010-10";         
         new_payment.Item = new_card;
         //new_payment.Item = new_bank;
         new_payment_profile.billTo = new CustomerAddressType();
         new_payment_profile.billTo.address = "1155 Maple St.";
         new_payment_profile.payment = new_payment;
         //ArrayOfCustomerPaymentProfileType pay_list = new ArrayOfCustomerPaymentProfileType();
         //pay_list.getCustomerPaymentProfileType().add(new_payment_profile);
      
         CustomerProfileWS.CreateCustomerPaymentProfileResponseType response = SoapAPIUtilities.Service.CreateCustomerPaymentProfile(SoapAPIUtilities.MerchantAuthentication, profile_id, new_payment_profile, CustomerProfileWS.ValidationModeEnum.testMode);

         long out_id = 0;
         Console.WriteLine("Response Code: " + response.resultCode);
         for(int i = 0; i < response.messages.Length; i++){
            Console.WriteLine("Message: " + response.messages[i].text);
         }

         out_id = response.customerPaymentProfileId;

         return out_id;
      }

 

 

joe_a84
Member
4 REPLIES 4

You can either add it when you create the customer profile or call the createcustomershippingaddress methods.

 

 

public static long CreateCustomerProfile()
{
            CustomerProfileWS.CustomerProfileType m_new_cust = new CustomerProfileWS.CustomerProfileType();
            m_new_cust.email = "fake@example.com";
            m_new_cust.description = "Example customer " + DateTime.Now.ToShortTimeString();
            m_new_cust.merchantCustomerId = "1001";

            m_new_cust.shipToList = new CustomerProfileAPI.CustomerProfileWS.CustomerAddressType[1];
            m_new_cust.shipToList[0] = new CustomerProfileAPI.CustomerProfileWS.CustomerAddressType();
            m_new_cust.shipToList[0].firstName = "Bob";
            m_new_cust.shipToList[0].lastName = "Smith";
            m_new_cust.shipToList[0].company = "ABC";
            m_new_cust.shipToList[0].address = "123 Monday way";
            m_new_cust.shipToList[0].city = "Chicago";
            m_new_cust.shipToList[0].state = "IL";
            m_new_cust.shipToList[0].zip = "60606";
            m_new_cust.shipToList[0].country = "us";
            m_new_cust.shipToList[0].phoneNumber = "4255555555";
            m_new_cust.shipToList[0].faxNumber = "4255555555";

            CustomerProfileWS.CreateCustomerProfileResponseType response = SoapAPIUtilities.Service.CreateCustomerProfile(SoapAPIUtilities.MerchantAuthentication, m_new_cust, CustomerProfileAPI.CustomerProfileWS.ValidationModeEnum.none);

            return response.customerProfileId;

}

 

 

 

 

public static long CreateCustomerShippingAddress(long profile_id)
        {
            CustomerProfileWS.CustomerAddressType new_shipping_profile = new CustomerProfileAPI.CustomerProfileWS.CustomerAddressType();

            new_shipping_profile.firstName = "Bob";
            new_shipping_profile.lastName = "Smith";
            new_shipping_profile.company = "Authorize.net";
            new_shipping_profile.address = "123 Weekend way";
            new_shipping_profile.city = "Chicago";
            new_shipping_profile.state = "IL";
            new_shipping_profile.zip = "60606";
            new_shipping_profile.country = "us";
            new_shipping_profile.phoneNumber = "4255555555";
            new_shipping_profile.faxNumber = "4255555555";

            CustomerProfileWS.CreateCustomerShippingAddressResponseType response = SoapAPIUtilities.Service.CreateCustomerShippingAddress(SoapAPIUtilities.MerchantAuthentication, profile_id, new_shipping_profile);

            return response.customerAddressId;
        }

RaynorC1emen7
Expert

Hi

 

I'm  using cim approach and my test account in live mode and I'm passing shipping address id while authorizing an order but didn't get shipping address in email notification and transaction details,

Shipping address  is showing only on CIM ->customer profile area.

 

So suggest me steps through that I can see  shipping address in shipping information area.  

 

 

========= SECURITY STATEMENT ==========
It is not recommended that you ship product(s) or otherwise grant services relying solely upon this e-mail receipt.

========= GENERAL INFORMATION =========

Merchant : manish kumar (402325)

Date/Time : 8-Jun-2013 6:35:37 PDT

========= ORDER INFORMATION =========
Invoice : O13151_USAAL_1CD8F3
Description :
Amount : 300.00 (USD)

Payment Method : Visa
Type : Authorization Only

============== RESULTS ==============
Response : This transaction has been approved.

Authorization Code : CY36IU
Transaction ID : 2194226608

Address Verification : Street Address: Match -- First 5 Digits of Zip: Match

==== CUSTOMER BILLING INFORMATION ===
Customer ID :

First Name : Test
Last Name : Manuf
Company : TDC
Address : street1
City : alabama
State/Province : AL
Zip/Postal Code : 32442
Country : US
Phone : 8888888888
Fax :
E-Mail : manuf1@quivers.com

 
 

==== CUSTOMER SHIPPING INFORMATION ===
First Name :
Last Name :
Company :
Address :
City :
State/Province :
Zip/Postal Code :
Country :

======= ADDITIONAL INFORMATION ======
Tax :
Duty :
Freight :
Tax Exempt :
PO Number :

That method needs to be extended to include the "customerShippingAddressId" as the CIM documentation has it. However, the ID of the shipping address saved to CIM is not saved on the Spree side, just the profile ID and payment profile ID. Would probably need to save a "gateway_shipping_address_id" on some model like Spree::Creditcard has.

Rhys69
Member

Well here is the code:

class CustomerProfile:
def __init__(self, first_name, last_name, email, phone_number, shipping_address):
self.first_name = first_name
self.last_name = last_name
self.email = email
self.phone_number = phone_number
self.shipping_address = shipping_address

def display_profile(self):
return {
"First Name": self.first_name,
"Last Name": self.last_name,
"Email": self.email,
"Phone Number": self.phone_number,
"Shipping Address": self.shipping_address
}

class ShippingAddress:
def __init__(self, street, city, state, postal_code, country):
self.street = street
self.city = city
self.state = state
self.postal_code = postal_code
self.country = country

def __str__(self):
return f"{self.street}, {self.city}, {self.state}, {self.postal_code}, {self.country}"

# Example usage
shipping_address = ShippingAddress(
street="123 Main St",
city="Springfield",
state="IL",
postal_code="62701",
country="USA"
)

customer_profile = CustomerProfile(
first_name="John",
last_name="Doe",
email="johndoe@example.com",
phone_number="123-456-7890",
shipping_address=str(shipping_address)
)

# Display the customer profile
print(customer_profile.display_profile())

This code defines two classes: CustomerProfile and ShippingAddress. The CustomerProfile class stores information about the customer, including their shipping address, while the ShippingAddress class contains the details of the shipping address. The example usage demonstrates how to create an instance of a customer profile and display its details. You can modify the structure as needed for integration with databases or APIs.

bajiaqsa0
Member