Skip to content

Instantly share code, notes, and snippets.

@XOlegator
Created July 15, 2017 13:09
Show Gist options
  • Save XOlegator/2114ec1bd4d3cdbcfcf98f3b7e00073c to your computer and use it in GitHub Desktop.
Save XOlegator/2114ec1bd4d3cdbcfcf98f3b7e00073c 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' => 'ldcrkxrfb@emltmp.com',
'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