kruegge82/deutschepost-internetmarke-php-sdk

部门:德国邮政包裹 - INTERNETMARKE是德国邮政股份公司邮件产品的在线邮资。

v1.25.1 2024-08-26 10:05 UTC

This package is auto-updated.

Last update: 2024-09-26 10:19:32 UTC


README

部门:德国邮政包裹
INTERNETMARKE是德国邮政股份公司邮件产品的在线邮资。

更多信息,请访问https://www.deutschepost.de/de/i/internetmarke-porto-drucken/kundenservice/internetmarke/kontakt.html

安装与使用

要求

PHP 7.4及更高版本。也适用于PHP 8.0。

Composer

要使用Composer安装绑定,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/kruegge82/deutschepost-internetmarke-php-sdk.git"
    }
  ],
  "require": {
    "kruegge82/deutschepost-internetmarke-php-sdk": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

<?php
require_once('/path/to/vendor/autoload.php');

入门指南

请按照安装过程进行,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');




$apiInstance = new OpenAPI\Client\Api\ApiVersionResourceApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);

try {
    $result = $apiInstance->apiVersion();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ApiVersionResourceApi->apiVersion: ', $e->getMessage(), PHP_EOL;
}

完整DirectCheckout示例

请按照安装过程进行,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$apiInstance = new OpenAPI\Client\Api\UserResourceApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$grant_type = 'client_credentials'; // string | OAuth2 standard content, must be set to 'client_credentials'
$username = 'franz.klammer@dhldp-test.de'; // string | Internetmarke user name (e.g. 'franz.klammer').
$password = 'abfahrt123#'; // string | Internetmarke password (e.g. 'abfahrt123#')
$client_id = 'XjSnyVWgQp1ShIQ5HQ6Vq5PIYLN2jGNS'; // string | API client_id obtained from developer portal (e.g. 'XjSnyVWgQp1ShIQ5HQ6Vq5PIYLN2jGNS')
$client_secret = 'TICgJWGRysH7mA57'; // string | API client_secret obtained from developer portal (e.g. 'TICgJWGRysH7mA57')
$for_payment = false; // bool | Flag to indicate the authorization for payment use case.


try {
    $result = $apiInstance->authorization($grant_type, $username, $password, $client_id, $client_secret, $for_payment);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling UserResourceApi->authorization: ', $e->getMessage(), PHP_EOL;
}

// Configure Bearer authorization: BearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken($result->getAccessToken());

$apiInstance = new OpenAPI\Client\Api\AppResourceApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

$AppShoppingCartPDFPosition=new \OpenAPI\Client\Model\AppShoppingCartPDFPosition();
$AppShoppingCartPDFPosition->setProductCode(10001);
$AppShoppingCartPDFPosition->setVoucherLayout("ADDRESS_ZONE");
$position = new \OpenAPI\Client\Model\VoucherPosition();
$position->setPage(1);
$position->setLabelX(1);
$position->setLabelY(1);
$AppShoppingCartPDFPosition->setPosition($position);
$AppShoppingCartPDFPosition->setPositionType("AppShoppingCartPDFPosition");

$checkout_shopping_cart_pdf_app_request = new \OpenAPI\Client\Model\AppShoppingCartPDFRequest();
$checkout_shopping_cart_pdf_app_request->setType('AppShoppingCartPDFRequest');
$checkout_shopping_cart_pdf_app_request->setPageFormatId(2);
//$checkout_shopping_cart_pdf_app_request->setShopOrderId($result->getShopOrderId());
$checkout_shopping_cart_pdf_app_request->setPositions($AppShoppingCartPDFPosition);
$checkout_shopping_cart_pdf_app_request->setTotal(110);
//$checkout_shopping_cart_pdf_app_request->setCreateManifest(false);
//$checkout_shopping_cart_pdf_app_request->setCreateShippingList(false);
$checkout_shopping_cart_pdf_app_request->setDpi('DPI203');
$validate = false; // bool | This request parameter enables the validate (preview) case.<br/>The response will contain the link to a preview image of an internet stamp in PDF format. A product code, a layout format and optionally a motif are transferred to the service. This information is encoded in the link and evaluated by INTERNETMARKE when the preview image is rendered. If the product code, print format, or theme ID is invalid, the response to the caller will contain appropriate information.   <br/><br/> For the validate (preview) case the 'Authorization' header is not required and the request body has to be of the specified type (See `#/components/schemas/AppShoppingCartPreviewPDFRequest`).
$finalize = false; // bool | This request parameter enables the direct finalization of the shopping cart and an extra finalization request is not required.
$directCheckout = true; // bool | This request parameter enables the direct checkout of the shopping cart and an extra finalization request is not required.

try {
    $result = $apiInstance->checkoutShoppingCartPDFApp($checkout_shopping_cart_pdf_app_request, $validate, $finalize, $directCheckout);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AppResourceApi->checkoutShoppingCartPDFApp: ', $e->getMessage(), PHP_EOL;
}

API端点

所有URI都是相对于https://api-eu.dhl.com/post/de/shipping/im/v1

模型

授权

API中定义的认证方案

BearerAuth

  • 类型:Bearer认证