The DP OneClickForRefund API SDK package offers an interface to the following web services:
- OneClickForRefund
- PHP 7.2+ with SOAP extension
psr/log
: PSR-3 logger interfaces
phpunit/phpunit
: Testing framework
$ composer require deutschepost/sdk-api-oneclickforrefund
$ composer remove deutschepost/sdk-api-oneclickforrefund
$ ./vendor/bin/phpunit -c test/phpunit.xml
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).
Submit a return for INTERNETMARKE stamps.
The library's components suitable for consumption comprise
- services:
- service factory
- refund service
- data transfer objects:
- credentials
$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);
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.
// 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
);