coreproc/paymaya-laravel
Composer 安装命令:
composer require coreproc/paymaya-laravel
包简介
Paymaya SDK for Laravel
README 文档
README
Paymaya SDK for Laravel
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
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
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.
<?php return [ 'webhooks' => [ 'payment_success' => 'hooks.paymaya.success', 'payment_failed' => 'hooks.paymaya.failed', 'payment_expired' => 'hooks.paymaya.expired', ], ];
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.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-20