1
0
mirror of synced 2025-01-18 17:01:41 +03:00

Fixed bug of sending incorrect externalId when editing payment

This commit is contained in:
Konstantin 2019-03-13 11:46:58 +03:00
parent af90b22c3e
commit c82faf616a

View File

@ -194,7 +194,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
}
if (isset($payment) && $payment['type'] == $this->retailcrm_settings[$order->get_payment_method()] && $order->is_paid()) {
$payment = $this->sendPayment($order, true);
$payment = $this->sendPayment($order, true, $payment['externalId']);
return $payment;
}
@ -402,13 +402,21 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
*
* @return array $payment
*/
protected function sendPayment($order, $update = false)
protected function sendPayment($order, $update = false, $externalId = false)
{
$payment = array(
'amount' => $order->get_total(),
'externalId' => $order->get_id() . uniqid('-')
'amount' => $order->get_total()
);
if ($update)
{
$payment['externalId'] = $externalId;
}
else
{
$payment['externalId'] = $order->get_id() . uniqid('-');
}
$payment['order'] = array(
'externalId' => $order->get_id()
);