Open VerilySoft opened 7 years ago
Hi Stephane (@VerilySoft) ,
I have checked the logs related to this request and no data was sent with the curl.
Could you please use the below code replacing with your ServiceKey and Token
curl https://api.worldpay.com/v1/orders -H "Authorization:<T_S_value>" -H "Content-type: application/json" -X POST -d '{ "token" : "<TEST_TOKEN>", "orderDescription" : "your-order-description", "amount" : 500, "currencyCode" : "GBP" }'
I just sent a request and here are the details (with my service key and token hidden here for privacy):
root@vps151644:~# curl -v https://api.worldpay.com/v1/orders -H "Authorization:T_S_c8<HIDDEN>" -H "Content-type: application/json" -X POST -d '{ "token" : "TEST_RU_<HIDDEN>", "orderDescription" : "your-order-description", "amount" : 500, "currencyCode" : "GBP" }'
* Adding handle: conn: 0x1121b90
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1121b90) send_pipe: 1, recv_pipe: 0
* About to connect() to api.worldpay.com port 443 (#0)
* Trying 52.19.201.7...
* Connected to api.worldpay.com (52.19.201.7) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES128-SHA
* Server certificate:
* subject: C=GB; ST=London; L=London; O=WorldPay (UK) Ltd; CN=api.worldpay.com
* start date: 2016-09-20 00:00:00 GMT
* expire date: 2018-09-21 23:59:59 GMT
* subjectAltName: api.worldpay.com matched
* issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 Secure Server CA - G4
* SSL certificate verify ok.
> POST /v1/orders HTTP/1.1
> User-Agent: curl/7.32.0
> Host: api.worldpay.com
> Accept: */*
> Authorization:T_S_c8d<HIDDEN>
> Content-type: application/json
> Content-Length: 147
>
* upload completely sent off: 147 out of 147 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json;charset=UTF-8
< Date: Fri, 25 Nov 2016 14:23:02 GMT
< requestId: c59a05d3-e80a-470b-b6c0-e259e65f87b5
* Server Windows NT 3.x is not blacklisted
< Server: Windows NT 3.x
< X-Content-Type-Options: nosniff
< Content-Length: 393
< Connection: keep-alive
<
* Connection #0 to host api.worldpay.com left intact
{"httpStatusCode":400,"customCode":"BAD_REQUEST","message":"CVC can't be null/empty","description":"Some of request parameters are invalid, please check your request. For more information please refer to Json schema.","errorHelpUrl":null,"originalRequest":"{'token':'TEST_RU_5<HIDDEN>','orderDescription':'your-order-description','amount':500,'currencyCode':'GBP'}"}
Notice, I got this card token after sending the test card details which include the CVC. Here, I understand we're just charging the card and it asks for the CVC.
@VerilySoft That httpResponse appears to be from the second time you've executed that order with the reusable token, is that correct? Could you please provide the first response?
I don't have the first full response because I executed it in a console window I closed. I just run the request you ask me to. I don't have the full response but I added a part in the top:
< HTTP/1.1 400 Bad Request
< Content-Type: application/json;charset=UTF-8
< Date: Fri, 25 Nov 2016 08:19:49 GMT
< requestId: ef0e0b6b-8a50-4810-b8d1-bbc77d1a7753
* Server Windows NT 3.x is not blacklisted
< Server: Windows NT 3.x
< X-Content-Type-Options: nosniff
< Content-Length: 221
< Connection: keep-alive
<
{"httpStatusCode":400,"customCode":"ERROR_PARSING_JSON","message":"Error parsing json, please check json request","description":"Error parsing Json, please refer to json schema","errorHelpUrl":null,"originalRequest":"'{"}* Connection #0 to host api.worldpay.com left intact
The first request I made was done from the browser in JavaScript. Then it passed the token to the web server to charge the customer. The issue then appears here.
Hello, any idea what would be the issue. I created a token from JavaScript then try charging card from server where it reported JSON format isn't valid while it is.
@VerilySoft Can you please confirm that the token you created from Javascript has not been used yet, as this error is often present when you try to reuse a token.
What about when I set reusable to true ?
You shouldn't get 400's with this particular request with reusable=true;
Hello,
Happy new year 2017 to you!
Can you please check this issue for me ? I'm coming back to you because our business strongly relies on this to be fixed.
What I did is the following:
<script type="text/javascript">
var form = document.getElementById('paymentForm');
Worldpay.useOwnForm({
'clientKey': 'used-our-test-client-key',
'form': form,
'reusable': false,
'callback': function(status, response) {
document.getElementById('paymentErrors').innerHTML = '';
if (response.error) {
Worldpay.handleError(form, document.getElementById('paymentErrors'), response.error);
} else {
var token = response.token;
Worldpay.formBuilder(form, 'input', 'hidden', 'token', token);
form.submit();
}
}
});
</script>
Worldpay API server returned this token: TEST_RU_2c1df9c0-d5a1-4f75-ad1c-e00ffeca8c1a
{"billingAddress":{"address1":"25883 N PARK AVE STE 511869","address2":"","address3":"","postalCode":"46514","city":"ELKHART","state":"IN","countryCode":"US"},"token":"TEST_RU_2c1df9c0-d5a1-4f75-ad1c-e00ffeca8c1a","orderDescription":"Demo Shop - Order 156","amount":19.8,"currencyCode":"USD","name":"Mike Vest","customerOrderCode":156}
As you can see this JSON code is valid and you can try re-sending this json with a command line utility like curl or wget and you'll see what I'm talking about. This token is a reusable token.
Array
(
[httpStatusCode] => 400
[customCode] => ERROR_PARSING_JSON
[message] => Error parsing json, please check json request
[description] => Error parsing Json, please refer to json schema
[errorHelpUrl] =>
[originalRequest] => {'billingAddress':{'address1':'25883 N PARK AVE STE 511869','address2':'','address3':'','postalCode':'46514','city':'ELKHART','state':'IN','countryCode':'US'},'token':'TEST_RU_2c1df9c0-d5a1-4f75-ad1c-e00ffeca8c1a','orderDescription':'Demo Shop - Order 156','amount':19.8,'currencyCode':'USD','name':'Mike Vest','customerOrderCode':156}
)
Please check it because the returned error isn't correct but at least if there's an error it's good to return a relevant error to help us fix the correct issue.
Thanks in advance,
Stephane
I'm having the same issue, no real error message passed back, apart from "Error parsing json, please check json request". As the WorldPay library is used to send the JSON, I presume this is either a bug in the library or an error that doesn't actually describe the problem?
I've found what was causing the issue for me (I was sending a non integer amount). @VerilySoft looks like that was the same issue in your JSON you were sending,
Best to double check the JSON string you send as WorldPay doesn't return useful errors. You can do that in the sendRequest function in the Connection class.
Hope that helps someone in future!
I've found what was causing the issue for me (I was sending a non integer amount). @VerilySoft looks like that was the same issue in your JSON you were sending,
Best to double check the JSON string you send as WorldPay doesn't return useful errors. You can do that in the sendRequest function in the Connection class.
Hope that helps someone in future!
Thank you. I solved my problem is same
I'm also having the same problem. But my case is different. Through payment form token generated and charges also happened. When I'm trying to do recurring payment with reusable token Id at the time I'm getting response JSON parse error like that . For the same request data I just removed Address value then It is charging. I have checked my merchant portal by disabling/enabling address verification option even though I'm getting same error.
If world pay returning with proper api response particular error . I could be better to show end user to change their input during charges.
Common error response creating lot of support issue.
Please try to address actual problem for immediate solution.
Hello,
I'm experiencing issues creating order with Worldpay API. I tried running your own call as found here https://developer.worldpay.com/jsonapi/docs/make-payment:
curl https://api.worldpay.com/v1/orders -H "Authorization:T_S_<HIDDEN>" -H "Content-type: application/json" -X POST -d '{ "token" : "TEST_SU_<HIDDEN>", "orderDescription" : "your-order-description", "amount" : 500, "currencyCode" : "GBP" }'
and here's what I get:
Can you check it please ?
Stephane