vmdevelopment / myfatoorah-laravel
Myfathoorah REST API 包
dev-master
2019-01-25 19:11 UTC
Requires
- php: ^7.1
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: >=6.0
- illuminate/support: 5.6.*|5.7.*|5.8.*
This package is auto-updated.
Last update: 2024-09-26 07:58:38 UTC
README
Myfatoorah Payment Gateway for Laravel 5*
安装
将 vmdevelopment/myfatoorah-laravel
添加到您的 composer.json
文件中。
"vmdevelopment/myfatoorah-laravel": "~1.0.*"
运行 composer update
以拉取包的最新版本。
或者简单地运行
composer require "vmdevelopment/myfatoorah-laravel"
现在打开 /config/app.php
并将服务提供者添加到您的 providers
数组中。
'providers' => [ VMdevelopment\MyFatoorah\MyFatoorahServiceProfider::class, ]
现在添加别名。
'aliases' => [ 'MyFatoorah' => VMdevelopment\MyFatoorah\Facade\MyFatoorah::class, ]
配置
要发布配置,请运行
php artisan vendor:publish --provider="VMdevelopment\MyFatoorah\MyFatoorahServiceProfider"
并使用您自己的信息修改配置文件。文件位于 /config/myfatoorah.php
您可以在 .env
文件中使用这些环境变量
MYFATOORAH_MODE=test
MYFATOORAH_USERNAME=username
MYFATOORAH_PASSWORD=secret
当前版本功能
Myfatoorah::requestAccessToken()
- 使用您的username
和password
进行授权并返回AccessToken
Myfatoorah::createApiInvoiceIso()
- 创建 ApiInvoiceMyfatoorah::findInvoice($id)
- 通过 ID 查找 ApiInvoiceMyfatoorah::setAccessToken($token)
- 设置运行时AccessToken
使用示例
请求 AccessToken
public function auth( ) { try{ $token = MyFatoorah::requestAccessToken(); } catch( \Exception $exception ){ // your handling of request failure } $token->isExpired() // check if token is expired $token->getToken() // get token }
创建 ApiInvoice(进行支付)
public function pay() { try{ $payment = MyFatoorah::createApiInvoiceIso(); $payment->setCustomerName( "John Doe" ); $payment->setDisplayCurrencyIsoAlpha( "KWD" ); $payment->setCountryCodeId( 1 ); $payment->setCallBackUrl( "http://example.com/success" ); $payment->setErrorUrl( "http://example.com/error" ); $payment->addProduct( "test product", 10, 5 ); $payment->make(); } catch( \Exception $exception ){ // your handling of request failure } $payment->isSuccess() // check if MyFatoorah has successfully handled request. }
查找 ApiInvoice AccessToken
public function check( $id ) { try{ $invoice = MyFatoorah::findInvoice( $id ); } catch( \Exception $exception ){ // your handling of request failure } $invoice->isPaid(); // check if invoice is paid $invoice->isUnpaid(); // check if invoice is unpaid $invoice->isFailed(); // check if invoice is failed }
找到的发票的可用的函数
getInvoiceId()
getInvoiceReference()
getCreatedDate()
getExpireDate()
getInvoiceValue()
getComments()
getCustomerName()
getCustomerMobile()
getCustomerEmail()
getTransactionDate()
getPaymentGateway()
getReferenceId()
getTrackId()
getTransactionId()
getPaymentId()
getAuthorizationId()
getOrderId()
getInvoiceItems()
getTransactionStatus()
getError()
getPaidCurrency()
getPaidCurrencyValue()
getTransationValue()
getCustomerServiceCharge()
getDueValue()
getCurrency()
getApiCustomFileds()
getInvoiceDisplayValue()
您也可以在运行时设置访问令牌
public function check( $id ) { try{ MyFatoorah::setAccessToken([ "access_token" => "your token here", ".expires" => "Tue, 21 Jan 2020 12:02:10 GMT", ]); // your code goes here... } catch( \Exception $exception ){ // your handling of request failure } }