定制 emydev/laravel_paytabs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

emydev/laravel_paytabs

Composer 安装命令:

composer require emydev/laravel_paytabs

包简介

Official laravel package to implement PayTabs integration with laravel apps

README 文档

README

build status Coverage Status pub package

A Flutter plugin for making payments via Paystack Payment Gateway. Fully supports Android and iOS.

🚀 Installation

To use this plugin, add flutter_paystack as a dependency in your pubspec.yaml file.

Then initialize the plugin preferably in the initState of your widget.

import 'package:flutter_paystack/flutter_paystack.dart';

class _PaymentPageState extends State<PaymentPage> {
  var publicKey = '[YOUR_PAYSTACK_PUBLIC_KEY]';
  final plugin = PaystackPlugin();

  @override
  void initState() {
    plugin.initialize(publicKey: publicKey);
  }
}

No other configuration required—the plugin works out of the box.

💲 Making Payments

There are two ways of making payment with the plugin.

  1. Checkout: This is the easy way; as the plugin handles all the processes involved in making a payment (except transaction initialization and verification which should be done from your backend).
  2. Charge Card: This is a longer approach; you handle all callbacks and UI states.

1. 🌟 Checkout (Recommended)

You initialize a charge object with an amount, email & accessCode or reference. Pass an accessCode only when you have initialized the transaction from your backend. Otherwise, pass a reference.

Charge charge = Charge()
      ..amount = 10000
      ..reference = _getReference()
       // or ..accessCode = _getAccessCodeFrmInitialization()
      ..email = 'customer@email.com';
    CheckoutResponse response = await plugin.checkout(
      context context,
      method: CheckoutMethod.card, // Defaults to CheckoutMethod.selectable
      charge: charge,
    );

Please, note that an accessCode is required if the method is CheckoutMethod.bank or CheckoutMethod.selectable.

plugin.checkout() returns the state and details of the payment in an instance of CheckoutResponse .

It is recommended that when plugin.checkout() returns, the payment should be verified on your backend.

2. ⭐ Charge Card

You can choose to initialize the payment locally or via your backend.

A. Initialize Via Your Backend (Recommended)

1.a. This starts by making a HTTP POST request to paystack on your backend.

1.b If everything goes well, the initialization request returns a response with an access_code. You can then create a Charge object with the access code and card details. The charge is in turn passed to the plugin.chargeCard() function for payment:

  PaymentCard _getCardFromUI() {
    // Using just the must-required parameters.
    return PaymentCard(
      number: cardNumber,
      cvc: cvv,
      expiryMonth: expiryMonth,
      expiryYear: expiryYear,
    );
  }

  _chargeCard(String accessCode) async {
    var charge = Charge()
      ..accessCode = accessCode
      ..card = _getCardFromUI();

    final response = await plugin.chargeCard(context, charge: charge);
    // Use the response
  }

The transaction is successful if response.status is true. Please, see the documentation of CheckoutResponse for more information.

2. Initialize Locally

Just send the payment details to plugin.chargeCard

      // Set transaction params directly in app (note that these params
      // are only used if an access_code is not set. In debug mode,
      // setting them after setting an access code would throw an error
      Charge charge = Charge();
      charge.card = _getCardFromUI();
      charge
        ..amount = 2000
        ..email = 'user@email.com'
        ..reference = _getReference()
        ..putCustomField('Charged From', 'Flutter PLUGIN');
      _chargeCard();

🔧 🔩 Validating Card Details

You are expected but not required to build the UI for your users to enter their payment details. For easier validation, wrap the TextFormFields inside a Form widget. Please check this article on validating forms on Flutter if this is new to you.

NOTE: You don't have to pass a card object to Charge. The plugin will call-up a UI for the user to input their card.

You can validate the fields with these methods:

card.validNumber

This method helps to perform a check if the card number is valid.

card.validCVC

Method that checks if the card security code is valid.

card.validExpiryDate

Method checks if the expiry date (combination of year and month) is valid.

card.isValid

Method to check if the card is valid. Always do this check, before charging the card.

card.getType

This method returns an estimate of the string representation of the card type(issuer).

✔️ Verifying Transactions

This is quite easy. Just send a HTTP GET request to https://api.paystack.co/transaction/verify/$[TRANSACTION_REFERENCE]. Please, check the official documentaion on verifying transactions.

🚁 Testing your implementation

Paystack provides tons of payment cards for testing.

▶️ Running Example project

For help getting started with Flutter, view the online documentation.

An example project has been provided in this plugin. Clone this repo and navigate to the example folder. Open it with a supported IDE or execute flutter run from that folder in terminal.

📝 Contributing, 😞 Issues and 🐛 Bug Reports

The project is open to public contribution. Please feel very free to contribute. Experienced an issue or want to report a bug? Please, report it here. Remember to be as descriptive as possible.

🏆 Credits

Thanks to the authors of Paystack iOS and Android SDKS. I leveraged on their work to bring this plugin to fruition.

Laravel PayTabs PT2

