定制 paywithterra/php-backend-library 二次开发

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

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

paywithterra/php-backend-library

Composer 安装命令:

composer require paywithterra/php-backend-library

包简介

PHP library for tx validation on public facades

README 文档

README

PHP library for validating payment transactions on Terra blockchain.

Prerequisites

PHP version 5.6, 7.0, 7.1, 7.2, 7.3, or 7.4
PHP extensions: ext-json, ext-curl

Installation

You can use Composer. Follow the installation instructions if you do not already have composer installed.

composer require paywithterra/php-backend-library

In your PHP script, make sure you include the Composer's autoloader:

require __DIR__ . '/vendor/autoload.php';

Alternatively, when you are not using Composer, you can download the release on GitHub and use library directly:

require __DIR__ . '/src/autoload-legacy.php';

Using the library

Request and validate transaction

// Prepare client (see all options below)
$client = new \PaywithTerra\TerraTxValidator([
    "merchantAddress" => "terra12abcdefg1234512345123451234512345abc",
    "chainId" => "pisco-1",
    "LCD" => "https://pisco-lcd.terra.dev/cosmos/tx/v1beta1/txs/{txHash}",
]);

// Request transaction information from public facade (by txHash)
$client->lookupTx("TynpStpmcovsgsNpqlchimy9cydlc83bwudgrBigShTksrzczfvxnf9q4kkvcek4");

// Check if transaction comply with our requirements (throw exception if not)
$client->assertTx([
    "memo" => '#order-1234',
    "denom" => "uluna",
    "amount" => "280000",
]);

Client options (initialization variants)

Variant 1: Using exact LCD and chainId

$client = new \PaywithTerra\TerraTxValidator([
    "merchantAddress" => "terra12abcdefg1234512345123451234512345abc",
    "chainId" => "pisco-1",
    "LCD" => "https://pisco-lcd.terra.dev/cosmos/tx/v1beta1/txs/{txHash}",
]);

Variant 2: Using exact FCD and chainId

$client = new \PaywithTerra\TerraTxValidator([
    "merchantAddress" => "terra12abcdefg1234512345123451234512345abc",
    "chainId" => "pisco-1",
    "FCD" => "https://pisco-fcd.terra.dev/v1/tx/{txHash}",
]);

Variant 3: Using network name (requests chains info + LCD url from Terra network and cache it)

$client = new \PaywithTerra\TerraTxValidator([
    "merchantAddress" => "terra12abcdefg1234512345123451234512345abc",
    "networkName" => "testnet", // or "mainnet" or "classic"
    "cache" => new \PaywithTerra\Cache\FileCache(),
]);

Assets (denoms) support

Denom code Asset name / Description
uluna Luna
Default (basic) network asset
ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4 axlUSDC (mainnet)
The USDC representation in Terra network (can be swapped from Luna right on Station Mobile)
ibc/CBF67A2BCF6CAE343FDF251E510C8E18C361FC02B23430C121116E0811835DEF axlUSDT (mainnet)
The Tether representation in Terra network (can be swapped from Luna right on Station Mobile)

Notes

We don't use any of modern libraries (like Guzzle or Symphony HTTP Client) as transport because we want to keep the minimal supported PHP version as low as possible.
This approach allows even old-school and legacy PHP-projects to connect to Terra. If you really want to use HTTP clients as transport, please open an issue.

License

The MIT License (MIT)

paywithterra/php-backend-library 适用场景与选型建议

paywithterra/php-backend-library 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 08 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 paywithterra/php-backend-library 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-15