Magento API - Guest Customer Email not being set? 

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

 

I’m using the Magento API from a remote website to create the order. Later I want to integrate the payment routine as well, but for now I just need the order process to work correctly.

Everything works as expected, EXCEPT:

When creating the order with the customer mode set to “guest”, even though I’m passing the email address via the API, it does not set the customer email address. When reviewing the order, I noted this in the “Account Information” block (top right). Thus the order notification email does not go out either, nor do any other emails. If you do not set a customer email address, the order is created with the customer name “Guest” and no email address is displayed, even if you provide the first name and last name. If you do set a customer email address, then the order is created with the customer name as supplied, but no email address.

I’ve tried setting the email address under billing address and shipping address, but that doesn’t help at all.

Here’s how the API query looks:

$shoppingCartId $xmlrpc->call("call", array($session'cart.create', array($store)));
    
    
$customerAsGuest = array(
        
"firstname" => "Bob",
        
"lastname" => "Hope",
        
"email" => "myemail@gmail.com",
        
"website_id" => "1",
        
"store_id" => "1",
        
"mode" => "guest"
    
);
    
$resultCustomerSet $xmlrpc->call("call", array($session'cart_customer.set', array( $shoppingCartId$customerAsGuest$store)));

Using Magento 1.5.1.0. I hope somebody can shed some light on this ‘cuz I’ve been banging my head against this one for two days, and I’m not the only 1 either!

Thanks

 

BUMP. No takers? Surely others have come across the same problem…

 

Ok, well here’s another one for you:

Via the API I set the payment method to “authorizenet” and pass the credit card number, CVV & expiry. I receive a “true” response so all ok so far.

When I try to create the order though, I get a “Credit Card number mismatch with credit card type”. Further investigation reveals that the credit card number doesn’t appear to be set at all when the order is created. So I’m lost.

The API is driving me totally nuts! All it’s good for that I can tell so far is maybe some reporting, but functionality (and documentation) is truly pathetic as far as I’m concerned, until somebody can prove otherwise to me.

Any takers on this problem?

 

Since apparently nobody knows how to do this, I thought I’d reply as to how I worked around it for anyone who’se still suffering with this like I did.

I basically resorted to extending the Magento API via a custom module, to which I send via the API the payment information and credit card details. My module then sets the payment details and tells Magento to process the order.

This method allows me to have a single Magento store set up and dozens of “mini-stores” or “mini shopping carts” all over the net which communicate to that single store, allowing me to build niche sites fast without having to manage dozens of Magento installs.

Note that I’m sending this data via Curl over SSL for security, and realise of course that using this method you’re literally sending someone else’s credit card details over the net, so make sure you’ve got decent security set up. Since I’m sending the data over SSL to the API, I feel that it’s exactly the same thing as him submitting it from the Magento checkout page (which is protected by SSL in exactly the same way), so I reckon that this is therefore adequately secure. I also add an SSL certificate to the mini-sites’ checkout pages.

As for the guest customer email issue, I resorted to forcing the customer to register (without him realising he’s doing so). I could not get around it any other way. I’m still interested to hear if anyone knows how to correct this or where I went wrong, if I did.

 

same problem, did you find a solution?

 

As for: http://www.magentocommerce.com/boards/viewthread/262680/
Worked for me.

1. Create directory /app/code/local/Mage/Checkout/Model/Api/Resource

2. Copy /app/code/core/Mage/Checkout/Model/Api/Resource/Customer.php in the new directory

3. Open /app/code/local/Mage/Checkout/Model/Api/Resource/Customer.php

Find:

protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
    
{
        $quote
->setCustomerId(null)
            ->
setCustomerEmail($quote->getBillingAddress()->getEmail())
            ->
setCustomerIsGuest(true)
            ->
setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
        return 
$this;
    
}

Substitute with:

protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
    
{    
        $quote
->setCustomerId(null)
            ->
setCustomerEmail($quote->getCustomerEmail())
            ->
setCustomerIsGuest(true)
            ->
setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
        return 
$this;
    
}

 

The problem is… Magento does not save information on guests.
If you want to allow guest checkout with credit card, you have to do custom modifications… to at least store temporarily.
If you do store guest info… make sure you set up a cron job to delete the info every 30 days or so… since you don’t have their permission to hold onto their information.

 
RuggeroSB - 01 July 2011 01:16 AM

As for the guest customer email issue, I resorted to forcing the customer to register (without him realising he’s doing so). I could not get around it any other way. I’m still interested to hear if anyone knows how to correct this or where I went wrong, if I did.

This is something I would like to incorporate.
So how did you go about it?

`Reply Or Comment!
Please LogIn to Reply!