Jump to content

Manually verify each purchase for shipping


Recommended Posts

Hello!

I am in the process of setting up a shop for a distributor.

 

His situation is different in that he needs to be able to look over an order and add shipping manually.

 

Something like this

1. order is placed

2. owner is notified of new order

3. order is assessed and shipping is calculated

4. shipping added to order

5. customer notified

6. order paid.

 

Step 3 is the important part.

 

Is it possible to have the order set to a "on hold" state after submitting?

Link to comment
Share on other sites

a payment module will execute a function called validateOrder

So I have to make changes to the code? Is this straight forward? I've never done this? Will I need to redo the changes when I update?

Thanks for your help.

Link to comment
Share on other sites

I found this section of code in the Paypal module's validation.php file.

But I don't know what I need to do with it.

If you can help point me int he right direction I would be forever grateful!

 

$paypal->validateOrder((int)$cart_secure[0], Configuration::get('PS_OS_PAYMENT'), (float)($_POST['mc_gross']), $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id'], array('transaction_id' => $_POST['txn_id'], 'payment_status' => $_POST['payment_status']), NULL, false, $cart_secure[1]);
}
}
else
$errors .= $paypal->getL('verified');
// Set transaction details if pcc is defiend in PaymentModule class
if (isset($paypal->pcc))
{
$this->pcc->transaction_id = (isset($_POST['txn_id']) ? $_POST['txn_id'] : '');
}
if (!empty($errors) AND isset($_POST['custom']))
{
if (strtoupper($_POST['payment_status']) == 'PENDING')
 $paypal->validateOrder((int)$cart_secure[0], Configuration::get('PS_OS_PAYPAL'), (float)$_POST['mc_gross'], $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id'].'<br />'.$errors, array('transaction_id' => $_POST['txn_id'], 'payment_status' => $_POST['payment_status']), NULL, false, $cart_secure[1]);
else
 $paypal->validateOrder((int)$cart_secure[0], Configuration::get('PS_OS_ERROR'), 0, $paypal->displayName, $errors.'<br />', array(), NULL, false, $cart_secure[1]);
}

Link to comment
Share on other sites

k good. so you found 3 locations where validateOrder are executed. This is because the module checks if the payment is pending ('PS_OS_PAYMENT'), completed ('PS_OS_PAYPAL') or failed ('PS_OS_ERROR')

 

so first you need to create a new order status called "pending", or whatever you like to name it. you do this from the back office under the Orders | Statuses section.

 

Once created, you need to note what the status Id is. It will likely be 14, but you need to verify that.

Then you want to replace

Configuration::get('PS_OS_PAYPAL')

 

with

14

 

so it looks like

  $paypal->validateOrder((int)$cart_secure[0], 14, (float)$_POST['mc_gross'], $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id'].'<br />'.$errors, array('transaction_id' => $_POST['txn_id'], 'payment_status' => $_POST['payment_status']), NULL, false, $cart_secure[1]);

Link to comment
Share on other sites

That looks great. So will that replace the papal payment? We still want the order to go through paypal but to pause until shipping is manually added.

I'll give this a go and see how it behaves.

Thanks so much.

Marc

Link to comment
Share on other sites

Well I'm clearly missing something. I tried your steps and it still processes the sale all the way through.

 

Here is my statuses. I don't understand how the code knows that this is a "wait" stage. before it is to go to process the sale.

statuses.jpg

 

 

Here is the code in place.

if (!empty($errors) AND isset($_POST['custom']))
{
if (strtoupper($_POST['payment_status']) == 'PENDING')
 //$paypal->validateOrder((int)$cart_secure[0], Configuration::get('PS_OS_PAYPAL'), (float)$_POST['mc_gross'], $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id'].'<br />'.$errors, array('transaction_id' => $_POST['txn_id'], 'payment_status' => $_POST['payment_status']), NULL, false, $cart_secure[1]);

 //add pending status to order process
  $paypal->validateOrder((int)$cart_secure[0], 15, (float)$_POST['mc_gross'], $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id'].'<br />'.$errors, array('transaction_id' => $_POST['txn_id'], 'payment_status' => $_POST['payment_status']), NULL, false, $cart_secure );
else
 $paypal->validateOrder((int)$cart_secure[0], Configuration::get('PS_OS_ERROR'), 0, $paypal->displayName, $errors.'<br />', array(), NULL, false, $cart_secure[1]);
}

 

Let me know if I am missing something. Optionally I could set up a ftp account and you could look at it.

Thanks again. I really need this option.

Link to comment
Share on other sites

looks like we missed some references to validateOrder in the main module file, paypal.php

 

   	 // Order status
       switch ($result['PAYMENTSTATUS'])
       {
           case 'Completed':
               $id_order_state = Configuration::get('PS_OS_PAYMENT');
               break;
           case 'Pending':
               if ($result['PENDINGREASON'] != 'authorization')
                   $id_order_state = Configuration::get('PS_OS_PAYPAL');
               else
                   $id_order_state = (int)(Configuration::get('PAYPAL_OS_AUTHORIZATION'));
               break;
           default:
               $id_order_state = Configuration::get('PS_OS_ERROR');
       }

 

change from

$id_order_state = Configuration::get('PS_OS_PAYMENT');

 

to

$id_order_state = 15;

Link to comment
Share on other sites

That doesn't seem to have worked either :(

I will PM you the login creds I created for a test account so you can see. iut just goes through with the process.

For you it will take you to the paypal sandbox site.

 

// Order status
 switch ($result['PAYMENTSTATUS'])
 {
  case 'Completed':
   //$id_order_state = Configuration::get('PS_OS_PAYMENT');
   //break for shipping
   $id_order_state = 15;
   //break end
   break;
  case 'Pending':
   if ($result['PENDINGREASON'] != 'authorization')
 $id_order_state = Configuration::get('PS_OS_PAYPAL');
   else
 $id_order_state = (int)(Configuration::get('PAYPAL_OS_AUTHORIZATION'));
   break;
  default:
   $id_order_state = Configuration::get('PS_OS_ERROR');
 }

Link to comment
Share on other sites

  • 8 months later...
  • 1 year later...

I'd suggest a non-coding solution.

 

Take for example COD module.  You could modify it's translations to indicate shipping will be added to the order and you will be billed.

 

This solves issue of deferred payment, as you can change the order status xlation for COD.

 

Add the shipping to the order and then send request for payment.

 

guess I should throw in a plug for one of my geo ps extensions..

 

http://www.prestashop.com/forums/topic/279119-module-geo-targeting-localization-country-or-ip-simulator-pro/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...