diff --git a/Checkout/Api/Platform/Cart.php b/Checkout/Api/Platform/Cart.php index 30d0f71..f8471dd 100644 --- a/Checkout/Api/Platform/Cart.php +++ b/Checkout/Api/Platform/Cart.php @@ -94,7 +94,7 @@ public static function estimateShippingMethods( Mage_Core_Controller_Request_Http $request, Mage_Core_Controller_Response_Http $response ) { - preg_match('/cart\/(.*)\/estimate-shipping-methods/', $request->getRequestUri(), $cartIdMatches); + preg_match('/carts\/(.*)\/estimate-shipping-methods/', $request->getRequestUri(), $cartIdMatches); $cartId = isset($cartIdMatches[1]) ? $cartIdMatches[1] : null; /** @var Mage_Sales_Model_Quote $quote */ $quote = Mage::getModel('sales/quote'); @@ -106,8 +106,18 @@ public static function estimateShippingMethods( return Bold_Checkout_Rest::buildResponse($response, json_encode([])); } $payload = json_decode($request->getRawBody()); - // todo: implement estimate-shipping methods. - return Bold_Checkout_Rest::buildResponse($response, json_encode([])); + self::updateAddress($quote->getShippingAddress(), $payload->address, $quote); + $quote->getShippingAddress()->setCollectShippingRates(true); + $quote->setDataChanges(true); + $quote->collectTotals(); + try { + return Bold_Checkout_Rest::buildResponse( + $response, + json_encode(Bold_Checkout_Service_Extractor_Quote_ShippingMethods::extract($quote)) + ); + } catch (Mage_Core_Model_Store_Exception $e) { + return self::buildErrorResponse($e->getMessage(), $response); + } } /** diff --git a/Checkout/Service/PaymentMethod.php b/Checkout/Service/PaymentMethod.php index d0d1c58..e690edb 100644 --- a/Checkout/Service/PaymentMethod.php +++ b/Checkout/Service/PaymentMethod.php @@ -87,7 +87,7 @@ public function getTitle() if ($infoInstance && $infoInstance->getCcLast4()) { $ccLast4 = $infoInstance->decrypt($infoInstance->getCcLast4()); $title .= strlen($ccLast4) === 4 - ? $infoInstance->getCcType() . ': ••••• •••••• ' . $ccLast4 + ? $infoInstance->getCcType() . ': ending in ' . $ccLast4 : $infoInstance->getCcType() . ': ' . $ccLast4; } return $title ?: parent::getTitle();