Skip to content

Commit

Permalink
Merge pull request #3 from Tyler-Magebinary/SP-3802
Browse files Browse the repository at this point in the history
Sp 3802 Implement LPay+ and Co-presentment functionalities
  • Loading branch information
Tyler-Magebinary committed Aug 19, 2021
2 parents b6e64d5 + 9bfbe01 commit 0c2cd38
Show file tree
Hide file tree
Showing 31 changed files with 314 additions and 768 deletions.
2 changes: 1 addition & 1 deletion config.xml
Expand Up @@ -2,7 +2,7 @@
<module>
<name>latitude_official</name>
<displayName><![CDATA[Latitude Finance Payment Module]]></displayName>
<version><![CDATA[1.1]]></version>
<version><![CDATA[1.2]]></version>
<description><![CDATA[Available to NZ and OZ residents who are 18 years old and over and have a valid debit or credit card.]]></description>
<author><![CDATA[Latitude Financial Services]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
13 changes: 8 additions & 5 deletions controllers/front/payment.php
Expand Up @@ -35,25 +35,24 @@ public function initContent()
} catch (Exception $e) {
$errors[] = Tools::displayError($e->getMessage());
Tools::redirect('index.php?controller=order');

return;
}
}

/**
* get the payment checkout logo by the current currency
* Get the payment checkout logo by the current currency
* @return string
* @throws Exception
*/
protected function getPaymentCheckoutLogo()
{
$logo = '';
$currencyCode = $this->context->currency->iso_code;
switch ($currencyCode) {
case 'AUD':
$logo = 'latitudepay_checkout.svg';
$logo = 'latitudepay.svg';
break;
case 'NZD':
$logo = 'genoapay_checkout.svg';
$logo = 'genoapay.svg';
break;
default:
throw new Exception('Unsupported currency code. Please change your currency code to AUD or NZD.');
Expand Down Expand Up @@ -131,11 +130,15 @@ public function getPurchaseUrl()
BinaryPay::log($e->getMessage(), true, 'prestashop-latitude-finance.log');
PrestaShopLogger::addLog($e->getMessage(), 1, null, 'PaymentModule', (int)$cart->id, true);
$this->errors[] = $e->getMessage();
Tools::redirect('index.php?controller=order');
return;
} catch (Exception $e) {
$message = $e->getMessage() ?: 'Something massively went wrong. Please try again. If the problem still exists, please contact us';
PrestaShopLogger::addLog($message, 1, null, 'PaymentModule', (int)$cart->id, true);
BinaryPay::log($message, true, 'latitudepay-finance-' . date('Y-m-d') . '.log');
$this->errors[] = $message;
Tools::redirect('index.php?controller=order');
return;
}
return $purchaseUrl;
}
Expand Down
14 changes: 8 additions & 6 deletions controllers/front/return.php
Expand Up @@ -28,6 +28,13 @@ public function initContent()
// Add the validation
$reference = Tools::getValue('reference');

if (Configuration::get(Latitude_Official::LATITUDE_FINANCE_DEBUG_MODE)) {
$logMessage = "======CALLBACK INFO STARTS======\n";
$logMessage .= json_encode(Tools::getAllValues(), JSON_PRETTY_PRINT);
$logMessage .= "\n======CALLBACK INFO ENDS======";
BinaryPay::log($logMessage, true, 'latitudepay-finance-' . date('Y-m-d') . '.log');
}

if (!$this->context->cookie->reference || $this->context->cookie->reference !== $reference) {
Tools::redirect(Context::getContext()->shop->getBaseURL(true));
}
Expand All @@ -50,10 +57,6 @@ public function initContent()
)
);
} else {
$message = (is_array($response)) ? json_encode($response) : 'Error response from Latitude Financial services API. The response data cannot be recorded.';
// record all the FAILED status order
// just in case we lose the response messages and transaction token ID
BinaryPay::log($message, true, 'prestashop-latitude-finance.log');
$this->errors[] = Context::getContext()->getTranslator()->trans("Your purchase order has been cancelled.");
$this->redirectWithNotifications('index.php?controller=order&step=1');
}
Expand All @@ -71,8 +74,7 @@ public function initContent()
* @param string $message
* @return string
*/
protected function
translateErrorMessage($message)
protected function translateErrorMessage($message)
{
switch ($message) {
case 'The customer cancelled the purchase.':
Expand Down

0 comments on commit 0c2cd38

Please sign in to comment.