Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name cannot begin with the '0' character, hexadecimal value 0x30. #57

Closed
deep12650 opened this issue Jul 6, 2015 · 2 comments
Closed

Comments

@deep12650
Copy link

Hello Team,

I am facing this issue and am not able to fix it. can you guys please suggest me why is it showing error. This code creates Customer profile ID, Payment Profile ID and saving address successfully but when i make transaction it give error. Please help me. Thanks

My Code:

   $customerProfile = new AuthorizeNetCustomer;
   $customerProfile->description = "Description of customer";
   $customerProfile->merchantCustomerId = $user->id;
   $customerProfile->email = $user->email;
   $address = new AuthorizeNetAddress;
   $address->firstName = "john";
   $address->lastName = "Doe";
   $address->phoneNumber = "555-555-5555";
   $customerProfile->shipToList[] = $address;

   $paymentProfile = new AuthorizeNetPaymentProfile;
   $paymentProfile->customerType = "individual";
   $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
   $paymentProfile->payment->creditCard->expirationDate = "2017-10";
   $customerProfile->paymentProfiles[] = $paymentProfile;

   $request = new AuthorizeNetCIM;
   $response = $request->createCustomerProfile($customerProfile);
   $new_customer_id = $response->xml->customerProfileId;
   $paymentProfileId = $response->xml->customerPaymentProfileIdList->numericString;
   $customerAddressId = $response->xml->customerShippingAddressIdList->numericString;

   $transaction = new AuthorizeNetTransaction;
   $transaction->amount = "9.79";
   $transaction->customerProfileId = $new_customer_id;
   $transaction->customerPaymentProfileId = $paymentProfileId;
   $transaction->customerShippingAddressId = $customerAddressId;

   $transaction->cardCode = "111";
   $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction);
   print_r($response); 

Error -

[code] => E00003
[text] => Name cannot begin with the '0' character, hexadecimal value 0x30. Line 2, position 291.

@TrevorW
Copy link
Contributor

TrevorW commented Jul 6, 2015

The problem here is the way that values are returned out of a simpleXML element. Reading a parameter such as "$response->xml->customerProfileId" still returns a simpleXML element by default, but the $transaction->customerProfileId is looking for a string.

The resolution to this is simply to cast these particular XML elements as strings. You could do this either when reading them from the XML or when entering them into the transaction object. Personally, I would recommend doing it when you read them out of the XML. It would just be a simple change as shown in the three lines below:

 $new_customer_id = (string) $response->xml->customerProfileId;
 $paymentProfileId = (string) $response->xml->customerPaymentProfileIdList->numericString;
 $customerAddressId = (string) $response->xml->customerShippingAddressIdList->numericString;

@brianmc
Copy link
Contributor

brianmc commented Oct 16, 2015

Closing this one as no additional response.

@brianmc brianmc closed this as completed Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants