gamevault/lunar-pensopay

A Lunar community payment driver for Pensopay


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Easily integrate Pensopay into Lunar with the community payment driver for Pensopay. This integration are based on PensoPay API docs

ToDo

There is still some minor stuff to take into consideration

  • Defining success_url, cancel_url and callback_url urls with id params in the urls.
  • Dynamic selection of facilitator (payment types: creditcard, viabill, expressbank, paypal and anyday).
  • Tests.

Installation

You can install the package via composer:

composer require gamevault/lunar-pensopay

This package uses the spatie laravel-webhook-client package to handle the callbacks sent from Pensopay.

You can publish the configs and run the migrations with:

php artisan vendor:publish --tag="lunar-pensopay-config"
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-config"
php artisan migrate

This is the contents of the published pensopay config file:

return [
    'policy' => env('AUTO_CAPTURE', false),
    'url' => env('PENSOPAY_URL', 'https://api.pensopay.com/v1'),
    'token' => env('PENSOPAY_TOKEN'),
    'testmode' => env('PENSOPAY_TESTMODE', false),
];

The webhook-client.php should look like the following:

<?php

return [
    'configs' => [
        [
            'name' => 'pensopay-webhook',
            'signing_secret' => config('PENSOPAY_SIGNING_SECRET'),
            'signature_header_name' => 'pensopay-signature',
            'signature_validator' => \Spatie\WebhookClient\SignatureValidator\DefaultSignatureValidator::class,
            'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class,
            'webhook_response' => \Spatie\WebhookClient\WebhookResponse\DefaultRespondsTo::class,
            'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class,
            'process_webhook_job' => \Gamevault\Pensopay\Jobs\ProcessPensopayCallbackJob::class,
        ],
    ],

    /*
     * The integer amount of days after which models should be deleted.
     *
     * 7 deletes all records after 1 week. Set to null if no models should be deleted.
     */
    'delete_after_days' => 30,
];

The webhook endpoint can be defined anywhere in the route files with the following:

Route::webhooks('pensopay-webhook', 'pensopay-webhook');

Usage

To get started, the payment driver must be registered at the AppServiceProvider:

public function register()
{
    Payments::extend('pensopay', function ($app) {
       return $app->make(\Gamevault\Pensopay\PensopayPaymentType::class);
    });
}

The payment methods can be invoked like the following:

/** @var Pensopay $paymentDriver */
$paymentDriver = Payments::driver('pensopay');
$paymentDriver->cart($cart);
$paymentAuthorize = $paymentDriver->authorize();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.