mirakl / sdk-php-shop

Mirakl PHP SDK for sellers
30 stars 16 forks source link

Invalide Page Token TransactionLineRequest #30

Open akkushopJK opened 2 years ago

akkushopJK commented 2 years ago

Hi,

We always get the error "Invalide Page Token" when we try to seek through results

$request = new \Mirakl\MMP\Shop\Request\Payment\Transaction\TransactionLineRequest();
$request->setDateCreatedFrom(new \Datetime('-1 Month'));
$result = $api->getTransactionLine($request);

$request = new \Mirakl\MMP\Shop\Request\Payment\Transaction\TransactionLineRequest();
$request->setPageToken($result->getNextPageToken());
$result = $api->getTransactionLine($request);

is there any magic to to that?

jreinke commented 2 years ago

Hello,

After investigation, it seems that the problem does not come from the PHP SDK itself but from API TL02. The date format provided is allowed in the first API call but generates an error with the second one (with the token).

I am going to escalate the ticket to the support team but in the meanwhile, I suggest the following workaround for the first API call:

$date = new \Datetime('-1 Month');
$api->queryParams = [
    'date_created_from' => $date->format('Y-m-d\TH:i:s\Z')
];
$result = $api->getTransactionLine($request);

Thanks for your feedback.

Best, Johann

akkushopJK commented 2 years ago

thats working ok in the functions.php this is defined

/**
 * @param \DateTime $date
 * @return string
 */
if (!function_exists('\Mirakl\date_format')) {
    function date_format(\DateTime $date)
    {
        return $date->setTimezone(new \DateTimeZone('GMT'))
            ->format(\DateTime::ISO8601);
    }
}

should be fixed in the API or in the function for propper use.