payload/payload-api
Composer 安装命令:
composer require payload/payload-api
包简介
Payload PHP Library
README 文档
README
A PHP library for integrating Payload.
Installation
Install using composer
composer require payload/payload-api
Install and run manually
Dependencies
sudo apt install php-curl
Require import.php
<?php require_once('payload-php/import.php'); ?>
Get Started
Once you've installed the Payload PHP library to your environment,
we recommend
using the shorthand alias name of pl for Payload\API.
<?php require_once('vendor/autoload.php'); use Payload\API as pl; ?>
API Authentication
To authenticate with the Payload API, you'll need a live or test API key. API keys are accessible from within the Payload dashboard.
use Payload\API as pl; pl::$api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE';
API Version
You can specify the API version to use by setting the api_version property.
use Payload\API as pl; pl::$api_version = 'v2.0';
Testing the PHP Library
Tests are contained within the Tests/ directory. To run a test file enter the command in terminal
./vendor/bin/phpunit Tests/{__FILENAME__}.php
Test execution options can be viewed using the ./vendor/bin/phpunit command.
Creating an Object
Interfacing with the Payload API is done primarily through Payload Objects. Below is an example of
creating a customer using the Payload\Customer object.
<?php # Create a Customer $customer = Payload\Customer::create(array( 'email'=>'matt.perez@example.com', 'name'=>'Matt Perez' )); ?>
<?php # Create a Payment $payment = Payload\Transaction::create(array( 'amount'=>100.0, 'type'=>'payment', 'payment_method'=>new Payload\PaymentMethod(array( 'card'=>array('card_number'=>'4242 4242 4242 4242'), 'type'=>'card' )) )); ?>
Accessing Object Attributes
Object attributes are accessible through dot notation.
<?php $customer->name; ?>
Updating an Object
Updating an object is a simple call to the update object method.
<?php # Updating a customer's email $customer->update(array( 'email'=>'matt.perez@newwork.com' )) ?>
Selecting Objects
Objects can be selected using any of their attributes.
<?php # Select a customer by email $customers = Payload\Customer::filter_by( pl::attr()->email->eq('matt.perez@example.com') ); ?>
Use the pl::attr() attribute helper
interface to write powerful queries with a little extra syntax sugar.
$payments = Payload\Transaction::filter_by( pl::attr()->amount->gt(100), pl::attr()->amount->lt(200), pl::attr()->description->contains("Test"), pl::attr()->created_at->gt('2019-02-01') )->all()
Available Objects
The following Payload objects are available in this library:
Core Objects:
Payload\Customer(v1 only)Payload\TransactionPayload\PaymentMethodPayload\AccountPayload\ProcessingAccount(v1 only)
Billing & Invoicing:
Payload\InvoicePayload\InvoiceItemPayload\BillingSchedulePayload\BillingCharge(v1 only)Payload\BillingItemPayload\LineItem(v1 only)
Payment Processing:
Payload\PaymentLinkPayload\PaymentActivation(v1 only)Payload\PaymentAllocationPayload\Intent
Business Entities:
Payload\ProfilePayload\EntityPayload\StakeholderPayload\ProcessingAgreementPayload\ProcessingRulePayload\ProcessingSettings
Transfers & Operations:
Payload\TransferPayload\TransactionOperation
Payment Methods:
Payload\Card(v1 only)Payload\BankAccount(v1 only)Payload\CheckFrontPayload\CheckBack
Other:
Payload\WebhookPayload\AccessTokenPayload\ClientTokenPayload\OAuthToken
Documentation
To get further information on Payload's PHP library and API capabilities, visit the unabridged Payload Documentation.
payload/payload-api 适用场景与选型建议
payload/payload-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.11k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「payments」 「payload」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 payload/payload-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 payload/payload-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 payload/payload-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A PSR-7 compatible library for making CRUD API endpoints
A framework-agnostic PHP library for building standardized JSend API responses with PSR-7 support
A simple payload data manager.
Responder for http messages
统计信息
- 总下载量: 5.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-10