1. Go to this page and download the library: Download granada-pride/clickpaysa library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
granada-pride / clickpaysa example snippets
return [
/*
|--------------------------------------------------------------------------
| Clickpay Profile ID
|--------------------------------------------------------------------------
|
| This is your Clickpay profile ID, which is | Clickpay Server Key
|--------------------------------------------------------------------------
|
| Your Clickpay server key is used to authenticate API requests. Make
| sure to keep this value secure and do not expose it in your version
| control system. It should be stored in the .env file.
|
*/
'server_key' => env('CLICKPAY_SERVER_KEY'),
/*
|--------------------------------------------------------------------------
| Default Currency
|--------------------------------------------------------------------------
|
| The currency in which payments will be processed by default. You can
| change this to any currency supported by Clickpay (e.g., USD, EUR).
| This value can also be configured in your .env file.
|
*/
'currency' => env('CLICKPAY_CURRENCY', 'SAR'),
/*
|--------------------------------------------------------------------------
| Clickpay API Base URL
|--------------------------------------------------------------------------
|
| The base URL for the Clickpay API. This is typically the endpoint where
| API requests are sent. You can change this value if Clickpay provides
| a different URL for specific regions or environments (e.g., testing).
|
*/
'base_url' => env('CLICKPAY_BASE_URL', 'https://secure.clickpay.com.sa'),
];
use GranadaPride\Clickpay\ClickpayClient;
use GranadaPride\Clickpay\DTO\CustomerDTO;
use GranadaPride\Clickpay\DTO\PaymentDTO;
use GranadaPride\Clickpay\Contracts\PaymentGatewayInterface;
$clickpay = app(PaymentGatewayInterface::class);
// Set CustomerDTO Information using the CustomerDTO DTO
$customerDTO = new CustomerDTO(
name: 'Ahmad Mohamed',
phone: '+123456789',
email: '[email protected]',
street: '123 Main St',
city: 'Cityville',
state: 'Stateland',
country: 'KSA',
zipCode: '12345'
);
// Use CustomerDTO Information for Shipping if it's the same
$shippingDTO = $customerDTO;
// Set PaymentDTO Details
$paymentDTO = new PaymentDTO(
cartId: 'CART123',
cartAmount: 150.00,
cartDescription: 'Sample Cart Description',
customerDTO: $customerDTO,
shippingDTO: $shippingDTO,
callbackUrl: 'https://yourdomain.com/callback',
returnUrl: 'https://yourdomain.com/return',
paypageLang: 'ar',
hideShipping: false // Set to true if you want to hide shipping details on the payment page
);
// Or you can simply send only
use GranadaPride\Clickpay\Contracts\PaymentGatewayInterface;
$clickpay = app(PaymentGatewayInterface::class);
$response = $clickpay->queryTransaction('TST2422201903602');
dd($response);