deutschepost / sdk-api-oneclickforrefund
Deutsche Post INTERNETMARKE 1C4R API SDK
Installs: 137 823
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 10
Forks: 0
Open Issues: 0
Requires (Dev)
- fig/log-test: ^1.1.0
- phpstan/phpstan: ^1.5.0
- phpunit/phpunit: ^9.5.0
- rector/rector: *
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-10-27 12:28:43 UTC
README
The DP OneClickForRefund API SDK package offers an interface to the following web services:
- OneClickForRefund
Requirements
System Requirements
- PHP 8.1+ with SOAP extension
Package Requirements
psr/log
: PSR-3 logger interfaces
Development Package Requirements
phpunit/phpunit
: Testing framework
Installation
$ composer require deutschepost/sdk-api-oneclickforrefund
Uninstallation
$ composer remove deutschepost/sdk-api-oneclickforrefund
Testing
$ ./vendor/bin/phpunit -c test/phpunit.xml
Features
The DP OneClickForRefund API SDK supports the following features:
- Cancel vouchers
The web service requires an authentication token. The library retrieves a token but discards it after the process terminates. In order to reuse the token, a persistent storage can be passed in (Persist Authentication Token).
Cancel Vouchers
Submit a return for INTERNETMARKE stamps.
Public API
The library's components suitable for consumption comprise
- services:
- service factory
- refund service
- data transfer objects:
- credentials
Usage
$shopOrderId = '1234567890'; $voucherIds = ['A0031C630F0000000135', 'A0031C630F0000000398']; $logger = new \Psr\Log\Test\TestLogger(); $tokenStorage = new \DeutschePost\Sdk\OneClickForRefund\Auth\TokenStorage(); $credentials = new \DeutschePost\Sdk\OneClickForRefund\Auth\Credentials( $username = 'max.mustermann@example.com', $password = 'portokasse321', $partnerId = 'PARTNER_ID', $partnerKey = 'SCHLUESSEL_DPWN_MEINMARKTPLATZ', $keyPhase = 1, $tokenStorage ); $serviceFactory = new \DeutschePost\Sdk\OneClickForRefund\Service\ServiceFactory(); $service = $serviceFactory->createRefundService($credentials, $logger); // cancel all the original order's vouchers OR $service->cancelVouchers($shopOrderId); // cancel some of the original order's vouchers $service->cancelVouchers($shopOrderId, $voucherIds);
Persist Authentication Token
To reuse a token during its lifetime, the credentials object can be created with a custom token storage. Implement access to a database, cache, or any other suitable source.
Usage
// PersistentTokenStorage implements \DeutschePost\Sdk\OneClickForRefund\Api\TokenStorageInterface $tokenStorage = new \My\OneClickForRefund\Auth\PersistentTokenStorage(); $credentials = new \DeutschePost\Sdk\OneClickForRefund\Auth\Credentials( $username = 'max.mustermann@example.com', $password = 'portokasse321', $partnerId = 'PARTNER_ID', $partnerKey = 'SCHLUESSEL_DPWN_MEINMARKTPLATZ', $keyPhase = 1, $tokenStorage );