/** * Fetch coupon info * * Controller Action */ public function execute() { $coupon_id = $this->getRequest()->getParam('id'); if (!empty($coupon_id)) { $response = $this->coreModel->validCoupon($coupon_id); } else { $response = $this->getArrayErrorResponse(); } if ($response['status'] != 200 && $response['status'] != 201) { $response = $this->getArrayErrorResponse(); } //save value to DiscountCoupon collect $this->_registry->register('mercadopago_discount_amount', (double) $response['response']['coupon_amount']); $quote = $this->_checkoutSession->getQuote(); $this->quoteRepository->save($quote->collectTotals()); $jsonData = json_encode($response); $this->getResponse()->setHeader('Content-type', 'application/json'); $this->getResponse()->setBody($jsonData); }