Initiating the payment
PayTabs provides you with the backend packages that make the integrating with PayTabs payment gateway very easy by providing ready-made classes that handle the payment process.
This manual is dedicated to walking you through how to initiate the payment/request payload using the configuration options and parameters that have already been clarified in the previous step, "Step 2 - Configure the integration method". Please follow the below steps to initiate a Hosted Payment Page via this package:
-
First thing, you will need to include our
paypage
facade within your uses. -
Then, create an object from the
paypage
class while passing payment method, transaction type/class, cart, URLs, customer, and shipping details to initiate a pre-filled payment page with your provided information. Then, in the end/tail, you MUST call thecreate_pay_page()
function to initiate the payment page with the previously provided information:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Paytabscom\Laravel_paytabs\Facades\paypage;
class PayTabsController extends Controller
{
public function initiatePayment(Request $request)
{
//your code here
$pay = paypage::sendPaymentCode($payment_method) //required
->sendTransaction($tran_type,$tran_class) //required
->sendCart($cart_id, $cart_amount, $cart_description) //required
->sendCustomerDetails($name, $email, $phone, $street1, $city, $state, $country, $zip, $ip)
->sendShippingDetails($name, $email, $phone, $street1, $city, $state, $country, $zip, $ip)
->shipping_same_billing() //If you call this method then remove sendShippingDetails() method
->sendHideShipping(false)
->sendURLs($return, $callback)
->sendLanguage($language)
->sendFramed(false)
->sendTokinse($status)
->sendToken($tran_ref,$token)
->sendUserDefined(["udf1"=>"UDF1", "udf2"=>"UDF2", "udf3"=>"UDF3"])
->create_pay_page(); // to initiate payment page
}
}
📄️ Manage the Payment Methods
- sendPaymentCode()
📄️ Manage the Transaction Type
- sendTransaction()
📄️ Manage the Cart Details
- sendCart()
📄️ Manage Shipping and Billing Details
- sendShippingDetails() & sendCustomerDetails()
📄️ Hide the Shipping Details
- sendHideShipping()
📄️ Manage the Return and Callback URLs
- sendURLs()
📄️ Manage the Payment Page Display Language
- sendLanguage()
📄️ Initiate an iFramed/Embedded Payment Page
- sendFramed()
📄️ Sending Customized Parameters
- sendUserDefined()
📄️ Manage Tokenization
- sendTokinse()
📄️ Manage Token Based transactions
- sendToken()