sunnysideup/afterpay
Composer 安装命令:
composer require sunnysideup/afterpay
包简介
Integrate easily with the api.afterpay.com API
README 文档
README
Provides a basic implementation of afterpay as a payment method for
sunnysideup/ecommerce - using https://github.com/culturekings/afterpay as a base.
installation
Use composer
composer require sunnysideup/afterpay
setup
Add the following code as outlined below:
- set up credentials
app/_config/afterpay.yml:
--- Name: Afterpay --- Sunnysideup\Afterpay\Factory\SilverstripeMerchantApi: merchant_name: 'my merchant name' merchant_id: yyy secret_key: 'xxx' expectations_folder: 'app/afterpay/configurations' number_of_payments: 4
- set afterpay as a payment option
app/_config/ecommerce.yml:
EcommercePayment: supported_methods: # ... Sunnysideup\Afterpay\Model\AfterpayEcommercePayment: "Afterpay"
- add fields to EcomConfig (via data extension or otherwise)
private static $db = [ 'ShowAfterpayOption' => 'Boolean', 'AfterpayMinValue' => 'Int', 'AfterpayMaxValue' => 'Int', ]
- add functionality to product:
app/src/Model/MyProduct.php:
use Sunnysideup\Afterpay\Factory\SilverstripeMerchantApi; class MyProduct extends Product { public function ShowAfterpay() : bool { return return $this->myAfterpayApi()->canProcessPayment($this->CalculatedPrice()); } protected function myAfterpayApi() : SilverstripeMerchantApi { return SilverstripeMerchantApi::inst() ->setMinAndMaxPrice( (float) EcommerceConfig::inst()->AfterpayMinValue, (float) EcommerceConfig::inst()->AfterpayMaxValue ) ->setIsServerAvailable(EcommerceConfig::inst()->ShowAfterpayOption); } public function getAfterpayNumberOfPayments() : int { return $this->myAfterpayApi() ->getNumberOfPayments(); } public function getAfterpayNumberOfPaymentsInWeeks() : int { return $this->getAfterpayNumberOfPayments() * 2; } public function getAfterpayAmountPerPayment() :float { return $this->myAfterpayApi() ->getAmountPerPayment($this->CalculatedPrice()); } public function getAfterpayAmountPerPaymentAsMoney() : Money { return EcommerceCurrency::get_money_object_from_order_currency( $this->getAfterpayAmountPerPayment() ); } public function getAfterpayAmountPerPaymentAsCurrency(): Currency { return DBField::create_field('Currency', $this->getAfterpayAmountPerPayment()); } }
sunnysideup/afterpay 适用场景与选型建议
sunnysideup/afterpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 357 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sunnysideup/afterpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sunnysideup/afterpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 357
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-11-01