定制 iamxid/iamx-payment-gateway 二次开发

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

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

iamxid/iamx-payment-gateway

Composer 安装命令:

composer require iamxid/iamx-payment-gateway

包简介

IAMX payment gateway is a Laravel package which allows users to pay a fee using cardano native token.

README 文档

README

IAMX payment gateway is a Laravel package which allows users to pay a fee using ADA or cardano native token.

Installation

Install the current version of the iamxid/iamx-payment-gateway package via composer:

    composer require iamxid/iamx-payment-gateway:dev-main

Configuration

Publish the config file:

    php artisan vendor:publish --provider="IAMXID\IamxPaymentGateway\IamxPaymentGatewayServiceProvider" --tag="config"

Publish the migration file:

    php artisan vendor:publish --provider="IAMXID\IamxPaymentGateway\IamxPaymentGatewayServiceProvider" --tag="migrations"

Run the migration:

    php artisan migrate

Add the Blockfrost project id to the file /config/blockfrost.php

return [
'project_id' => 'mainnet...',
];

Add the variable PAYMENT_GATEWAY_LOGGER to the env file to active logging of the package.

PAYMENT_GATEWAY_LOGGER=true

Usage

Use the trait UsePaymentController in your controller to insert a new payment to the database, check if the payment is pending or confirmed.

<?php

namespace App\Http\Controllers;

use IAMXID\IamxPaymentGateway\Traits\UsePaymentGateway;

class TestController extends Controller
{

    use UsePaymentGateway;
    public function test() {

        // Insert a new payment into the database

        $uuid = '1122ABC';
        $wallet_receiver = 'addr1...';
        $wallet_sender = 'stake1...';
        $after_blockheight = 9881942;
        $token_amount = 10;
        $token_policy_id = '12d5f4fefe222d52a4fdcee56f4b272911d7c2202b068a08ebf53270';
        $token_name_hex = '49414d58';

        // Payment in native token (Example 10 IAMX token)
        $returnValue1 = $this->setPayment(
            $uuid,
            $wallet_receiver,
            $wallet_sender,
            $after_blockheight,
            $token_amount,
            $token_policy_id,
            $token_name_hex
        );

        // Payment in ADA (Example 10 ADA)
        $returnValue2 = $this->setPayment(
            $uuid,
            $wallet_receiver,
            $wallet_sender,
            $after_blockheight,
            $token_amount
        );

        // Check if the payment is still pending
        $returnValue3 = $this->isPendingPayment($uuid);

        // Check if the payment is confirmed
        $returnValue4 = $this->checkForPayment($uuid);


    }
}

Use the GET route [ROOT_URL]/iamx_payment_gateway/checkPayment to check if the payment is confirmed by the blockchain

curl --location '[ROOT_URL]/iamx_payment_gateway/checkPayment?uuid=[UUID of the transaction]'

Setup a cronjob which executes the command iamx_payment_gateway:checkTokenPayment every minute. This command will check blockfrost for the confirmation of the open payments.

* * * * * cd /[PATH TO THE PROJECT]; php artisan iamx_payment_gateway:checkTokenPayment >> /dev/null 2>&1

Setup a cronjob which executes the command iamx_payment_gateway:clearOldOpenPayments every day. This command will delete all pending payments older than 7 days from the database

0 1 * * * cd /[PATH TO THE PROJECT]; php artisan iamx_payment_gateway:clearOldOpenPayments >> /dev/null 2>&1

Bugs and Suggestions

Copyright and License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-01