首页 > 解决方案 > 如何整合 Klarna 3 pay 分期付款方式?

问题描述

我想在我的网站中添加Klarna 3 pay 分期付款方式。像这样:

这个

我正在使用此文档:https ://developers.klarna.com/api/#checkout-api-create-a-new-order

这是我的请求代码:

 $data = [
    "purchase_country" => "GB",
    "purchase_currency"=> "GBP",
    "locale"=> "en-GB",
    "order_amount"=> $total_amount,
    "order_tax_amount"=> 0,
    "payment_method_category" => 
    "order_lines" => [[
        "type"=>"physical",
        "reference"=> "25",
        "name"=> $name,
        "quantity"=> $quantity,
        "quantity_unit"=> "pcs",
        "unit_price"=>$price_per_item,
        "tax_rate"=> 0,
        "total_amount"=> $total_amount,
        "total_discount_amount"=> $discount,
        "total_tax_amount"=> 0
    ]],
    "merchant_urls"=> [
        "terms"=> base_url("ordernow/term"),
        "checkout" => base_url("ordernow/newform"),
        "confirmation"=> base_url("ordernow/paid_via_klarna")."?order_id={checkout.order.id}",
        "push"=> base_url("ordernow/validate_klarna_payment")."?order_id={checkout.order.id}"
    ]
];


$ch = curl_init( $url );
$payload = json_encode( $data );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);  
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
curl_close($ch);

echo $result;

目前我是这样的:

这个

标签: javascriptphpklarna

解决方案


推荐阅读