From 3f7773859046a266b24418392721e53d7d50b167 Mon Sep 17 00:00:00 2001 From: xanadu-3g <75958256+xanadu-3g@users.noreply.github.com> Date: Mon, 14 Dec 2020 02:15:14 +0100 Subject: [PATCH 1/2] Fix curl when getting statements It fixes 2 related bugs, when sending getStatement API calls. First SCA header fields were only added to POST requests, but getStatement is a GET and needs SCA depending on account country. And SCA->path doesn't contain the required GET parameters, such as currency. --- code/includes/class_TransferWise.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/includes/class_TransferWise.php b/code/includes/class_TransferWise.php index bc7455d..c2c95ab 100644 --- a/code/includes/class_TransferWise.php +++ b/code/includes/class_TransferWise.php @@ -274,14 +274,14 @@ private function curl($mode, $curl_url,$data=NULL,$headers=NULL){ $payload = json_encode($data); $headerArray[] = "Content-Type: application/json"; $headerArray[] = 'Content-Length: ' . strlen($payload); - if($headers){ + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); + } + if($headers){ foreach($headers as $header){ $headerArray[] = $header; } - } - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); } - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); //Reset One Time Token @@ -311,7 +311,7 @@ private function curl($mode, $curl_url,$data=NULL,$headers=NULL){ } $headers[] = "x-2fa-approval: $this->OTT"; $headers[] = "X-Signature: $Xsignature"; - $response = $this->curl($mode, $SCA->path,$data,$headers); + $response = $this->curl($mode,$curl_url,$data,$headers); } } From f5b2abdab6c45c6833b1bb53e74947d8dc799af1 Mon Sep 17 00:00:00 2001 From: xanadu-3g <75958256+xanadu-3g@users.noreply.github.com> Date: Mon, 14 Dec 2020 02:19:30 +0100 Subject: [PATCH 2/2] Initial comment --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bcc772a..19e8009 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # TransferWise Simple API PHP Class +# It's a fork from robclark56's to iron out a few bugs, and deprecated calls in newer php versions. + ## Introduction This PHP class is completely standalone; it does not require composer to bring in other code. As such this is a light-weight module for easy inclusion into bigger projects.