Jump to content

payment completion from order history page


Recommended Posts

Hi,

 

I would like to ask you how to make that customer could pay from his order history page. For example, he orders products but not completes payment (no money in bank account or something), need that he could make payment through order history page.

 

Prestashop version - 1.6

Link to comment
Share on other sites

yes i had done that the problem I am facing is instead of cart elements I need current order elements. I mean 

$address = new Address((int)$this->context->cart->id_address_invoice);
        $address_state =  new State($address->id_state);
        $customer = new Customer($this->context->cart->id_customer);
        $amount = $this->context->cart->getOrderTotal();  
 
so $amount is coming zero because I am not entering it into the cart. How I pass the current order id and total amount then update the order instead of create?
Link to comment
Share on other sites

You should not really be editing any table.
If the order has been placed, and it has been, you just have to trigger a payment with the module you have, just using the way it processes it by default
 

$order->addOrderPayment($amount, Tools::getValue('payment_method'),
                        Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date'),
                        $order_invoice)

This is how you usually add a payment for an already created order, but it obviously needs to take place after the cc payment has been processed by your module's api

After that you can trigger a new order state
Link to comment
Share on other sites

yes i had created another function and added only the code to update the order-payment table but there is a condition - if (!isset($order) || !Validate::isLoadedObject($order) || !$order->addOrderPayment($amount_paid, null, $transaction_id)) {

 

I had changed only the condition to

 

if ( !$Order->addOrderPayment($amount_paid, null, $transaction_id)) {

PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int)$id_cart, true);
throw new PrestaShopException('Can\'t save Order Payment');
}

 Now the problem is how I add $order here? so condition is failing


yes i had created another function and added only the code to update the order-payment table but there is a condition - if (!isset($order) || !Validate::isLoadedObject($order) || !$order->addOrderPayment($amount_paid, null, $transaction_id)) {

 

I had changed only the condition to

 

if ( !$Order->addOrderPayment($amount_paid, null, $transaction_id)) {

PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int)$id_cart, true);
throw new PrestaShopException('Can\'t save Order Payment');
}

 Now the problem is how I add $order here? so condition is failing

Link to comment
Share on other sites

@nemo I had solved it by taking

 

 
            //Insert current order id in cookie
            Context::getContext()->cookie->__set('current_order_id', $this->existingOrderId);
 
Not sure I am taking correct way to retrieve existing ID. Now Order Id is getting and I can update into the order_payment table, now the problem I am facing is duplicate transaction details are entering for single transaction i.e, for payment completion the order-payment table is inserting with two values, one with transaction id and one without.
Link to comment
Share on other sites

How are you adding it to the cookie? I mean you get it from a link or save it after the order partial completion?
Be aware of the fact that in the latter case, if someone places two orders consecutively, they will never be able to pay for the first one.

When is it inserting the empty payment?

Link to comment
Share on other sites

  • 1 year later...

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...