thanhvo-cse/worldpay

Worldpay API 的 PHP 库

v1.4.0 2023-12-14 07:43 UTC

This package is auto-updated.

Last update: 2024-09-14 09:41:11 UTC


README

连接到 Worldpay API。

安装

Composer
composer require thanhvo-cse/worldpay
事件
  • 定义你的观察者
use ThanhVo\Worldpay\WPG\Client;

class BeforeRequestListener implements ThanhVo\Worldpay\Event\ObserverInterface
{
/**
     * @return string
     */
    public function getSubject(): string
    {
        return Client::EVENT_BEFORE_REQUEST;
    }

    /**
     * @param $data
     * @return mixed
     */
    public function onEvent($data)
    {
        // Handle your Observer here
        var_dump($data);
    }
}
  • 添加你的观察者
$hosted = new \ThanhVo\Worldpay\WPG\Service\Hosted();
$beforeObserver = new BeforeRequestListener();
$hosted->addEventObserver($beforeObserver);
...
事件列表
  • before_request
  • after_response

文档

https://developer.worldpay.com/docs/wpg

示例

示例位于 sample 目录中。请在那里找到 README 文件。