Swish はスウェーデンの決済プロバイダーです。電話番号に送金するだけでお支払いいただけます。
これは、Swish が提供する新しい PAYOUT サービスの API です。PAYMENTサービスと同じではないので、混同しないでください。
彼らの Web サイトには PHP の例がなく、200 の応答を得ることができません。
あなたのプロがこれを解決するのを手伝ってくれるなら、他の多くの人が将来的にこの解決策から恩恵を受けることができると思います.
これが私の現在のコードです。
$payload = [
"payoutInstructionUUID" => "E4D773858AF5459B96ABCA4B9DBFF94D",
"payerPaymentReference" => "payerRef",
"payerAlias" => "1231388446",
"payeeAlias" => "46712345678",
"payeeSSN" => "198602111638",
"amount" => "100.00",
"currency" => "SEK",
"payoutType" => "PAYOUT",
"message" => "Message to the recipient.",
"instructionDate" => carbon::now(),
"signingCertificateSerialNumber" => "667A2C6E068B76988AB657351F5AF636"
];
$pkey = openssl_pkey_get_private(file_get_contents('Swish_Merchant_TestSigningCertificate_1234679304.key'), 'swish');
$payloadHash = hash('sha512', json_encode($payload));
$signature = openssl_sign($payloadHash, $signature, $pkey) ? base64_encode($signature) : null;
$request = [
"payload" => $payload,
"callbackUrl" => "https://postb.in/1634560192746-3820346647407",
"signature" => $signature
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://mss.cpc.getswish.net/swish-cpcapi/api/v1/payouts');
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSLCERT, 'Swish_Merchant_TestCertificate_1234679304.p12');
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'P12');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'swish');
curl_setopt($ch, CURLOPT_SSLKEY, 'Swish_Merchant_TestCertificate_1234679304.key');
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'swish');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_CAINFO, 'Swish_TLS_RootCA.pem');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
$f = tmpfile();
curl_setopt($ch, CURLOPT_STDERR, $f);
$results = curl_exec($ch);
fseek($f, 0);
echo "Verbose information:\n<pre>", fread($f, 32 * 1024), "</pre>\n";
fclose($f);
$info =curl_errno($ch)>0 ? array("curl_error_".curl_errno($ch)=>curl_error($ch)) : curl_getinfo($ch);
print_r($info);
curl_close($ch);
それは私にこの応答を与えます
* Trying 213.132.115.90:443...
* Connected to mss.cpc.getswish.net (213.132.115.90) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: Swish_TLS_RootCA.pem
* CApath: none
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=SE; ST=Stockholms l�n; L=Stockholm; O=GetSwish AB; OU=IT; CN=mss.cpc.getswish.net
* start date: Feb 18 00:00:00 2020 GMT
* expire date: May 19 12:00:00 2022 GMT
* subjectAltName: host "mss.cpc.getswish.net" matched cert's "mss.cpc.getswish.net"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018
* SSL certificate verify ok.
> POST /swish-cpcapi/api/v1/payouts HTTP/1.1
Host: mss.cpc.getswish.net
Accept: */*
Content-Type:application/json
Content-Length: 1172
* Mark bundle as not supporting multiuse
< HTTP/1.1 400
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Thu, 21 Oct 2021 19:52:53 GMT
< Connection: close
<
* Closing connection 0
[
{
"errorCode":"PA01",
"errorMessage":"Parameter is not correct.",
"additionalInformation":null
}
]
ご覧のとおり、応答はあまり正確ではありません。何が問題なのか教えてください。署名をノンスに変更しようとしましたが、それでも同じエラー メッセージが表示されます。これは、署名が間違っていると私に信じさせます。
テスト環境には登録は必要ありません。これは、自分のコンピューターでテストできます。
ドキュメントへのリンクは次のとおりですhttps://developer.swish.nu/documentation/getting-started/swish-payout-api
証明書はここにあります (証明書の管理の下) https://developer.swish.nu/documentation/environments