Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Help in automate the process of Magento Checkout using Paypal-direct as payment method
 
prajeesh19861
Jr. Member
 
Total Posts:  9
Joined:  2010-01-27
 

Hi

I am trying to automate the checkout process from a store using magento. I had used the payment method as “check/money”. And it is working fine . But my ultimate goal is to checkout using payapl-direct payment method. I am attaching my automation code for the checkout process

<?php
require_once("C:/wamp/www/magento/app/Mage.php");
umask(0);
Mage::app();

$email ="test5@gmail.com";
$password ="qburst";
$customer Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($email);
 try 
{
if(!$customer->getId()) {
 
    $customer
->setEmail($email);
    
$customer->setFirstname('Milo');
    
$customer->setLastname('Devan');
    
$customer->setPassword($password);

 
   
    
//$customer->save();
    
$customer->setConfirmation($password);
    
$customer->save();
    
}
    Mage
::getSingleton('core/session', array('name'=>'frontend'));
            
$session Mage::getSingleton('customer/session');
$session->login($email,$password);
$session->setCustomerAsLoggedIn($session->getCustomer());
    
//Make a "login" of new customer
    //Mage::getSingleton('customer/session')->loginById($customer->getId());
    
header ("Location:http://localhost/magento/index.php/customer/account");
}
 
catch (Exception $ex{
    Zend_Debug
::dump($ex->getMessage());
}
//var_dump($session);
/* Send user to Mage HOME */

$_custom_address = array (
    
'firstname' => 'chachan',
    
'lastname' => 'vilun',
    
'street' => array (
        
'0' => 'Sample address part1',
        
'1' => 'Sample address part2',
    ),
 
    
'city' => 'Osijek',
    
'region_id' => '12',
    
'region' => 'California',
    
'postcode' => '93120',
    
'country_id' => 'US'/*USA */
    
'telephone' => '9999999999',
);
 
$customAddress Mage::getModel('customer/address');
//$customAddress = new Mage_Customer_Model_Address();
$customAddress->setData($_custom_address)
            ->
setCustomerId($customer->getId())
            ->
setIsDefaultBilling('1')
            ->
setIsDefaultShipping('1')
            ->
setSaveInAddressBook('1');
 
try 
{
    $customAddress
->save();
}
catch (Exception $ex{
    
//Zend_Debug::dump($ex->getMessage());
}
 
Mage
::getSingleton('checkout/session')->getQuote()->setBillingAddress(Mage::getSingleton('sales/quote_address')->importCustomerAddress($customAddress));



$product Mage::getModel('catalog/product')->getCollection()
    
/* Remember, you can load/find product via any attribute, better if its attribute with unique value */
    
->addAttributeToFilter('sku''slam1')
    ->
addAttributeToSelect('*')
    ->
getFirstItem();
 
/* Do a full product load, otherwise you might get some errors related to stock item */
$product->load($product->getId());
 
$cart Mage::getSingleton('checkout/cart');

/* We want to add only the product/products for this user and do so programmatically, so lets clear cart before we start adding the products into it */
/*$cart->truncate();
$cart->save();
$cart->getItems()->clear()->save();    */        
 
try {
    
/* Add product with custom oprion? =>  some-custom-option-id-here: value to be read from database or assigned manually, hardcoded? Just example*/
    
$cart->addProduct($product, array('options'=> array('sku' => 'gift2')));
    
$cart->save();                
}
catch (Exception $ex{
    
echo $ex->getMessage();
}
 
unset($product);


$storeId Mage::app()->getStore()->getId();
 
$checkout Mage::getSingleton('checkout/type_onepage');
 
$checkout->initCheckout();
 
$checkout->saveCheckoutMethod('register');
 
$checkout->saveShippingMethod('fedex_FEDEX2DAY');
 
$checkout->savePayment(array('method'=>'checkmo'));
 
try 
{
    $checkout
->saveOrder();
}
catch (Exception $ex{
    
//echo $ex->getMessage();
}            
 
/* Clear the cart */
$cart->truncate();
$cart->save();
$cart->getItems()->clear()->save();

So I am using sandbox account with paypal-direct checkout.But when I add my code for paypal checkout it is not working

Following are the code snippet that I used for paypal -direct checkout

$checkout->savePayment(array("method"=>"paypal_direct","cc_type"=>"VI","cc_number"=>"4485362859528762","cc_exp_month"=>"6","cc_exp_year"=>"2011","cc_cid"=>"528"));

Please help me in this process

File Attachments
mage_login_1.php  (File Size: 4KB - Downloads: 107)
 
Magento Community Magento Community
Magento Community
Magento Community
 
potro
Jr. Member
 
Total Posts:  8
Joined:  2008-09-25
 

I have the same problem to set the Autorize.Net payment. I use:

$checkout->savePayment(array("method"=>"authorizenet”,"cc_type"=>"VI”,"cc_number"=>"4485362859528762”,"cc_exp_month"=>"6”,"cc_exp_year"=>"2011”,"cc_cid"=>"528"));

but it doesn’t work.

Please help!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
potro
Jr. Member
 
Total Posts:  8
Joined:  2008-09-25
 

I have the same problem to set the Autorize.Net payment. I use:

$checkout->savePayment(array("method"=>"authorizenet”,"cc_type"=>"VI”,"cc_number"=>"4485362859528762”,"cc_exp_month"=>"6”,"cc_exp_year"=>"2011”,"cc_cid"=>"528"));

but it doesn’t work.

It’s my second post and none answered yet. Please guys I need your help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sudhirsoft01
Jr. Member
 
Total Posts:  3
Joined:  2011-02-05
 

Hello prajeesh,

I have same issue . Did you get the solution yet ?

Please help i am ready to pay for the solutions.

Skype : techphpexpert
email :

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top