承接 granada-pride/paytabs 相关项目开发

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

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

granada-pride/paytabs

最新稳定版本:v2.5.5

Composer 安装命令:

composer require granada-pride/paytabs

包简介

This provide integration with the PayTabs payment gateway

README 文档

README

Github All Releases

PayTabs Payment Gateway Integration for Laravel

Table of Contents

  1. Description
  2. Installation
  3. Configuration
  4. Usage
  5. Troubleshooting
  6. Testing
  7. Contribution
  8. License

Description

PayTabs Payment Gateway Integration with Laravel Framework

Installation

You can install the package via composer:

composer require granada-pride/paytabs

Note: This package is compatible with Laravel 9 and higher. Ensure your application meets this requirement before installing.

Configuration

After installation, publish the configuration file using the following command:

php artisan vendor:publish --provider="GranadaPride\Paytabs\PaytabsServiceProvider"

The configuration file paytabs.php will be added to your config directory. Here is a sample configuration:

return [
    'profile_id' => env('PAYTABS_PROFILE_ID'),
    'server_key' => env('PAYTABS_SERVER_KEY'),
    'currency' => env('PAYTABS_CURRENCY'),
    'region' => env('PAYTABS_REGION'),
    'iframe_message_target' => env('PAYTABS_IFRAME_MESSAGE_TARGET'),
];

Configuration Options

  • profile_id: Your PayTabs profile ID, required for API requests.
  • server_key: Your PayTabs server key, used for authentication.
  • currency: The currency code in which payments will be processed (e.g., USD).
  • region: The region for your PayTabs account (e.g., ARE, SAU).

Usage

Create PayPage

Here’s how to create a payment page using this package:

use GranadaPride\Paytabs\Paytabs;
use GranadaPride\Paytabs\DTO\CustomerDetails;

$paytabs = Paytabs::make();

// Set Cart Information
$paytabs->setCart('CART123', 150.00, 'Sample Cart Description');

// Set Customer Information using the CustomerDetails DTO
$customerDetails = new CustomerDetails(
    name: 'John Doe',
    phone: '+123456789',
    email: 'johndoe@example.com',
    street: '123 Main St',
    city: 'Cityville',
    state: 'Stateland',
    country: 'US',
    zipCode: '12345'
);

$paytabs->setCustomer($customerDetails);

// Option 1: Use Customer Information for Shipping if it's the same
$paytabs->useCustomerForShipping();

// Option 2: Set Shipping Information separately if it's different
$shippingDetails = new CustomerDetails(
    name: 'Jane Doe',
    phone: '+987654321',
    email: 'janedoe@example.com',
    street: '456 Market St',
    city: 'Townsville',
    state: 'Regionland',
    country: 'US',
    zipCode: '54321'
);

$paytabs->setShipping($shippingDetails);

// Set URLs and Language
$paytabs->setCallbackUrl('https://yourdomain.com/callback')
        ->setReturnUrl('https://yourdomain.com/return')
        ->setPaypageLang('en');
        
// To display IFrame
$paytabs->displayIFrame();

// and you sholud update your .env with PAYTABS_IFRAME_MESSAGE_TARGET this A valid HTTPS website URL of your domain (the recipient) that will receive the event. In order for the event to be dispatched, this domain must match exactly (including scheme, hostname, and port).

// Generate Payment Page
$response = $paytabs->paypage();

// Handle the response
dd($response);

Query Transaction

You can also query a transaction using its reference:

use GranadaPride\Paytabs\Paytabs;

$response = Paytabs::make()
    ->queryTransaction('TST2422201903602');

dd($response);

Troubleshooting

Common Issues

  • Invalid Credentials: Ensure that your profile_id and server_key in the configuration file are correct.
  • Unsupported Region: Double-check that the region in your configuration file is valid and supported by PayTabs.
  • Transaction Failure: Verify the transaction data (e.g., cart amount, customer details) to ensure it meets PayTabs' requirements.

If you encounter other issues, refer to the PayTabs API Documentation for more details.

Testing

Soon...

Contribution

Contributions are welcome! If you’d like to contribute to this package, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Write your code and ensure it is well-documented.
  4. Submit a pull request with a clear description of your changes.

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固