承接 alaa-elsaid/laravel-tap-payments 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alaa-elsaid/laravel-tap-payments

最新稳定版本:v1.0.1

Composer 安装命令:

composer require alaa-elsaid/laravel-tap-payments

包简介

Tap Payment REST API package for Laravel >= 5

README 文档

README

Laravel package for https://www.tap.company Supports Laravel 5.5 and above

Installation

Simply run

composer require "alaa-elsaid/laravel-tap-payments"

For laravel >=5.5 that's all. This package supports Laravel new Package Discovery.

Otherwise you need to open up /config/app.php and add the service provider to your providers array.

'providers' => [
	\Alaa\TapPayment\TapPaymentServiceProvider::class
]

Now add the alias.

'aliases' => [
	'TapPayment' => \Alaa\TapPayment\Facade\TapPayment::class
]

Configuration

To publish config run

php artisan vendor:publish --provider="Alaa\TapPayment\TapPaymentServiceProvider"

and modify the config file with your own information. File is located in /config/tap-payment.php

you can use this environment variables in your .env file

TAP_PAYMENT_API_KEY=your_api_key

Current version Functions

  • TapPayment::createCharge() - Creating an ApiInvoice
  • TapPayment::findCharge($id) - Finding an ApiInvoice by ID

Usage example

Creating Charge(make payment)

use Alaa\TapPayment\Facade\TapPayment;

public function pay()
{
	try{

		$payment = TapPayment::createCharge();

		$payment->setCustomerName( "John Doe" );
		
		$payment->setCustomerPhone( "123456789" );
		
		$payment->setDescription( "Some description" );

		$payment->setAmount( 123 );

		$payment->setCurrency( "KWD" );
		
		$payment->setSource( "src_kw.knet" );
        
		$payment->setRedirectUrl( "https://example.com" );

		$payment->setPostUrl( "https://example.com" ); // if you are using post request to handle payment updates

		$payment->setMetaData( [ 'package' => json_encode( $package ) ] ); // if you want to send metadata

		$invoice = $payment->pay();
		$invoice->getPaymentUrl(); // get the payment url to redirect the user to it.

		
	} catch( \Exception $exception ){
		// your handling of request failure
	}
    
    $payment->isSuccess() // check if TapPayment has successfully handled request.
}

Find ApiInvoice

public function check( $id )
{
	try{
	
		 $invoice = TapPayment::findCharge( $id );;
		 
	 } catch( \Exception $exception ){
		// your handling of request failure
	}
	$invoice->checkHash($request->header('Hashstring')); // check hashstring to make sure that request comes from Tap
	$invoice->isSuccess(); // check if invoice is paid
	$invoice->isInitiated(); // check if invoice is unpaid yet
}

统计信息

  • 总下载量: 41
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-11