jchegenye/mypesapal

为您的Laravel应用提供简化的PesaPal集成。

v1.0.1 2019-04-08 08:27 UTC

This package is auto-updated.

Last update: 2024-09-23 04:42:49 UTC


README

为您的Laravel应用提供简化的PesaPal集成。

安装

通过Composer

composer require jchegenye/mypesapal

用法

将此类添加到您的控制器中。

use App\Http\JTech\PesaPal\PesaPalIframe;

运行此vendor:publish命令以发布PesaPal配置文件。

What's inside config file?

    1. Application Environment:

        | Pesapal will utilize this option to determine which 
        | mode your App is running, either Sandbox or Live
        |
        | Local - Means your App is running on a Sandbox Mode.
        | Production - Means your App is running on a Live Mode

    2. Authentication / Configuration

        | 'token_params' => NULL,
        | 'consumer_key' => env('PESAPAL_CONSUMER_KEY', '*** CONSUMER KEY ***'),
        | 'consumer_secret' => env('PESAPAL_CONSUMER_SECRET', '*** YOUR CONSUMER SECRET ***'),
        | 'live_iframelink' => 'https://www.pesapal.com/API/PostPesapalDirectOrderV4',
        | 'demo_iframelink' => 'http://demo.pesapal.com/api/PostPesapalDirectOrderV4'

    3. Define the callback_url

        | This is the full url pointing to the page the iframe redirects to 
        | after processing the order on pesapal.com

        'callback_url' => env('PESAPAL_CALLBACK_URL', 'http://test.com/payment-gateways-php/pesapal-php/'),

    4. Field Names

        | You may wish for to select prefered form details posted by your 
        | App to be used by pesapal.
        |
        | You can add more `Fields` here if you wish.
        |
        | NOTE: default value = MERCHANT

        'fields' => [

            'amount' => 'number_format(PESAPAL_FIELD_AMOUNT, 2)', //format amount to 2 decimal places
            'description' => 'PESAPAL_FIELD_DESC',
            'type' => 'MERCHANT', //default value = MERCHANT
            'reference' => 'PESAPAL_FIELD_REF', //unique order id of the transaction, generated by merchant
            'first_name' => 'PESAPAL_FIELD_FNAME',
            'last_name' => 'PESAPAL_FIELD_LNAME',
            'email' => 'PESAPAL_FIELD_EMAIL',
            'phonenumber' => 'PESAPAL_FIELD_PHONE' //ONE of email or phonenumber is required

        ]

要返回PesaPal Response,使用此pesapal()方法。

为了让PesaPal获取当前HTTP Request的实例,添加此$request变量。

请参阅以下示例

response()->pesapal($request);