codebuglab/noon-payment-laravel
最新稳定版本:v0.0.8
Composer 安装命令:
composer require codebuglab/noon-payment-laravel
包简介
Integrate noon payment API with Laravel
README 文档
README
Integrate NoonPayment API with Laravel
Table of contents
Setup
Installation
To install this package through composer run the following command in the terminal
composer require codebuglab/noon-payment-laravel
Config
Refer to Noon docs to get your info then add them to .env file
NOON_PAYMENT_BUSINESS_ID=
NOON_PAYMENT_APP_NAME=
NOON_PAYMENT_APP_KEY=
NOON_PAYMENT_TOKEN_IDENTIFIER=
NOON_PAYMENT_RETURN_URL=http://127.0.0.1:8000/noon_payment_response
# Change the mode to Live for the Production or set it as Test
NOON_PAYMENT_MODE=Test
# Pre-configured order route categories (the categories will be mentioned also in the initial setup email)
NOON_PAYMENT_ORDER_CATEGORY=
# Channels are pre-defined and limited to Web / Mobile (the channels will be mentioned also in the initial setup email)
NOON_PAYMENT_CHANNEL=web
# Default value - Payment API Endpoint - Chooses
# https://api.noonpayments.com/payment/v1/
# https://api-test.noonpayments.com/payment/v1/
NOON_PAYMENT_PAYMENT_API=https://api-test.noonpayments.com/payment/v1/
Publish (optional)
Run this command in terminal to publish package files in your app
php artisan vendor:publish --provider="CodeBugLab\NoonPayment\NoonPaymentServiceProvider"
This will publish 2 files
1- App/Http/Controllers/NoonPaymentController.php 2- config/noon_payment.php
- Feel free to change
noon_payment.phpconfig file and set package configuration on this file instead of.envif you want - If you don't need the config file you can run this command instead
php artisan vendor:publish --provider="CodeBugLab\NoonPayment\NoonPaymentServiceProvider" --tag=controller
NoonPaymentController.phpis a simple example to use it in your project, consider it as a demo.
Routes (optional)
This package has two routes using NoonPaymentController.php file
- Create payment page:
http://yourwebsite/noon_payment
Which call function ( NoonPaymentController@index ) by GET Request
- Receiving response
http://yourwebsite/noon_payment_response
Which receive a GET response through function ( NoonPaymentController@response )
Test Card
the link for test cards by official documentation => Test Cards
Available API Methods
Initiate
- This will initiate new order.
$data =[ "order" => [ "reference" => "1", "amount" => "10", "currency" => "SAR", "name" => "Sample order name", ], "configuration" => [ "locale" => "en" ] ] $response = NoonPayment::getInstance()->initiate($data);
- Simply you can use response and redirect to pay page through this code
if ($response->resultCode == 0) { return redirect($response->result->checkoutData->postUrl); }
- After sitting your payment information or cancel the process you will go to response page
- Remember you set it up earlier in
.envfile like this
NOON_PAYMENT_RETURN_URL=http://127.0.0.1:8000/noon_payment_response
- For more information about request and response for initiate visit documentation ( Payment Initiate )
Get Order
- This will get your order information by order id that retrieved by initiate function
$response = NoonPayment::getInstance()->getOrder($orderId);
- Simply you can check if transaction is success by using
$responsevariable like this
if ( $response->result->transactions[0]->type == "SALE" && $response->result->transactions[0]->status == "SUCCESS" ) { //success Message }
- For more information about response and request for initiate visit documentation ( Payment Get Order )
Notices
- If you facing any problems using this package try use Publish and Routes this will give you a simple example in
NoonPaymentController.phpfile. - If you want to make
RefundorCancelfor order then this package doesn't provide these methods yet, So we highly recommend to read full Documentation before try this and making a pull request.
License
This package is a free software distributed under the terms of the MIT license.
统计信息
- 总下载量: 7.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-21
