Git Product home page Git Product logo

paytabs-laravel's Introduction

Paytabs Laravel

Installation

Begin by installing this package through Composer. Just run following command to terminal-

composer require maq89/paytabs-laravel

Once this operation completes the package will automatically be discovered for Laravel 5.6 and above, otherwise, the final step is to add the service provider. Open config/app.php, and add a new item to the providers array.

'providers' => [
	...
	Damas\Paytabs\PaytabsServiceProvider::class,
],

Now add the alias.

'aliases' => [
	...
	'Paytabs' => Damas\Paytabs\Facades\PaytabsFacade::class,
],

Example:

Create Payment Page:

Route::get('/paytabs_payment', function () {
    $pt = Paytabs::getInstance("MERCHANT_EMAIL", "SECRET_KEY");
	$result = $pt->create_pay_page(array(
		"merchant_email" => "MERCHANT_EMAIL",
		'secret_key' => "SECRET_KEY",
		'title' => "John Doe",
		'cc_first_name' => "John",
		'cc_last_name' => "Doe",
		'email' => "[email protected]",
		'cc_phone_number' => "973",
		'phone_number' => "33333333",
		'billing_address' => "Juffair, Manama, Bahrain",
		'city' => "Manama",
		'state' => "Capital",
		'postal_code' => "97300",
		'country' => "BHR",
		'address_shipping' => "Juffair, Manama, Bahrain",
		'city_shipping' => "Manama",
		'state_shipping' => "Capital",
		'postal_code_shipping' => "97300",
		'country_shipping' => "BHR",
		"products_per_title"=> "Mobile Phone",
		'currency' => "BHD",
		"unit_price"=> "10",
		'quantity' => "1",
		'other_charges' => "0",
		'amount' => "10.00",
		'discount'=>"0",
		"msg_lang" => "english",
		"reference_no" => "1231231",
		"site_url" => "https://your-site.com",
		'return_url' => "https://www.mystore.com/paytabs_api/result.php",
		"cms_with_version" => "API USING PHP"
	));
    
    	if($result->response_code == 4012){
	    return redirect($result->payment_url);
        }
        return $result->result;
});

Verify Payment:

Route::post('/paytabs_response', function(Request $request){
    $pt = Paytabs::getInstance("MERCHANT_EMAIL", "SECRET_KEY");
    $result = $pt->verify_payment($request->payment_reference);
    if($result->response_code == 100){
        // Payment Success
    }
    return $result->result;
});

you will need to exclude your paytabs_response route from CSRF protection

paytabs-laravel's People

Contributors

maq89 avatar danielwaghorn avatar jadsalhani avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.