javascript - 如何整合 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;
目前我是这样的:
解决方案
推荐阅读
- html - 链接中出现CSS奇怪的颜色
- java - PostAdapter 为帖子返回不正确的 postid
- r - 如何在 Rstudio 的 Riverplot 脚本中编辑节点到节点的布局和 y 值?
- javascript - e.target 并不总是触发元素
- python - 将 tensorflow .pb 模型转换为 .mlmodel 时出错
- oracle11g - 11 g 客户端 SQL*loader:插入日期时间不起作用
- c# - 没有给出与“Person.Person(string, string, int)”所需的形式参数“name”相对应的参数
- react-native - 当 url 在本机反应中受密码保护时,如何执行 axios.get?
- python - 如何使用 python 将文本文件转换为列表:
- python - Pygame 的“口吃”开始菜单