定制 mblsolutions/paypoint-notification 二次开发

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

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

mblsolutions/paypoint-notification

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mblsolutions/paypoint-notification

包简介

PayPoint Notification package

README 文档

README

PayPoint notification package

Installation

The recommended method to install LaravelRepository is with composer

php composer require mblsolutions/paypoint-notification

Laravel without auto-discovery

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

\MBLSolutions\Notification\NotificationServiceProvider::class,

Package configuration

Copy the package configuration to your local config directory.
php artisan vendor:publish --tag=notification-config

Database Driver

If you would like to use the Database driver to store your notification logs, you will first need to create and run the database driver migration.

php artisan paypoint-notification:database:table

This will create a new migration in database/migrations, after creating this migration run the database migrations to create the new table.

php artisan migrate

Usage

The configuration and setup can be adjusted in the notification config file located in config/notification.php. We recommend reading through the config file before enabling notification to ensure you have the optimum setup.

Enable Notification Service

In environment setting, you need to change MAIL_MAILER from smtp to paypoint to enable the service. The endpoint and credentials is neede to add in your .env file.

MAIL_MAILER=paypoint
PP_NOTIFICATION_endpoint=https://ENDPOINT_URL
PP_NOTIFICATION_SUBSCRIPTION_KEY=xxxxxxxxxxx

Template Setup

The template should be generated manually via the endpoint and an existing template id that is needed. If any field in request body that needs to validate before sending it to endpoint, a rule needs to specify for that template.

'template' => [
        'default_id' => env('TEMPLATE_ID','xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1'),
    ],

This can also be set in your .env file by using the corresponding environment variable

TEMPLATE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1

Notification Setup

In application, you need to use or replace a new PayPointMailMessage which are wrapped the value of 'X-Template-Request-Body' and 'X-Template-Id'.

class SendEmail extends Notification implements ShouldQueue
{
    //... construct method

    public function toMail($notifiable)
    {
        return (new PayPointMailMessage(
                    //Change the template id if not default
                    config('notification.template.default_id'),
                    //Request Body
                    [   
                        'CallbackUrl' => '',
                        'Model' =>
                            [
                            'NotificationModel' =>
                                [
                                    'Recipients' =>
                                    [
                                        [
                                            'Name' => 'Test Customer',
                                            'Email' => 'test@test.com'
                                        ]
                                    ],
                                    /* .. */
                                ]
                            ]                 
                        ]
                ));
    }
}

Enable user information for logging in job

If you would like to have user information in notification logs, you need to set user in authentication as in the example below:

class SendEmail extends Notification implements ShouldQueue
{
    //... construct method

    public function toMail($notifiable)
    {
        return (new PayPointMailMessage(/* .. */))
                ->withUser($notifiable);
    }
}

Optional validation for request body

If any field in request body that needs to validate before sending it to endpoint, a rule needs to add in notification.php config file as in the example below:

'template' => [
        //Optional validation array with template id as key
        //The rule depends on what is the matched validation field in array from the above example of notification setup. e.g. $data
        'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1' => [
            'validation_rule' => [
                'Model.NotificationModel.Recipients.*.Name' => ['required', 'string', 'max:255'],
                'Model.NotificationModel.Recipients.*.Email' => ['required', 'email', 'max:255'],
            ],
        ]
    ],

License

Notification is free software distributed under the terms of the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-08-22