maree-sewidan/hyper-pay

使用 hyper pay 支付网关进行支付的包

dev-main 2024-05-21 11:33 UTC

This package is auto-updated.

Last update: 2024-09-21 12:12:02 UTC


README

安装

您可以通过 Composer 安装此包。

composer require maree-sewidan/hyper-pay

使用以下命令发布您的 hyper-pay 配置文件

php artisan vendor:publish --provider="maree\hyperPay\HyperPayServiceProvider" --tag="hyperPay"

然后更改配置文件中的 hyperPay 配置

	
	"mode" => "test" , // test||live
    "token" =>  "",
    "entityIds" => [
        'VISA MASTER' => "",
        'STC_PAY'     => "",
        'MADA'        => "",
        'APPLEPAY'    => "",
        'AMEX'        => ""
    ],

用法

第一步

use maree\hyperPay\HyperPay;
$customerInfo = ['email' => 'm7mdmaree26@gmail.com' , 'country' => 'EG' , 'givenName' => 'mohamed maree' ,'surname' => 'mohamed maree' , 'street1' => '23 elmagd' ,'city' => 'almehalla' ,'state' => 'gharbia' , 'postcode' => '1234'];
$brand = 'VISA MASTER'; //you can use 'VISA MASTER' or 'STC_PAY' or 'MADA' or 'APPLEPAY' or 'AMEX'
$response = HyperPay::checkout($amount = 1.0 ,$brand, $customerInfo);  

注意

  • 使用 'VISA MASTER' 作为一种品牌或密钥,而不是两种不同的品牌或密钥
  • 此函数返回 ['checkoutId' => $checkoutId , 'responseData' => $responseData]
  • 使用 checkoutId 在数据库中保存交易
  • 在下一步中,在视图页面中使用 checkoutId

第二步

  • 返回包含 $checkoutId 的视图页面以显示支付过程
    <style>
        .wpwl-container{
            z-index: 99;
            color : rgb(15, 13, 13);
        }
        .wpwl-control, .wpwl-group-registration{
            color:#333;
        }
        .pay-link{
            position: relative;
            z-index: 99;
        }
        .pay-link ul{
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .pay-link ul li{
            margin: 10px;
        }
        .pay-link ul li img{
            width: 120px;
            height: 50px;
            max-width: 100%;
        }
        .wpwl-group{
            direction:ltr;
        }
        .wpwl-control-cardNumber{
            direction:ltr !important;
            text-align:right;
        }        
    </style>
    <!--  //you can use 'VISA MASTER' or 'STC_PAY' or 'MADA' or 'APPLEPAY' or 'AMEX' -->
    <form action="{{route('show-response-route')}}" class="paymentWidgets" data-brands="VISA MASTER"></form>
    <script>
        var wpwlOptions = {
            locale: "ar",
            paymentTarget:"_top",
        }
    </script>
    @if (config('hyperPay.mode') == 'live') 
        <script src="{{config('hyperPay.view_live_url').$checkoutId}}"></script>
    @else{
        <script src="{{config('hyperPay.view_test_url').$checkoutId}}"></script>
    @endif

注意

  • 为响应 URL 创建路由 'show-response-route',例如:Route::get('show-response-route', 'PaymentsController@paymentresponse')>name('show-response-route');
  • 为结账响应创建函数 'paymentresponse'
  • 使用该函数检查支付是否失败或成功

在 'paymentresponse' 函数内部使用

use maree\hyperPay\HyperPay;
//$brand = 'VISA MASTER';// || STC_PAY || MADA || APPLEPAY || AMEX
// $transactionid = $request->resourcePath;
$response = HyperPay::checkoutResponseStatus($transactionid,$brand);  

返回类似以下的内容

['key' => 'success' , 'msg'=> $description ,'checkoutId' => $checkoutId , 'responseData' => $responseData]  

['key' => 'fail'    , 'msg'=> $description ,'checkoutId' => $checkoutId , 'responseData' => $responseData];

注意:您可以使用响应数据中的数据将交易保存到数据库中

  • 测试卡详情
  • 卡号:Visa:4111111111111111
  • CVV:123
  • 到期日期:05/22
  • 卡名:Test Family

APPLEPAY 注意

  • 在 apple pay 中,您会从 hyperpay 收到文本文件,然后将该文件放入您项目中的 public/.well-known 目录中,无需更改该文件名
  • 您必须使用 apple 设备来检查它是否成功工作
  • 您必须存在于提供 apple pay 付款的国家/地区

当前 hyperpay 包支持的支付方式

  • visa
  • master
  • mada
  • stc
  • apple pay
  • AMEX