1. Go to this page and download the library: Download hochstrasserio/wirecard 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/ */
use Hochstrasser\Wirecard\Helper\WirecardHelper;
// Guzzle 6
$guzzle = new Guzzle\Client;
$helper = new WirecardHelper($context, function ($request) use ($guzzle) {
return $guzzle->send($request);
});
// Sets the context, converts the request and makes the http response to a
// WirecardResponseInterface
$response = $helper->send(InitDataStorageRequest::withOrderIdentAndReturnUrl(
'1234', 'http://example.com'
));
$dataStorage = $response->toObject();
if ($response->hasErrors()) {
// Show errors in the UI
}
// Redirect if no errors happened
header('Location: '.$response->toObject()->getRedirectUrl());
php
use Hochstrasser\Wirecard\Context;
// Constructor takes Customer ID, Customer Secret, Language code, and Shop ID:
$context = new Context([
'customer_id' => 'D200001',
'secret' => 'B8AKTPWBRMNBV455FG6M2DANE99WU2',
'language' => 'de',
'shop_id' => 'qmore',
'hashing_method' => Context::HASHING_HMAC,
]);
php
use Hochstrasser\Wirecard\Request\Seamless\Frontend\InitDataStorageRequest;
$request = InitDataStorageRequest::withOrderIdentAndReturnUrl('1234', 'http://example.com')
->setContext($context);
$response = $request->createResponse($client->send($request->createHttpRequest()));
// Store the storage ID for later usage with the payment request
$_SESSION['wirecardDataStorageId'] = $response->toObject()->getStorageId();
var_dump($response->hasErrors());
var_dump($response->toObject()->getStorageId());
var_dump($response->toObject()->getJavascriptUrl());
php
use Hochstrasser\Wirecard\Request\Seamless\Frontend\ReadDataStorageRequest;
$request = ReadDataStorageRequest::withStorageId($_SESSION['wirecardDataStorageId'])
->setContext($context);
$response = $request->createResponse($client->send($request->createHttpRequest()));
var_dump($response->hasErrors());
var_dump($response->toObject()->getStorageId());
foreach ($response->toObject()->getPaymentInformation() as $paymentInformation) {
var_dump($paymentInformation->getMaskedPan());
}
php
use Hochstrasser\Wirecard\Model\Common\Basket;
use Hochstrasser\Wirecard\Model\Common\BasketItem;
// Create the basket, this is optional for most payment methods, but probably
// can be automatically created from your shop’s cart model
$basket = new Basket();
$basket->setAmount('17.00');
$basket->setCurrency('EUR');
$basket->addItem((new BasketItem)
->setArticleNumber('A001')
->setDescription('Product A1')
->setQuantity(1)
->setUnitPrice('10.00')
->setTax('1.00')
);
$basket->addItem((new BasketItem)
->setArticleNumber('SHIPPING')
->setDescription('Shipping')
->setQuantity(1)
->setUnitPrice('5.00')
->setTax('1.00')
);
php
use Hochstrasser\Wirecard\Model\Common\ShippingInformation;
use Hochstrasser\Wirecard\Model\Common\BillingInformation;
$shippingInformation = (new ShippingInformation)
->setFirstname('Max')
->setLastname('Mustermann')
->setAddress1('Musterstraße')
->setAddress2('2')
->setZipCode('1234')
->setState('Lower Austria')
->setCity('Musterstadt')
->setCountry('AT')
->setPhone('+431231231234')
->setFax('+431231231234');