xlabs / epochbundle
Epoch包装包
Requires
- php: >=5.6
- knplabs/knp-paginator-bundle: ^2.6
- symfony/symfony: >=3.4
- xlabs/mmadminbundle: ^2.0
This package is auto-updated.
Last update: 2024-09-21 13:57:47 UTC
README
一个EPOCH回传包装器。
安装
通过Composer安装
php -d memory_limit=-1 composer.phar require xlabs/epochbundle
在你的AppKernel中
public function registerbundles()
{
return [
...
...
new XLabs\EpochBundle\XLabsEpochBundle(),
];
}
为了使这个包正常工作,EpochTransStats和MemberCancelStats需要设置为HTTPS方法,而不是MYSQL方法。你可能需要联系Epoch支持来启用此设置。
路由
追加到主路由文件
# app/config/routing.yml
x_labs_epoch:
resource: .
type: xlabs_epoch_routing
配置示例
以下显示默认值
# app/config/config.yml
x_labs_epoch:
# postbacks will go to <url><postback_url>
url: https://www.yourdomain.com
postback_url: /your/epoch/postback/url (default '/epoch/postback')
return_url: /your/epoch/response/url (default '/epoch/response')
stats_url: /your/epoch/stats/url (default '/epoch/stats')
logging:
enabled: true
location: '%kernel.logs_dir%/'
allowed_ips: ['127.0.0.1', '192.168.1.10', '60.58.43.125', ...]
api:
url: 'https://wnu.com/secure/services/'
reseller: 'a'
epoch_digest_key: '<your_epoch_hmac_key>'
mail_notifications:
enabled: true|false
subject: '' # descriptive prefix for the notifications subject
from: '' # useful to apply a gmail label for the notifications
destinataries: []
重要
确保创建一个每日cronjob来拉取Epoch IP
(0 8 * * *) php bin/console xlabs:epoch:update_ips
你仍然可以使用配置参数"allowed_ips"来配置其他允许的IP。
注意:$_SERVER['SERVER_ADDR']的值默认允许,因此不需要将其包含在'allowed_ips'数组中。
此外,确保咨询支持关于"S"交易类型,以避免当数据回传在CamCharge交易之后出现问题时。为了使CamCharge工作,我们还需要要求摘要代码。
事件监听器
以下事件基于epoch回传触发
SYNCHRONOUS (fired by flexpost):
epoch.sync.join.event
SYNCHRONOUS (fired by memberplus):
epoch.sync.join_channel.event
ASYNCHRONOUS (fired by dataplus):
epoch.async.join.event
epoch.async.join_channel.event
epoch.async.rebill.event
epoch.async.rebill_channel.event
epoch.async.chargeback.event
epoch.async.chargeback_channel.event
epoch.async.refund.event
epoch.async.refund_channel.event
epoch.async.cancel.event
epoch.async.purchase.event
SYNCHRONOUS (fired by camcharge):
epoch.sync.purchase.event
SYNCHRONOUS (fired by unkown):
epoch.async.reactivation.event
在同步/异步事件中,如果交易被拒绝,将触发以下事件
epoch.error.event
在epoch响应时,将触发2个事件,具体取决于响应
epoch.response_success.event
epoch.response_failed.event
例如,您可以使用"epoch.response_success.event",来重新加载用户会话并添加他的新购买。
如果您想为其中任何一个注册事件监听器
# YourBundle/Resources/config/services.yml
...
custom_listener_for_epoch_onPostback.event_listener:
class: YourBundle\EventListener\MyListener
tags:
- { name: kernel.event_listener, event: epoch.join.event, method: yourCustomMethod }
namespace YourBundle\EventListener;
use Symfony\Component\EventDispatcher\Event;
class MyListener extends Event
{
public function yourCustomMethod(Event $event)
{
$params = $event->getParams(); // all params sent by epoch
...
$event->setResponse('OK');
/*
OR
*/
$event->setResponse('KO - <ERR MSG>');
}
}
如果监听器中没有设置响应,则默认输出为'OK'。
返回URL参数
如果您想覆盖"感谢/交易拒绝"模板,可以通过覆盖以下模板来实现
XLabsEpochBundle::response.html.twig
XLabsEpochBundle::success.html.twig
XLabsEpochBundle::error.html.twig
以下变量被发送到模板
- 在成功的交易中
status = "SUCCESS" message -> (empty string)
- 在失败的交易中
status = "ERROR" message -> (string containing a descriptive error)
待办事项
- 在xlabs_epoch.twig_extension的twig扩展中使用需要的依赖项(而不是容器)。
- 除非自定义查询字符串参数被设置,否则只允许交易一次,在这种情况下交易将通过。
测试
请使用以下测试卡号来测试批准和拒绝
4121371122223333 / 任何有效的到期日 5123456789012346 / 任何有效的到期日
为了模拟批准,您需要使用'111'作为CVV2。为了模拟拒绝,可以使用'567'作为CVV2。
但是您必须使用办公室代理IP,它是受保护的IP,是他们完全白名单的唯一IP。