Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
POST the whole JSON object at once
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott A Connerly committed Mar 27, 2018
1 parent c16fc2b commit a8b2b56
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/PaymentSpring.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public static function makeRequest($path, $params = array(), $isPost = false){
$curlOptions = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => self::$apiBaseURL . $path,
CURLOPT_HTTPHEADER => array('Authorization: Basic '. base64_encode( self::$privateKey . ":" ) )
CURLOPT_HTTPHEADER => [
'Authorization: Basic '. base64_encode( self::$privateKey . ":" ),
'Content-Type: application/json'
]
);
if($isPost){
$curlOptions = self::constructPostRequest($curlOptions, $params);
Expand All @@ -57,12 +60,7 @@ public static function makeRequest($path, $params = array(), $isPost = false){

public static function constructPostRequest($options, $params){
$options[CURLOPT_POST] = TRUE;
foreach($params as $k => $v){
if(is_array($v)){
$params[$k] = json_encode($v);
}
}
$options[CURLOPT_POSTFIELDS] = $params;
$options[CURLOPT_POSTFIELDS] = json_encode($params);
return $options;
}

Expand Down

0 comments on commit a8b2b56

Please sign in to comment.