Description

This Package provides integration with the PayTabs payment gateway.

CONTENTS OF THIS FILE

  • Introduction
  • Requirements
  • Installation
  • Configuration
  • usage

INTRODUCTION

This Package integrates PayTabs online payments into the Laravel Framework starts from version 5.8 - 8.x.

REQUIREMENTS

This Package requires no external dependencies.

INSTALLATION

  • composer require paytabscom/laravel_paytabs

CONFIGURATION

  • composer dump-autoload

  • Go to config/app.php and in the providers array add

      Paytabscom\Laravel_paytabs\PaypageServiceProvider::class,
    
  • Create the package config file:

      php artisan vendor:publish --tag=paytabs
    
  • Go to config/logging.php and in the channels array add

    'PayTabs' => [
    'driver' => 'single',
    'path' => storage_path('logs/paytabs.log'),
    'level' => 'info',
    ],
    
  • In config/paytabs.php add your merchant info.

Important Hint: you can pass your merchant info in the environment file with the same key names mentioned in the config/paytabs.php file. This value will be returned if no environment variable exists for the given key.

Usage

  • create pay page

      use Paytabscom\Laravel_paytabs\Facades\paypage;
    
      $pay= paypage::sendPaymentCode('all')
             ->sendTransaction('sale')
              ->sendCart(10,1000,'test')
             ->sendCustomerDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10')
             ->sendShippingDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10')
             ->sendURLs('return_url', 'callback_url')
             ->sendLanguage('en')
             ->create_pay_page();
      return $pay;
    
  • if you want to pass the shipping address as same as billing address you can use

      ->sendShippingDetails('same as billing')
    
  • if you want to hide the shipping address you can use

      ->sendHideShipping(true);
    
  • if you want to use iframe option instead of redirection you can use

      ->sendFramed(true);
    
  • refund (you can use this function to both refund and partially refund)

      $refund = Paypage::refund('tran_ref','order_id','amount','refund_reason');
      return $refund;
    
  • Auth

      pay= Paypage::sendPaymentCode('all')
             ->sendTransaction('Auth')
              ->sendCart(10,1000,'test')
             ->sendCustomerDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10')
             ->sendShippingDetails('Walaa Elsaeed', 'w.elsaeed@paytabs.com', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','100.279.20.10')
             ->sendURLs('return_url', 'callback_url')
             ->sendLanguage('en')
             ->create_pay_page();
      return $pay;
    
  • capture (the tran_ref is the tran_ref of the Auth transaction you need to capture it.

    you can use this function to both capture and partially capture.)

       $capture = Paypage::capture('tran_ref','order_id','amount','capture description'); 
       return $capture;
    
  • void (the tran_ref is the tran_ref of the Auth transaction you need to void it.

    you can use this function to both capture and partially capture)

      $void = Paypage::void('tran_ref','order_id','amount','void description');
      return $void
    
  • transaction details

      $transaction = Paypage::queryTransaction('tran_ref');
      return $transaction;
    
  • if you face any error you will find it logged in: storage/logs/paytabs.log

PAYMENT RESULT NOTIFICATION

PayTabs payment gateway provides means to notify your system with payment result once transaction processing was completed so that your system can update the transaction respective cart.

To get use of this feature do the following:

1- Defining a route (Optional)

Laravel PayTabs PT2 package comes with a default route for incoming IPN requests. The route URI is /paymentIPN , if you don't like it this URI just ignore it and define your own. Look at src/routes.php to get a clue.

2- Implementing a means to receive notification

To receive notification, do one of the following:

  • While creating a pay page, passed a URL as the second argument to sendURLs method, that URL will receive an HTTP Post request with the payment result. For more about callback check: merchant dashboard > Developers > Transaction API.

  • Second means is to configure IPN notification from merchant dashboard. For more details about how to configure IPN request and its different formats check: merchant dashboard > Developers > Service Types.

3- Configuring a callback method

Now, you need to configure the plugin with the class\method that will grab the payment details and perform your custom logic (updating cart in DB, notifying the customer ...etc ).

  • In your website config/paytabs.php file, add the following:

      'callback' => env('paytabs_ipn_callback', new namespace\your_class() ),
    
  • In your class add new method, it must named: updateCartByIPN

      updateCartByIPN( $requestData){
          $cartId= $requestData->getCartId();
          $status= $requestData->getStatus();
          //your logic .. updating cart in DB, notifying the customer ...etc
      }
    

you can also get transaction reference number. To get the list of available properties check: Paytabscom\Laravel__paytabs\IpnRequest class.

emydev/laravel_paytabs 适用场景与选型建议

emydev/laravel_paytabs 是一款 基于 Dart 开发的 Composer 扩展包,目前已累计 560 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payments」 「laravel」 「paytabs」 「E-comerce」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 emydev/laravel_paytabs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 emydev/laravel_paytabs 我们能提供哪些服务?
定制开发 / 二次开发

基于 emydev/laravel_paytabs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 19
  • 开发语言: Dart

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-12