collector-bank/collector-checkout-sdk
Composer 安装命令:
composer require collector-bank/collector-checkout-sdk
包简介
SDK for Collector Bank Checkout API
README 文档
README
Php package used to communicate with Collector Bank Checkout API. Used when creating orders.
Data objects are immutable. Pass all variables in the constructor.
Example initialization
$config = new \Webbhuset\CollectorCheckoutSDK\Config\Config; // Either use this class or create your own class, implementing \Webbhuset\CollectorCheckoutSDK\Config\ConfigInterface
$config->setUsername('my-username')
->setSharedAccessKey('my-shared-access-key')
->setCountryCode('SE')
->setStoreId('1')
->setRedirectPageUri('https://example.com')
->setMerchantTermsUri('https://example.com')
->setNotificationUri('https://example.com')
->setValidationUri('https://example.com');
$adapter = new \Webbhuset\CollectorCheckoutSDK\Adapter\CurlAdapter($config);
$shippingFee = new \Webbhuset\CollectorCheckoutSDK\Checkout\Fees\Fee(1, "Shipping fee", 10, 25);
$fees = new \Webbhuset\CollectorCheckoutSDK\Checkout\Fees($shippingFee, null);
$item = new \Webbhuset\CollectorCheckoutSDK\Checkout\Cart\Item(
'my-sku',
'The product name',
59,
1,
25,
false,
'my-sku'
);
$cart = new \Webbhuset\CollectorCheckoutSDK\Checkout\Cart([$item]);
$customer = new \Webbhuset\CollectorCheckoutSDK\Checkout\Customer\InitializeCustomer(
'test@example.com',
'0123456789',
'89123456',
'12345'
);
$countryCode = 'SE';
$reference = 'ref-000001';
$session = new \Webbhuset\CollectorCheckoutSDK\Session($adapter);
try {
$session->initialize($this->getConfig(), $fees, $cart, $customer, $countryCode, $reference);
} catch (RequestError $e) {
// do stuff
} catch (ResponseError $e) {
// do stuff
}
$iframeSnippet = \Webbhuset\CollectorCheckoutSDK\Iframe->getScript($iframeConfig)
If an address is updated (not handled in this lib), you might have to update items or fees if address has changed
$session = new Session($config)
$checkoutData = $session->load($privateId)
->getCheckoutData() //initialized
$deliveryCountry = $checkoutData->getCustomer()->getDeliveryAddress()
->getCountry();
if ($deliveryCountry == 'Sverige') {
$shippingFee = new \Webbhuset\CollectorCheckoutSDK\Checkout\Fees\Fee(
1,
"Shipping fee for sweden",
20,
25
);
$newFees = new \Webbhuset\CollectorCheckoutSDK\Checkout\Fees($shippingFee, null);
$session->updateFees($newFees)
}
To render checkout or success iframe
// If the session got initalized in another request, you have to save to public token and use it
$session = new Session($config);
$publicToken = $mySavedToken;
// Or initialize new session
$session->initialize($this->getConfig(), $fees, $cart, $customer, $countryCode, $reference);
$publicToken = $session->getPublicToken();
$iframeConfig = new \Webbhuset\CollectorCheckoutSDK\Config\IframeConfig(
$publicToken
);
$iframe = $session->getIframe($iframeConfig)
collector-bank/collector-checkout-sdk 适用场景与选型建议
collector-bank/collector-checkout-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.64k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 collector-bank/collector-checkout-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 collector-bank/collector-checkout-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2020-05-04