dansmaculotte/laravel-omnipay

Laravel的Omnipay服务提供商

v4.0.0 2022-03-10 08:52 UTC

This package is auto-updated.

Last update: 2024-09-29 06:02:39 UTC


README

Latest Version Total Downloads Build Status Quality Score Code Coverage

此包允许您在Laravel中使用Omnipay

安装

要求

  • PHP 7.4

您可以通过composer安装此包

composer require dansmaculotte/laravel-omnipay

该包将自动注册自己。

要发布配置文件到config/omnipay.php,请运行

php artisan vendor:publish --provider="DansMaCulotte\Omnipay\OmnipayServiceProvider"

用法

$params = [
    'amount' => $order->amount,
    'issuer' => $issuerId,
    'description' => $order->description,
    'returnUrl' => URL::action('PurchaseController@return', [$order->id]),
];
$response = Omnipay::purchase($params)->send();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
    return $response->getRedirectResponse();
}

if ($response->isSuccessful() === false) {
    // payment failed: display message to customer
    echo $response->getMessage();
}

// payment was successful: update database
print_r($response);

您可以使用以下命令更改默认网关

OmnipayFacade::setDefaultGateway('Stripe');

或者临时更改网关

Omnipay::withGateway('Dummy')->purchase($params)->send();

测试

composer test

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

贡献

有关详细信息,请参阅CONTRIBUTING

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。