This repository has been archived by the owner on May 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
71 lines (62 loc) · 2.14 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require __DIR__.'/../../vendor/autoload.php';
use Hochstrasser\Wirecard\Context;
use Hochstrasser\Wirecard\Model\Common\PaymentType;
use Hochstrasser\Wirecard\Model\Common\Basket;
use Hochstrasser\Wirecard\Model\Common\BasketItem;
use Hochstrasser\Wirecard\Model\Common\ShippingInformation;
use Hochstrasser\Wirecard\Model\Common\BillingInformation;
use Hochstrasser\Wirecard\Request\CheckoutPage\InitCheckoutPageRequest;
$context = new Context([
'customer_id' => 'D200411',
'secret' => 'CHCSH7UGHVVX2P7EHDHSY4T2S4CGYK4QBE4M5YUUG2ND5BEZWNRZW5EJYVJQ',
'language' => 'de',
'shop_id' => 'qmore'
]);
$basket = new Basket();
$basket->setAmount('18.00');
$basket->setCurrency('EUR');
$basket->addItem((new BasketItem)
->setArticleNumber('A001')
->setDescription('Product A1')
->setQuantity(1)
->setUnitPrice('10.00')
->setTax('2.00')
);
$basket->addItem((new BasketItem)
->setArticleNumber('SHIPPING')
->setDescription('Shipping')
->setQuantity(1)
->setUnitPrice('5.00')
->setTax('1.00')
);
$shipping = (new ShippingInformation)
->setFirstname('Christoph')
->setLastname('Hochstrasser')
->setAddress1('Markt 1')
->setZipCode('1234')
->setCity('Musterstadt')
->setState('Niederösterreich')
->setCountry('AT');
$billing = BillingInformation::fromShippingInformation($shipping)
->setConsumerEmail('me@christophh.net')
->setConsumerBirthdate(new \DateTime('01.01.1970'))
;
$request = InitCheckoutPageRequest::withBasket($basket)
->setPaymentType(PaymentType::Select)
->setConsumerShippingInformation($shipping)
->setConsumerBillingInformation($billing)
->setContext($context)
->setOrderDescription("12345")
->setSuccessUrl("http://localhost:8001/success.php")
->setFailureUrl("http://localhost")
->setCancelUrl("http://localhost")
->setServiceUrl("http://localhost")
;
?>
<form action="<?= $request->getEndpoint() ?>" method="POST">
<?php foreach ($request->getRequestParameters() as $param => $value): ?>
<input type="hidden" name="<?= $param ?>" value="<?= $value ?>"/>
<?php endforeach ?>
<input type="submit" value="Buy"/>
</form>