PHPackages                             coreproc/paymaya-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. coreproc/paymaya-laravel

ActiveLibrary[Payment Processing](/categories/payments)

coreproc/paymaya-laravel
========================

Paymaya SDK for Laravel

1.1.0(5y ago)314MITPHPPHP ^7.4

Since Oct 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/CoreProc/paymaya-laravel)[ Packagist](https://packagist.org/packages/coreproc/paymaya-laravel)[ Docs](https://github.com/coreproc/paymaya-laravel)[ RSS](/packages/coreproc-paymaya-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Paymaya SDK for Laravel
=======================

[](#paymaya-sdk-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dd5a44fa72e6c0529cece9fa6d06430b9be6e70b2eeef2bed9e60c365d8c95c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f726570726f632f7061796d6179612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coreproc/paymaya-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/045c155912f7af4b0ccc4f2eb69a150e0ddc767fe214a1f6c8e5d4cad283402f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636f726570726f632f7061796d6179612d6c61726176656c2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/coreproc/paymaya-laravel/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/e52a4849a8bf004c4c1302830aa26cec662b702c5fe143c7d234d90b9cb99058/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f726570726f632f7061796d6179612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coreproc/paymaya-laravel)

Paymaya SDK for Laravel

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require coreproc/paymaya-laravel
```

You can publish and run the migrations with:

You can publish the config file with:

```
php artisan vendor:publish --provider="Coreproc\Paymaya\PaymayaServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [

    'environment' => env('PAYMAYA_ENVIRONMENT', PayMayaClient::ENVIRONMENT_SANDBOX),

    'key' => env('PAYMAYA_KEY'),

    'secret' => env('PAYMAYA_SECRET'),

    'webhooks' => [

        'checkout_success' => env('PAYMAYA_WEBHOOKS_CHECKOUT_SUCCESS'),

        'checkout_failure' => env('PAYMAYA_WEBHOOKS_CHECKOUT_FAILURE'),

        'checkout_dropout' => env('PAYMAYA_WEBHOOKS_CHECKOUT_DROPOUT'),

        'payment_success' => env('PAYMAYA_WEBHOOKS_PAYMENT_SUCCESS'),

        'payment_failed' => env('PAYMAYA_WEBHOOKS_PAYMENT_FAILED'),

        'payment_expired' => env('PAYMAYA_WEBHOOKS_PAYMENT_EXPIRED'),

    ],

];
```

Usage
-----

[](#usage)

### Creating a payment

[](#creating-a-payment)

```
use CoreProc\PayMaya\PayMayaClient;
use CoreProc\PayMaya\Requests\Address;
use Coreproc\PaymayaLaravel\Builders\PaymayaCheckoutBuilder;
use Coreproc\PaymayaLaravel\Facades\PaymayaCheckoutClientFacade;

$checkout = PaymayaCheckoutBuilder::make()
    ->setCurrency('PHP')
    ->setItem($paymayaItemModel, 1)
    ->setDiscount(1000)
    ->setServiceCharge(1001)
    ->setShippingFee(1002)
    ->setTax(1003)
    ->setBuyerFirstName('Juan')
    ->setBuyerMiddleName('D')
    ->setBuyerLastName('Dela Cruz')
    ->setBuyerContactPhone('09171231234')
    ->setBuyerContactEmail('juan@gmail.com')
    ->setBuyerShippingAddress(Address::make()->setLine1('123 Daan')->setCity('Quezon City'))
    ->setBuyerBillingAddress(Address::make()->setLine1('456 Highway')->setCity('Makati City'))
    ->setReferenceNumber('100')
    ->setRedirectUrlSuccess('https://yoursite.com/success')
    ->setRedirectUrlFailure('https://yoursite.com/failure')
    ->setRedirectUrlCancel('https://yoursite.com/cancel')
    ->build();

$response = PaymayaCheckoutClientFacade::post($checkout);

$result = PayMayaClient::getDataFromResponse($response);

return redirect()->to($result->redirectUrl);
```

### Installing the webhooks

[](#installing-the-webhooks)

```
php artisan paymaya:install-webhook

```

This command will register all webhooks defined in the configuration file. To register only the webhooks you need, remove webhooks from the array.

You can also refer to the webhook's callback URL using the route name.

```
