承接 paywithterra/php-backend-library 相关项目开发

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

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

paywithterra/php-backend-library

最新稳定版本:1.0.1

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)

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固