如何整合Klarna 3付款分期付款方式?

时间:2020-06-29 11:45:53

标签: javascript php klarna

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

this

我正在使用此文档: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;

目前,我的状态如下:

this

0 个答案:

没有答案