Skip to content

Instantly share code, notes, and snippets.

@aboodma
Forked from XOlegator/test-retail-api.php
Created July 27, 2019 08:57
Show Gist options
  • Save aboodma/278fa1eda986039f1dfb2bbbe6af6dba to your computer and use it in GitHub Desktop.
Save aboodma/278fa1eda986039f1dfb2bbbe6af6dba to your computer and use it in GitHub Desktop.
<?php
// Подключим зависимые библиотеки (API RetailCRM)
require_once __DIR__ . '/vendor/autoload.php';
$arVersions = [
\RetailCrm\ApiClient::V4,
\RetailCrm\ApiClient::V5
];
$site = 'https://sitename';
$apiKey = 'secretKey';
$arTestOrderData = [
'externalId' => 40,
'createdAt' => '2017-07-15 14:23:38',
'phone' => '+7900-0000000',
'email' => '[email protected]',
'customerComment' => '',
'managerComment' => '',
'contragent' => [
'contragentType' => 'individual'
],
'orderType' => 'eshop-individual',
'orderMethod' => 'shopping-cart',
'items' => [
0 => [
'initialPrice' => 25000,
'offer' => [
'externalId' => 37
],
'productName' => 'Пылесос Dyson DC23 Pink',
'quantity' => 1
]
],
'delivery' => [
'cost' => 0.00,
'address' => [
'text' => 'г. Липецк, ул. Пушкина, д. 1'
],
'code' => 'courier'
],
'customer' => [
'externalId' => 2
],
'status' => 'new',
'discount' => 0.00,
'discountPercent' => 0.00,
'paymentStatus' => 'not-paid',
'firstName' => 'Иван',
];
foreach ($arVersions as $key => $apiVer) {
echo '<pre>';
$clientRetailCRM = new \RetailCrm\ApiClient(
$site,
$apiKey,
$apiVer
);
echo 'Версия = ' . $clientRetailCRM->getVersion() . PHP_EOL;
try {
$response = $clientRetailCRM->request->ordersCreate($arTestOrderData);
print_r($response);
} catch (\RetailCrm\Exception\CurlException $e) {
echo 'RetailCRM_Api ordersCreate() ' . $e->getMessage();
}
echo '</pre>';
unset($clientRetailCRM);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment