Skip to content

Include new parameters in session and authorize to support MarketPay integration - #158

Open
BushraAsif wants to merge 9 commits into
mainfrom
support-marketpay-applepay
Open

BushraAsif wants to merge 9 commits into
mainfrom
support-marketpay-applepay

Conversation

@BushraAsif

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread controllers/front/cardwalletsession.php Outdated
{
$db = Db::getInstance();

$uniqueId = $db->getValue('SELECT unique_id FROM `' . _DB_PREFIX_ . 'altapay_transaction` WHERE id_cart = ' . $cartId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to cast, you can't guarantee that the layer using the method will do the casting for you

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -17,23 +19,112 @@ public function postProcess()
{
$currentShopId = $this->context->shop->id;
$validationUrl = Tools::getValue('validationUrl');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we validate this is a valid url ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — I’ve added a check for this now.

Comment thread controllers/front/cardwalletsession.php Outdated
->setDomain($domain);

if (!$terminal->applepay_legacy_flow) {
$requestedAmount = (float) Tools::getValue('amount');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting can return valid numeric values for bad input such as "", boolean, etc.

This can caause the requested amount to be an unexpected value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

->setDomain($domain);

if (!$terminal->applepay_legacy_flow) {
$requestedAmount = Tools::getValue('amount');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the value coming from? Is that coming from the front? If yes, then it looks to be exposed for an attacker to be tampered => a lower value retrieved by the merchant


if (!empty($paymentId)) {
$sql = 'INSERT INTO `' . _DB_PREFIX_ . 'altapay_cartInfo` (id_cart, date_add, payment_id, shop_order_id) VALUES ('
. (int) $cart->id . ", '" . pSQL(time()) . "', '" . pSQL($paymentId) . "', '" . pSQL($shopOrderId) . "')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$cart->id might be null if cardwalletsession is invoked by a user whose session has expired.
The code currently inserts a row into the altapay_cartInfo table using (int) $cart->id, which will result in inserting 0 as the id_cart.
Maybe you should validate the $cart->id

data: {
validationUrl: event.validationURL,
termminalid: terminalId
termminalid: terminalId,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo termminalid

@ovidiuba ovidiuba left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants