spacemudd/laravel-tap-payments

Tap Payment REST API package for Laravel
3,349 7
Install
composer require spacemudd/laravel-tap-payments
Latest Version:2.0.1
PHP:^7.1
License:MIT
Last Updated:Nov 4, 2020
Links: GitHub  ·  Packagist
Maintainer: spacemudd

About

Integration library with https://www.tap.company

Installation

composer require "spacemudd/laravel-tap-payments"

For older versions of Laravel (<5.5)

Update your /config/app.php with:

'providers' => [
    ...
	\Tap\TapPayment\TapPaymentServiceProvider::class
]
'aliases' => [
    ...
	'TapPayment' => \Tap\TapPayment\Facade\TapPayment::class
]

Publishing

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

Config

Update /config/tap-payment.php with your info.

Add the following to 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 a charge

use Tap\TapPayment\Facade\TapPayment;

public function pay()
{
	try {
		$payment = TapPayment::createCharge();
		$payment->setCustomerName("John Doe");
		$payment->setCustomerPhone("965", "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();
	} catch( \Exception $exception ) {
		// your handling of request failure
	}
    
    $payment->isSuccess(); // check if TapPayment has successfully handled request.
}

Getting an invoice

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
}

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

628,058,007 9,707
laravel/framework

The Laravel Framework.

576,155,700 34,907
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440