Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedenweb/webpay
Wrapper for GP Webpay request and response
https://github.com/jedenweb/webpay
Last synced: about 1 month ago
JSON representation
Wrapper for GP Webpay request and response
- Host: GitHub
- URL: https://github.com/jedenweb/webpay
- Owner: JedenWeb
- Created: 2015-03-15T21:10:09.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-09T19:10:43.000Z (about 6 years ago)
- Last Synced: 2024-08-05T23:24:00.159Z (5 months ago)
- Language: PHP
- Size: 28.3 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Wrapper for GP Webpay request and response
===## Sending request
```
use JedenWeb\Webpay;$request = new Webpay\Request('private.pem', 'password');
$request->setWebPayUrl('https://test.3dsecure.gpwebpay.com/rb/order.do');
$request->setResponseUrl('http://example.com/order.php');
$request->setMerchantNumber(1234);
$request->setOrderInfo(100001 /* webpay order number */, 12345678 /* eshop order number */);
$request->setPayment(10.50); // optionally Request::CZK, Request::EUR, Request::USD as second parameter, CZK is default
echo "Pay";
```In Nette
```
extensions:
webpay: JedenWeb\Webpay\DI\WebpayExtension
webpay:
privateKey: %appDir%/cert/private.pem
publicKey: %appDir%/cert/public.pem
password: 'abc'
merchantId: '012345'
# webpayUrl: 'https://3dsecure.gpwebpay.com/kb/order.do' is default
```
and then in your application
```
$builder = $requestBuilderFactory->create();
$builder->setResponseUrl('http://example.com/order.php');
$builder->setOrderInfo(100001 /* webpay order number */, 12345678 /* eshop order number */);
$builder->setPayment(10.50); // optionally Request::CZK, Request::EUR, Request::USD as second parameter, CZK is default/* validates all required fields are provided */
$request = $builder->build();$template->url = $request->getRequestUrl();
```## Accepting response
```
use JedenWeb\Webpay;$response = new Webpay\Response('public.pem');
$response->setResponseParams($httpRequest->getQuery()); // $_GET is uglyif ($response->verify(/* optionally merchant number */)) // authentic a successful
...
```In Nette
```
// throws JedenWeb\Webpay\InvalidStateException if a required field is missing in query
$response = $responseFactory->create();if ($response->verify(/* optionally merchant number */)) // authentic a successful
...
```