Skip to content

Commit

Permalink
Merge branch 'master' of bitbucket.org:comercia/mollie
Browse files Browse the repository at this point in the history
  • Loading branch information
maximj committed Jan 29, 2019
2 parents 816e1e5 + fa9fa52 commit 4921a4a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
24 changes: 23 additions & 1 deletion catalog/controller/payment/mollie/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,26 @@ private function webhookForPayment($payment_id) {

// Load essentials
Util::load()->model("checkout/order");
$this->getModuleModel();
$model = $this->getModuleModel();
Util::load()->language("payment/mollie");

//Get order_id of this transaction from db
$order = $this->model_checkout_order->getOrder($mollieOrder->metadata->order_id);

//Set transaction ID
$data = array();

if($molliePayment) {
$data = array(
'payment_id' => $payment_id,
'status' => $molliePayment->status
);
}

if(!empty($data)) {
$model->updatePayment($mollieOrder->metadata->order_id, $mollieOrderId, $data);
}

if (empty($order)) {
header("HTTP/1.0 404 Not Found");
echo "Could not find order.";
Expand Down Expand Up @@ -890,6 +904,14 @@ public function callback()
if (($orderDetails->isPaid() || $orderDetails->isAuthorized()) && $order['order_status_id'] != $paid_status_id) {
$this->addOrderHistory($order, $paid_status_id, $this->language->get("response_success"), true);
$order['order_status_id'] = $paid_status_id;
} else if(!empty($orderDetails->_embedded->payments)) {

$payment = $orderDetails->_embedded->payments[0];
if (($payment->status == 'paid') && ($order['order_status_id'] != $paid_status_id)) {
$this->addOrderHistory($order, $paid_status_id, $this->language->get("response_success"), true);
$order['order_status_id'] = $paid_status_id;
}

}

/* Check module module setting for shipment creation,
Expand Down
14 changes: 8 additions & 6 deletions catalog/model/payment/mollie/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,19 @@ public function setPayment($order_id, $mollie_order_id)
*
* @return bool
*/
public function updatePayment($transaction_id, $payment_status, $consumer = NULL)
public function updatePayment($order_id, $mollie_order_id, $data, $consumer = NULL)
{
if (!empty($transaction_id) && !empty($payment_status)) {
if (!empty($order_id) && !empty($mollie_order_id)) {
$this->db->query(
sprintf(
"UPDATE `%smollie_payments`
SET `bank_status` = '%s'
WHERE `transaction_id` = '%s';",
SET `transaction_id` = '%s', `bank_status` = '%s'
WHERE `order_id` = '%s' AND `mollie_order_id` = '%s';",
DB_PREFIX,
$this->db->escape($payment_status),
$this->db->escape($transaction_id)
$this->db->escape($data['payment_id']),
$this->db->escape($data['status']),
$this->db->escape($order_id),
$this->db->escape($mollie_order_id)
)
);

Expand Down

0 comments on commit 4921a4a

Please sign in to comment.