orangedata / orangedata-client
此包的最新版本(4.0.0)没有提供许可证信息。
OrangeData项目的示例客户端API类
4.0.0
2024-05-14 14:53 UTC
Requires
- php: >=5.6.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
This package is not auto-updated.
Last update: 2024-09-22 13:16:49 UTC
README
OrangeData服务的PHP集成
库当前版本:4.0.0
PHP版本:5.6.6+
与互联网收银机交互的协议版本:2023年11月15日的2.29.1
内容
入门
连接库
要开始工作,需要连接类文件
<?php include_once 'orangedata_client.php';
创建客户端
<?php $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
客户端属性
要将在文件'curl.log'中记录日志,请写入
<?php $buyer->is_debug();
订单
创建订单
创建客户端后,可以开始创建订单。
<?php $order = [ 'id' => '23423423434', 'type' => 1, 'customerContact' => 'example@example.com', 'taxationSystem' => 1, 'key' => '1234567', 'ffdVersion' => 4 ]; $buyer->create_order($order);
订单属性
将项目添加到订单
<?php $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);
项目属性
nomenclatureCode 和 unitOfMeasurement 参数用于 FFD 1.05
itemCode、quantityMeasurementUnit、industryAttribute、plannedStatus、fractionalQuantity、barcodes 参数用于 FFD 1.2
供应商信息属性
代理信息属性
行业属性属性
分数属性属性
条形码属性
将付款添加到订单
<?php $payment = [ 'type' => 16, 'amount' => 131.23, ]; $buyer->add_payment_to_order($payment);
付款属性
将代理添加到订单
不支持FFD1.2
<?php $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);
代理属性
添加用户额外属性
<?php $userAttribute = [ 'name' => 'Like', 'value' => 'Example', ]; $buyer->add_user_attribute($userAttribute);
用户额外属性属性
添加额外字段
<?php $additional = [ 'additionalAttribute' => 'Attribute', 'customer' => 'Ivanov Ivan', 'customerINN' => '0987654321', ]; $buyer->add_additional_attributes($additional);
额外字段属性
客户信息属性
操作属性
行业属性属性
对于FFD1.2,Customer和customerINN参数变更为单个customerInfo参数。
将自助服务终端添加到订单
<?php $vending = [ 'automatNumber' => '21321321123', 'settlementAddress' => 'Address', 'settlementPlace' => 'Place', ]; $buyer->add_vending_to_order($vending);
自助服务终端属性
将快递员添加到订单
<?php $courier = [ 'settlementAddress' => 'Address', 'settlementPlace' => 'Place', 'cashier' => 'Test' 'cashierINN' => '123456789012' ]; $buyer->add_courier_to_order($courier);
快递员属性
发送订单
填写完所有订单字段并添加所有参数后,可以发送订单进行处理
<?php $result = $buyer->send_order(); var_dump($result);
检查订单状态
<?php $order_status = $buyer->get_order_status(23423423434); var_dump($order_status);
检查更正
创建FFD1.05更正检查
<?php $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);
更正检查属性
发送FFD1.05更正检查
<?php $result = $buyer->post_correction(); var_dump($result);
创建FFD1.2更正检查
<?php $correction = [ 'ffdVersion' => 4, 'id' => '23423423', 'inn' => '7725327863', 'key' => '1234567', 'correctionType' => 0, 'type' => 1, 'group' => 'main_2', 'causeDocumentDate' => new \DateTime(), 'causeDocumentNumber' => '56ce', 'totalSum' => 0, 'customerContact' => 'liza@ya.ru', 'vat1Sum' => 0, 'vat2Sum' => 0, 'vat3Sum' => 0, 'vat4Sum' => 0, 'vat5Sum' => 0, 'vat6Sum' => 0, ]; $buyer->create_correction12($correction);
更正检查属性
发送FFD1.2更正检查
<?php $result = $buyer->post_correction12(); var_dump($result);
将自助服务终端添加到更正检查
<?php $correctionVending = [ 'automatNumber' => '21321321123', 'settlementAddress' => 'Address', 'settlementPlace' => 'Place', ]; $buyer->add_vending_to_correction($correctionVending);
自助服务终端属性
将快递员添加到更正检查
<?php $correctionСourier = [ 'settlementAddress' => 'Address', 'settlementPlace' => 'Place', 'cashier' => 'Test' 'cashierINN' => '123456789012' ]; $buyer->add_courier_to_correction($correctionСourier);
快递员属性
将额外属性、项目和付款添加到更正检查(仅适用于FFD1.2)
<?php $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);
函数属性请参考订单中类似块的说明
检查更正检查状态
<?php $cor_status = $buyer->get_correction_status('23423423'); var_dump($cor_status);