|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @link https://github.com/phpviet/omnipay-vtcpay |
| 4 | + * |
| 5 | + * @copyright (c) PHP Viet |
| 6 | + * @license [MIT](https://opensource.org/licenses/MIT) |
| 7 | + */ |
| 8 | + |
| 9 | +namespace Omnipay\VTCPay; |
| 10 | + |
| 11 | +use Omnipay\Common\AbstractGateway; |
| 12 | +use Omnipay\VTCPay\Message\PurchaseRequest; |
| 13 | +use Omnipay\VTCPay\Message\NotificationRequest; |
| 14 | +use Omnipay\VTCPay\Message\CompletePurchaseRequest; |
| 15 | + |
| 16 | +/** |
| 17 | + * @author Vuong Minh <vuongxuongminh@gmail.com> |
| 18 | + * @since 1.0.0 |
| 19 | + */ |
| 20 | +class Gateway extends AbstractGateway |
| 21 | +{ |
| 22 | + use Concerns\Parameters; |
| 23 | + use Concerns\ParametersNormalize; |
| 24 | + |
| 25 | + /** |
| 26 | + * {@inheritdoc} |
| 27 | + */ |
| 28 | + public function getName(): string |
| 29 | + { |
| 30 | + return 'VTCPay'; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * {@inheritdoc} |
| 35 | + */ |
| 36 | + public function initialize(array $parameters = []) |
| 37 | + { |
| 38 | + return parent::initialize( |
| 39 | + $this->normalizeParameters($parameters) |
| 40 | + ); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * {@inheritdoc} |
| 45 | + * @return \Omnipay\Common\Message\AbstractRequest|PurchaseRequest |
| 46 | + */ |
| 47 | + public function purchase(array $options = []): PurchaseRequest |
| 48 | + { |
| 49 | + return $this->createRequest(PurchaseRequest::class, $options); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * {@inheritdoc} |
| 54 | + * @return \Omnipay\Common\Message\AbstractRequest|CompletePurchaseRequest |
| 55 | + */ |
| 56 | + public function completePurchase(array $options = []): CompletePurchaseRequest |
| 57 | + { |
| 58 | + return $this->createRequest(CompletePurchaseRequest::class, $options); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Khởi tạo IPN request tiếp nhận từ VTCPay gửi sang. |
| 63 | + * |
| 64 | + * @return \Omnipay\Common\Message\AbstractRequest|NotificationRequest |
| 65 | + */ |
| 66 | + public function notification(array $options = []): NotificationRequest |
| 67 | + { |
| 68 | + return $this->createRequest(NotificationRequest::class, $options); |
| 69 | + } |
| 70 | +} |
0 commit comments