bankette / omnipay-hipay
此包的最新版本(v1.0)没有提供许可信息。
在Omnipay中集成Hipay
v1.0
2016-06-28 08:58 UTC
Requires
- php: >=5.3.2
- omnipay/omnipay: ~2.0
This package is not auto-updated.
Last update: 2024-09-18 19:00:43 UTC
README
hipay的Omnipay网关。
此代码需要改进,但它是将hipay集成到您的Omnipay中的良好基础。请随意分支并提交PR来改进此库。
购买
以下是一个symfony发送购买请求到hipay的代码示例。
use Bankette\OmnipayHipay\Gateway; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; /** * Payment by hipay Action. * * @return Response */ public function hipayPaymentAction(SymfonyRequest $request) { $data = [ 'orderid' => 'my-order-id', 'amount' => 10, 'currency' => 'EUR', 'card' => [ 'number' => '4000000000000002', 'expiryMonth' => '10', 'expiryYear' => '2020', 'cvv' => '123', ], 'cardtype' => 'visa', 'description' => 'description', ]; $gateway = new Gateway(); $gateway->setClientId($this->username); $gateway->setSecret($this->password); $gateway->setTestMode(true); $purchaseResponse = $gateway->purchase($data)->send(); if (!$purchaseResponse->isSuccessful() && !$purchaseResponse->isRedirect()) { throw new BadRequestHttpException($purchaseResponse->getError()); } if ($purchaseResponse->isSuccessful()) { // Payment validated } if ($purchaseResponse->isRedirect() && $purchaseResponse->getRedirectUrl()) { // Payment waiting for 3D secure validation } // ... }
通知
购买请求后,hipay将在hipay后台定义的“通知URL”上发送通知。以下控制器将被hipay API直接调用到您的API上。
/** * @return Response * * @Route("/hipay/notify") * * @Method("POST") * * @View() * * @throws NotFoundHttpException */ public function hipayNotifyAction(SymfonyRequest $request) { $gateway = new Gateway(); $response = $gateway->completePurchase(); switch ($response->getStatus()) { // Status "Cardholder Enrolled" case '103': // Status "Cardholder Not Enrolled" case '104': // Status "Authorized" case '116': // Status "Capture Requested" case '117': // do something break; // Status "Captured" case '118': // do something break; // Status "Could Not Authenticate" case '108': // Status "Authentication Failed" case '109': // Status "Refused" case '113': // Status "Expired" case '114': // do something break; default: // do something break; } return new Response(); }