定制 forci/epay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

forci/epay

Composer 安装命令:

composer require forci/epay

包简介

Library for epay.bg

README 文档

README

TODO

  • Tests

Usage

  • Create a Forci\Component\Epay\Client\ClientOptions instance, responsible for providing all the options the Forci\Component\Epay\Client\Client needs. Its constructor needs the merchant ID and secret, provided by epay.bg. Remember to set the third constructor parameter to true or false depending on whether you're testing or not.
  • Create a handler that implements the Forci\Component\Epay\Client\PaymentHandlerInterface interface. This interface has methods that are being called by the client
  • Create an instance of Forci\Component\Epay\Client\Client, passing the above two
  • To create a payment form, call $client->getEpayForm($id, $amount, $description, $expiry, $formId, $okUrl, $cancelUrl)
  • To create an EasyPay payment ID, call $response = $this->client->getEasyPayIdn($id, $amount, $description, $expiry). This will return a Forci\Component\Epay\Response\EasyPayResponse response. Call $response->getIdn() to get the ID. Beware, this method throws a Forci\Component\Epay\Exception\EasyPayGetIdnError exception.

The WucdbmEpayBundle https://packagist.org/packages/wucdbm/epay-bundle uses this library, head there for more examples.

$options = new \Forci\Component\Epay\Client\ClientOptions($merchantId, $merchantSecret, $isDebug);
// $options->set... to alter any options
$handler = new \My\Project\Payments\Epay\PaymentHandler(LogManager $some, PaymentManager $dependencies);
$client = new \Forci\Component\Epay\Client\Client($options, $handler);

Getting a payment form is done like this

$uniqId = uniqid(); // this is to make autosubmitting easy - $('#formId').submit();
$expiry = new \DateTime('today + 2 days');
// ... other parameters
$form = $client->getEpayForm($id, $amount, $description, $expiry, $formId, $okUrl, $cancelUrl);
// Display the form and optionally auto submit it. Another option is to alter the submit button through the options and let the user do that

Getting an EasyPay IDN

$id = $payment->getId();
$amount = $payment->getAmount();
$description = 'Payment #' . $payment->getId();
$expiry = $payment->getExpiryDate();

try {
    $response = $this->client->getEasyPayIdn($id, $amount, $description, $expiry);
    $idn = $response->getIdn();
    // display idn to the user, do some logging.
    // the response body is available at $response->getBody();
    return $idn;
} catch (\Forci\Component\Epay\Exception\EasyPayGetIdnError $ex) {
    $this->logEasyPayRequest($payment, $ex->getBody(), true);
    throw $ex;
}

Receiving payments

$response = $client->receiveResponse($post);
// the client will call your handler, which must deal with the payments received
// $response is an \Forci\Component\Epay\Response\ReceiveResponseInterface instance
// exceptions are caught internally and transformed into responses, the no data exception and checksum mismatch exceptions in particular generate a global error response for epay
echo $response->toString();
exit();
// alternatively, if you use Symfony's HttpFoundation component
$response = \Symfony\Component\HttpFoundation\Response($response->toString());

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固