mallgroup / mpapi-client-php

MPAPI client is a PHP tool created to help Internet Mall, a. s. partners easily manage article catalog, deliveries, orders, etc. using Mall Marketplace API.
Apache License 2.0
6 stars 19 forks source link

Product price protection #28

Open tescz opened 2 years ago

tescz commented 2 years ago

Zdravím,

pokud dobře chápu, zatím není možné přes tohoto API klienta změnit cenu produktu o více jak 30%. Musí se totiž zasílat force_token, ovšem jak v příkladech, tak v kódu jsem nenašel, jak je tohle možné provést. Nebo mýlím se?

https://mpapi-docs.mallgroup.com/#/Products

FluffyDiscord commented 2 years ago

Tohle by bylo třeba přidat také pro V3 verzi balíčku. Tahle "ochrana" by měla jít globálně vypnout v účtu MallPartner.

DRN88 commented 9 months ago

Why is this still not merged? This exception happens all the time.

vendor/mallgroup/mpapi-client/src/Article/ArticleClient.php

    public function updateProduct(ProductRequest $product): void
    {
        $this->sendJson('PUT', sprintf(self::PRODUCT_DETAIL, $product->getId()), $product->getArrayForApi());
    }

    public function updateProductWithForceToken(ProductRequest $product, string $forceToken): void
    {
        $appendUrlWithForceToken = '?force_token=' . $forceToken;
        $this->sendJson('PUT', sprintf(self::PRODUCT_DETAIL, $product->getId()) . $appendUrlWithForceToken, $product->getArrayForApi());
    }

    public function deleteProduct(string $productId): void
    {
        $this->sendJson('DELETE', sprintf(self::PRODUCT_DETAIL, $productId));
    }

In a try-catch, get the force token, and use updateProductWithForceToken to update the product.

DRN88 commented 3 weeks ago

This is still not fixed.