PHP code example of orangedata / orangedata-client

1. Go to this page and download the library: Download orangedata/orangedata-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

orangedata / orangedata-client example snippets





$client = [
  'inn' => '0123456789',
  'api_url' => '2443',
  // 'api_url' => 'https://apip.orangedata.ru:2443', // link access
  'sign_pkey' => dirname(__DIR__) . '/secure_path/private_key.pem',
  'ssl_client_key' => dirname(__DIR__) . '/secure_path/client.key',
  'ssl_client_crt' => dirname(__DIR__) . '/secure_path/client.crt',
  'ssl_ca_cert' => dirname(__DIR__) . '/secure_path/cacert.pem',
  'ssl_client_crt_pass' => 1234,
];

$buyer = new orangedata\orangedata_client($client); // create new client


$buyer->is_debug();


$order = [
  'id' => '23423423434',
  'type' => 1,
  'customerContact' => '[email protected]',
  'taxationSystem' => 1,
  'key' => '1234567',
  'ffdVersion' => 4
];

$buyer->create_order($order);


$position = [
  'quantity' => '10',
  'price' => 100,
  'tax' => 1,
  'text' => 'some text',
  'paymentMethodType' => 3,
  'paymentSubjectType' => 1,
  'nomenclatureCode' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
  'supplierInfo' => [
    'phoneNumbers' => ['+79266660011', '+79293456723'],
    'name' => 'PAO Example',
  ],
  'supplierINN' => 1234567890,
  'agentType' => 127,
  'agentInfo' => [
    'paymentTransferOperatorPhoneNumbers' => ['+79266660011', '+79293456723'],
    'paymentAgentOperation' => 'some operartion',
    'paymentAgentPhoneNumbers' => ['+79266660011', '+79293456723'],
    'paymentOperatorPhoneNumbers' => ['+79266660011'],
    'paymentOperatorName' => 'OAO ATLANT',
    'paymentOperatorAddress' => 'Address',
    'paymentOperatorInn' => 1234567890,
  ],
  'unitOfMeasurement' => 'kg',
  'additionalAttribute' => 'attribute',
  'manufacturerCountryCode' => '534',
  'customsDeclarationNumber' => 'AD 11/77 from 01.08.2018',
  'excise' => '12.43',
];

$buyer->add_position_to_order($position);


$payment = [
  'type' => 16,
  'amount' => 131.23,
];

$buyer->add_payment_to_order($payment);


$agent = [
  'agentType' => 127,
  'paymentTransferOperatorPhoneNumbers' => ['+79998887766', '+76667778899'],
  'paymentAgentOperation' => 'Operation',
  'paymentAgentPhoneNumbers' => ['+79998887766'],
  'paymentOperatorPhoneNumbers' => ['+79998887766'],
  'paymentOperatorName' => 'Name',
  'paymentOperatorAddress' => 'ulitsa Adress, dom 7',
  'paymentOperatorINN' => '3123011520',
  'supplierPhoneNumbers' => ['+79998887766', '+76667778899'],
];

$buyer->add_agent_to_order($agent);


$userAttribute = [
  'name' => 'Like',
  'value' => 'Example',
];

$buyer->add_user_attribute($userAttribute);


$additional = [
  'additionalAttribute' => 'Attribute',
  'customer' => 'Ivanov Ivan',
  'customerINN' => '0987654321',
];

$buyer->add_additional_attributes($additional);


$vending = [
  'automatNumber' => '21321321123',
  'settlementAddress' => 'Address',
  'settlementPlace' => 'Place',
];

$buyer->add_vending_to_order($vending);


$courier = [
  'settlementAddress' => 'Address',
  'settlementPlace' => 'Place',
  'cashier' => 'Test'
  'cashierINN' => '123456789012'
];

$buyer->add_courier_to_order($courier);


$result = $buyer->send_order();
var_dump($result);


$order_status = $buyer->get_order_status(23423423434);
var_dump($order_status);


$correction = [
  'id' => '23423423',
  'key' => '1234567',
  'correctionType' => 0,
  'type' => 1,
  'description' => 'cashier error',
  'causeDocumentDate' => new \DateTime(),
  'causeDocumentNumber' => '56ce',
  'totalSum' => 567.9,
  'cashSum' => 567,
  'eCashSum' => 0.9,
  'prepaymentSum' => 0,
  'postpaymentSum' => 0,
  'otherPaymentTypeSum' => 0,
  'tax1Sum' => 0,
  'tax2Sum' => 0,
  'tax3Sum' => 0,
  'tax4Sum' => 0,
  'tax5Sum' => 0,
  'tax6Sum' => 0,
  'taxationSystem' => 2,
];

$buyer->create_correction($correction);


$result = $buyer->post_correction();
var_dump($result);


  $correction = [
      'ffdVersion' => 4,
      'id' => '23423423',
      'inn' => '7725327863',
      'key' => '1234567',
      'correctionType' => 0,
      'type' => 1,
      'group' => 'main_2',
      'causeDocumentDate' => new \DateTime(),
      'causeDocumentNumber' => '56ce',
      'totalSum' => 0,
      'customerContact' => '[email protected]',
      'vat1Sum' => 0,
      'vat2Sum' => 0,
      'vat3Sum' => 0,
      'vat4Sum' => 0,
      'vat5Sum' => 0,
      'vat6Sum' => 0,
  ];

$buyer->create_correction12($correction);


$result = $buyer->post_correction12();
var_dump($result);


$correctionVending = [
  'automatNumber' => '21321321123',
  'settlementAddress' => 'Address',
  'settlementPlace' => 'Place',
];

$buyer->add_vending_to_correction($correctionVending);


$correctionСourier = [
  'settlementAddress' => 'Address',
  'settlementPlace' => 'Place',
  'cashier' => 'Test'
  'cashierINN' => '123456789012'
];

$buyer->add_courier_to_correction($correctionСourier);


 $correctionPos = [
      "quantity" => 1.000,
      "price" => 1,
      "tax" => 6,
      "text" => "Булка",
      "excise" => 23.45,
      "paymentMethodType" => 4, "paymentSubjectType" => 1,
      "agentType" => 127,
      "agentInfo" => 
      [
        "paymentTransferOperatorPhoneNumbers" => ["+79200000001", "+74997870001"], 
        "paymentAgentOperation" => "Какая-то операция 1",
        "paymentAgentPhoneNumbers" => ["+79200000003"], 
        "paymentOperatorPhoneNumbers" => ["+79200000002", "+74997870002"], 
        "paymentOperatorName" => "ООО \"Атлант\"", 
        "paymentOperatorAddress" => "Воронеж, ул. Недогонная, д. 84", 
        "paymentOperatorINN" => "7727257386"
      ]
  ];

  $correctionPayment =
      [
          'type' => 1,
          'amount' => 1,
      ];

  $userAttribute = [
    "value" => "2132",
    "name" => "21212"
  ];

  $additional = [
      'additionalAttribute' => 'Attribute',
       "customerInfo" =>[
            "name"=> "Кузнецов Иван Петрович",
            "inn"=> "7725327863",
            "birthDate"=> "15.09.1988",
            "citizenship"=> "643",
            "identityDocumentCode"=> "01",
            "identityDocumentData"=> "multipassport",
            "address"=> "Басеенная 36"
        ],
  ];

$buyer->add_position_to_correction12($correctionPos)
      ->add_payment_to_correction12($correctionPayment)
      ->add_user_attribute_to_correction12($userAttribute)
      ->add_additional_attributes_to_correction12($additional);


$cor_status = $buyer->get_correction_status('23423423');
var_dump($cor_status);