Closed elr0berto closed 7 years ago
Please refer to the official swish docs. This library is not doing any manipulation of the responses so if you're getting 200 OK
back you should be all good. Copy-pasta from the docs, section 11.1.3:
curl -v --request POST https://swicpc.bankgirot.se/swishcpcapi/api/v1/paymentrequests
\
--header "Content-Type: application/json" \
--data @- <<!
{
"payeePaymentReference": "0123456789",
"callbackUrl": "https://example.com/api/swishcb/paymentrequests",
"payerAlias": "46701234567",
"payeeAlias": "1234760039",
"amount": "100",
"currency": "SEK",
"message": "Kingston USB Flash Drive 8 GB"
}
!
< HTTP/1.1 201 Created
< Location: https://swicpc.bankgirot.se/swishcpcapi/api/v1/paymentrequests/AB23D7406ECE4542A80152D909EF9F6B
As you can see the response only contains a header with a link to the payment request. You may use this method to extract the ID.
It works when i get the response from $client->getPaymentRequest() and then decode it .. not sure why... anyway, I'm happy that this works now :)
Thanks for the good work Helmut :)
$id = Util::getPaymentRequestIdFromResponse($res); $res = $client->getPaymentRequest($id); $body = Util::decodeResponse($res); // now it works ..
My code:
Response in command line:
Any idea why I don't get a full response?