我需要在我的网站上实现 Swish Payment 电子商务 API。swish 给出的测试代码使用 Git Bash 运行良好。样品在这里
curl -s -S -i --cert ./Swish_Merchant_TestCertificate_1231181189.pem --key ./Swish_Merchant_TestCertificate_1231181189.key --cacert ./Swish_TLS_RootCA.pem --tlsv1.1 --header "Content-Type: application/json" https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests --data '{ "payeePaymentReference" : "0123456789", "callbackUrl" : "https://myfakehost.se/swishcallback.cfm", "payerAlias" : "4671234768", "payeeAlias" : "1231181189", "amount" : "100", "currency" : "SEK", "message" : "Kingston USB Flash Drive 8 GB" }'
但是当我在 php 中转换它时,它给了我错误 cURL Error #:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
我的php代码在这里
$data = array(
"content-type: application/json",
"accept: application/json",
"payeePaymentReference: 0123456789",
"callbackUrl: https://myfakehost.se/swishcallback.cfm",
"payerAlias: 4671234768",
"payeeAlias: 1231181189",
"amount: 100",
"currency: SEK",
"message: Kingston USB Flash Drive 8 GB"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSLCERT, getcwd() . '/Swish_Merchant_TestCertificate_1231181189.pem');
curl_setopt($curl, CURLOPT_SSLKEY, getcwd() .'/Swish_Merchant_TestCertificate_1231181189.key');
curl_setopt($curl, CURLOPT_SSLKEYPASSWD, 'swish');
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://mss.cpc.getswish.net/swish-cpcapi/v1/paymentrequests/',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 30,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"content-type: application/json"
)
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo "Well:" .$response;
}