定制 conedevelopment/bazar-stripe 二次开发

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

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

conedevelopment/bazar-stripe

最新稳定版本:v1.3.2

Composer 安装命令:

composer create-project conedevelopment/bazar-stripe

包简介

Stripe payment integration for Bazar.

README 文档

README

Installation

composer require conedevelopment/bazar-stripe

Configuration

.env

STRIPE_TEST_MODE=
STRIPE_API_KEY=
STRIPE_SECRET=

Bazar Config

    // config/bazar.php

    'gateway' => [
        'drivers' => [
            // ...
            'stripe' => [
                'test_mode' => env('STRIPE_TEST_MODE', false),
                'api_key' => env('STRIPE_API_KEY'),
                'secret' => env('STRIPE_SECRET'),
            ],
        ],
    ],

    // ...

Webhook Events

php artisan make:listener StripeWebhookHandler
namespace App\Listeners;

use Cone\Bazar\Stripe\WebhookInvoked;
use Stripe\Event;

class StripeWebhookHandler
{
    public function handle(WebhookInvoked $event): void
    {
        // https://stripe.com/docs/api/events/types
        $callback = match ($event->event->type) {
            'payment_intent.payment_failed' => function (Event $event): void {
                // mark transaction as failed
            },
            'payment_intent.succeeded' => function (Event $event): void {
                // mark transaction as completed and order as paid
            },
            default => function (): void {
                //
            },
        };

        call_user_func_array($callback, [$event->event]);
    }
}

Tip

If Event Discovery is disabled, make sure the listener is bound to the WebhookInvoked event in your EventServiceProvider.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-06