PHP code example of lloricode / laravel-maya-sdk

1. Go to this page and download the library: Download lloricode/laravel-maya-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lloricode / laravel-maya-sdk example snippets




declare(strict_types=1);

use Lloricode\Paymaya\Enums\Environment;
use Lloricode\Paymaya\Enums\Webhook;

/**
 * @todo: Manage Exception using laravel logs, allow set config log files
 */

return [
    'mode' => env('MAYA_MODE', Environment::Sandbox->value),
    'keys' => [
        'public' => env('MAYA_PUBLIC_KEY'),
        'secret' => env('MAYA_SECRET_KEY'),
    ],

    /**
     * Webhooks
     */
    'webhooks' => [
        Webhook::CHECKOUT_SUCCESS => 'api/payment-callback/maya/success',
        Webhook::CHECKOUT_FAILURE => 'api/payment-callback/maya/failure',
        Webhook::CHECKOUT_DROPOUT => 'api/payment-callback/maya/dropout',

        //        Webhook::PAYMENT_SUCCESS => 'api/test/success',
        //        Webhook::PAYMENT_EXPIRED => 'api/test/expired',
        //        Webhook::PAYMENT_FAILED => 'api/test/failed',
    ],

    'checkout' => [
        'customization' => [
            'logoUrl' => 'https://image1.png',
            'iconUrl' => 'https://image2.png',
            'appleTouchIconUrl' => 'https://image3.png',
            'customTitle' => 'test maya sandbox title',
            'colorScheme' => '#e01c44',
            'redirectTimer' => 3,
            //            'hideReceiptInput' => true,
            //            'skipResultPage' => false,
            //            'showMerchantName' => true,
        ],
    ],
];


    
    use Lloricode\Paymaya\Requests\Checkout\CreateCheckoutRequest;
    use Saloon\Http\Faking\MockClient;
    use Saloon\Http\Faking\MockResponse;

    /**
     * @test
     */
    public function success_checkout() 
    {
            $paymayaID = 'test-maya-generated-id';
            $paymayaRedirectUrl = 'http://test-maya/redirect-url';
    
            MockClient::global([
                CreateCheckoutRequest::class => new MockResponse(
                    body: [
                        'checkoutId' => $paymayaID,
                        'redirectUrl' => $paymayaRedirectUrl,
                    ]
                ),
            ]);
            
           // your test
          

bash
php artisan vendor:publish --provider="Lloricode\LaravelPaymaya\LaravelPaymayaServiceProvider" --tag="maya-sdk-config"