Skip to content

Commit

Permalink
Removed redundant callback url param
Browse files Browse the repository at this point in the history
  • Loading branch information
albtje committed Mar 29, 2019
1 parent 91aeb10 commit 6b5909f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
16 changes: 5 additions & 11 deletions app/code/community/Svea/Checkout/Model/Checkout/Api/BuildOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,18 @@ protected function _setupOrderConfig($sveaOrder, $quote)
$quoteId = $quote->getId();
$storeId = Mage::app()->getStore()->getId();
$mode = Mage::getStoreConfig('payment/SveaCheckout/testmode', $storeId) ? 'test' : 'prod';
$secret = urlencode(Mage::getModel('Core/Encryption')->encrypt($quoteId));

$pushParams = [
$callbackParams = [
'quoteId' => $quoteId,
'mode' => $mode,
];

if (isset($pushParams['sveaId'])) {
$pushParams['sveaId'] = $quote->getPaymentReference();
if (isset($callbackParams['sveaId'])) {
$callbackParams['sveaId'] = $quote->getPaymentReference();
}

$validationParams = array_merge(
$pushParams,
['secret' => $secret]
);

$pushUri = Mage::getUrl('sveacheckout/push', $pushParams);
$validationUri = Mage::getUrl('sveacheckout/validation', $validationParams);
$pushUri = Mage::getUrl('sveacheckout/push', $callbackParams);
$validationUri = Mage::getUrl('sveacheckout/validation', $callbackParams);
$termsUri = Mage::getUrl('sveacheckout/index/terms', ['quoteId' => $quoteId]);

//payment_SveaCheckout_override_terms_uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,9 @@ protected function _getSveaResponse($sveaOrder)

if(isset($response['MerchantSettings']['CheckoutValidationCallBackUri'])){
$validationUri = $response['MerchantSettings']['CheckoutValidationCallBackUri'];
preg_match('/secret\/(.+)\//', $validationUri, $validationUri);
$encryptedSecret = urlencode(Mage::getModel('Core/Encryption')->encrypt($quote->getId()));
preg_match('/quoteId\/([0-9]+)\//', $validationUri, $validationUri);

if ($validationUri[1] != $encryptedSecret) {
if ($validationUri[1] != $quote->getId()) {
$this->_invalidateQuote($sveaOrder, $quote);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,13 @@ public function indexAction()
$sveaOrder = $svea->setupCommunication();
$request = $this->getRequest();
$quoteId = (int)$request->getParam('quoteId');
$secret = $request->getParam('secret');
$decryptedSecret = (int)Mage::getModel('Core/Encryption')->decrypt($secret);
$orderQueueItem = Mage::getModel('sveacheckout/queue')->load($quoteId, 'quote_id');

if (!$orderQueueItem->getId()) {

return $this->reportAndReturn(204, "QueueItem {$quoteId} not found in queue.");
}

if ($decryptedSecret !== $quoteId) {

return $this->reportAndReturn(204, "Secret does not match on Queue ID {$quoteId}.");
}

try {
$quote = $this->_getQuoteById($quoteId);
$storeId = $quote->getStoreId();
Expand Down

0 comments on commit 6b5909f

Please sign in to comment.