定制 pimcore/payment-provider-klarna 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pimcore/payment-provider-klarna

Composer 安装命令:

composer require pimcore/payment-provider-klarna

包简介

Pimcore Payment Provider - Klarna

README 文档

README

Official Klarna Documentation

Test E-Mail Accounts

Requirements

  • klarna/checkout

Installation

Install latest version with Composer:

composer require pimcore/payment-provider-klarna

Enable bundle via console or extensions manager in Pimcore backend:

php bin/console pimcore:bundle:enable PimcorePaymentProviderKlarnaBundle

Configuration

<?php
$url = $this->view->serverUrl();
$config = [
    'purchase_country' => 'AT'
    , 'merchant_reference' => [
        'orderid2' => $paymentInfo->getInternalPaymentId()
    ]
    , 'locale' => 'de-at'
    , 'merchant' => [
        'back_to_store_uri' => $url(['action' => 'payment'])
        , 'terms_uri' => $this->view->serverUrl() . '/agb'
        , 'checkout_uri' => $url(['action' => 'payment']) . '?klarna_order={checkout.order.uri}'
        , 'confirmation_uri' => $url(['action' => 'confirm'], 'payment') . '?klarna_order={checkout.order.uri}'
        , 'push_uri' => $url(['action' => 'confirm'], 'payment') . '?klarna_order={checkout.order.uri}'
        , 'validation_uri' => $this->view->serverUrl() . '/<LINK TO VALIDATE ORDER>?klarna_order={checkout.order.uri}'
    ]
    , 'options' => [
        'color_button' => '#557F0D'
        , 'color_button_text' => '#FFFFFF'
        , 'color_checkbox' => '#FF0000'
        , 'color_checkbox_checkmark' => '#FF0000'
        , 'color_header' => '#EA5B0C'
        , 'color_link' => '#FF0000'
        , 'allow_separate_shipping_address' => true
    ]
];

The cart items

The Klarna provider implementation has currently no fallback to the default checkout manager to extract the cart items. So you have to pass them in the config array $config['cart']['items'] . See under "1. Add the cart items" https://developers.klarna.com/en/at/kco-v2/checkout/2-embed-the-checkout

Example implementation:

    $items = [];

    foreach ( $cart->getItems() as $cartItem){

            $item = [];
            $item['reference'] = $cartItem->getProduct()->getOSProductNumber(); // a unique reference for this product / variant
            $item['name'] = $cartItem->getProduct()->getOSName(); 
            $item['quantity'] = (int) $cartItem->getCount();

            $unitPrice = $cartItem->getProduct()->getOSPrice(); // the price for 1 piece
            $item['unit_price'] =  (int) $unitPrice->getAmount()->asRawValue() / 100; // format to integer
            
            $item['discount_rate'] = 0; // mostly implemented via an cart modificator
            $item['tax_rate'] = 0; // can be null, if you don't need tax calculation in the Klarna checkout
            $items[]  = $item; // push it to the items array
     }
     
     $config['cart']['items'] = $items;

Most important is the formatting of the prices, they have to be integers. For example: 20.00 € has to become 2000. Klarna only accepts integers because of avoiding rounding mistakes.

Here is a list for all accepted item fields: https://developers.klarna.com/en/at/kco-v2/checkout-api#cart-item-object-properties

pimcore/payment-provider-klarna 适用场景与选型建议

pimcore/payment-provider-klarna 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.82k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pimcore/payment-provider-klarna 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pimcore/payment-provider-klarna 我们能提供哪些服务?
定制开发 / 二次开发

基于 pimcore/payment-provider-klarna 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 6
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2021-02-02