Aaahh my mistake. I thought you were telling me that I may have somewhere slurping in the STDOUT (i.e a log file).
Ok - so I'm now seeing the debugging, but I'm still baffled with it.
I'm doing a basic curl request to PayPal:
my $results = `curl https://$config->{$config->{mode}}->{transacti
+on_endpoint}/v1/payments/payment/$_[0] -H "Content-Type: application/
+json; charset=utf-8" -H "Authorization: Bearer $token"`;
#my $json_vals = decode_json($results); # also tried just this
my $json_vals = JSON->new->utf8->decode($results);
If I add -v to the command and run it manually, I get:
curl -v https://api.sandbox.paypal.com/v1/payments/payment/PAY-6KY1964
+6FF321593HLCVRQSY -H "Content-Type: application/json; charset=utf-8"
+-H "Authorization: Bearer MY_AUTH_TOKEN"
* Hostname was NOT found in DNS cache
* Trying 173.0.82.78...
* Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS Unknown, Unknown (22):
* SSLv3, TLS handshake, Client hello (1):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Server hello (2):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, CERT (11):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Server finished (14):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, CERT (11):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv2, Unknown (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Finished (20):
* SSLv2, Unknown (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv2, Unknown (22):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / AES256-SHA256
* Server certificate:
* subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; OU=
+PayPal Production; CN=api.sandbox.paypal.com
* start date: 2016-01-13 00:00:00 GMT
* expire date: 2018-01-13 23:59:59 GMT
* subjectAltName: api.sandbox.paypal.com matched
* issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Netwo
+rk; CN=Symantec Class 3 Secure Server CA - G4
* SSL certificate verify ok.
* SSLv2, Unknown (23):
> GET /v1/payments/payment/PAY-6KY19646FF321593HLCVRQSY HTTP/1.1
> User-Agent: curl/7.38.0
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Authorization: Bearer MY_AUTH_TOKEN
>
* SSLv2, Unknown (23):
< HTTP/1.1 200 OK
< Date: Mon, 20 Feb 2017 17:32:59 GMT
* Server Apache is not blacklisted
< Server: Apache
< paypal-debug-id: a347a7a059ab9
< Content-Language: *
< Paypal-Debug-Id: a347a7a059ab9
< Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880
+%26app%3Dplatformapiserv%26TIME%3D1260956504%26HTTP_X_PP_AZ_LOCATOR%3
+D; Expires=Mon, 20 Feb 2017 18:02:59 GMT; domain=.paypal.com; path=/;
+ Secure; HttpOnly
< Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
< Vary: Authorization
< Content-Length: 1853
< Connection: close
< Content-Type: application/json
<
+ óé ","line1":"19 gaskyns close","c
+ity":"Rudgwick","state":"West Sussex","postal_code":"rh123he","countr
+y_code":"GB"},"phone":"07769201576","óé ","line1":"19 gaskyns close
+","city":"Rudgwick","state":"West Sussex","postal_code":"rh123he","co
+untry_code":"GB"}},"related_resources":[{"sale":{"id":"5EH65998225152
+523","state":"pending","amount":{"total":"160.75","currency":"EUR","d
+etails":{"subtotal":"160.75"}},"payment_mode":"INSTANT_TRANSFER* Clos
+ing connection 0
* SSLv2, Unknown (21):
* SSLv3, TLS alert, Client hello (1):
","reason_code":"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION","protect
+ion_eligibility":"INELIGIBLE","parent_payment":"PAY-6KY19646FF321593H
+LCVRQSY","create_time":"2017-02-20T16:25:19Z","update_time":"2017-02-
+20T16:25:36Z","links":[{"href":"https://api.sandbox.paypal.com/v1/pay
+ments/sale/5EH65998225152523","rel":"self","method":"GET"},{"href":"h
+ttps://api.sandbox.paypal.com/v1/payments/sale/5EH65998225152523/refu
+nd","rel":"refund","method":"POST"},{"href":"https://api.sandbox.payp
+al.com/v1/payments/payment/PAY-6KY19646FF321593HLCVRQSY","rel":"paren
+t_payment","method":"GET"}],"soft_descriptor":"PAYPAL *TESTFACILIT"}}
+]}],"create_time":"2017-02-20T16:25:19Z","update_time":"2017-02-20T16
+:25:36Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments
+/payment/PAY-6KY19646FF321593HLCVRQSY","rel":"self","method":"GET"}]
(I'm not in a utf8 session, which is why I guess it looks a bit weird on some parts). The main point though, is that its sending the request as utf8. This is how the string comes out in a Dump();
SV = PV(0x1143890) at 0x11e5758
REFCNT = 1
FLAGS = (POK,pPOK,UTF8)
PV = 0x11a47c0 "Andy\303\255\303\255\303\255\303\255\303\251\303\251
+\303\251 \303\215\303\263\303\251 "\0 [UTF8 "Andy\x{ed}\x{ed}\x{ed}\x
+{ed}\x{e9}\x{e9}\x{e9} \x{cd}\x{f3}\x{e9} "]
CUR = 26
LEN = 28
Maybe I'm missing something? It's been a long day!
UPDATE: Interestingly, if I comment this out of my code:
binmode(STDOUT, ":utf8");
...then it works! (I'm not sure why though, and I don't like things like that! ;)) |