collector-bank / collector-checkout-sdk
该包最新版本(v1.0.15)的许可信息不可用。
Collector Bank Checkout API 的 SDK
v1.0.15
2024-02-26 10:27 UTC
- dev-master
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-bugfix_switch-b2b
- dev-feature/prefill-buyer
- dev-feature/oath
- dev-bugfix/php80-emails-not-sent
- dev-release/magento-upgrade-plus-bug-fixes
- dev-bug/handle_new_aborted_status
- dev-bug/magento244_or_php8_fixes
- dev-7-action-color-fungerar-inte
This package is auto-updated.
Last update: 2024-09-26 11:39:59 UTC
README
用于与 Collector Bank Checkout API 通信的 PHP 包。在创建订单时使用。
数据对象是不可变的。请在构造函数中传递所有变量。
示例初始化
$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)
如果地址更新了(本库未处理),如果地址有变化,可能需要更新项目或费用
$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)
}
渲染结算或成功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)