Skip to content

Commit 3c2781e

Browse files
committed
+ OAuth Changes
1 parent 7d55a15 commit 3c2781e

File tree

2 files changed

+61
-42
lines changed

2 files changed

+61
-42
lines changed

generator/cybersource-php-template/ApiClient.mustache

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,13 @@ class ApiClient
220220
$postData = json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($postData));
221221
}
222222
$resourcePath= utf8_encode($resourcePath);
223-
$authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath);
224-
$headers = array_merge($headers, $authHeader);
223+
224+
if($this->merchantConfig->getAuthenticationType() != GlobalParameter::MUTUAL_AUTH)
225+
{
226+
$authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath);
227+
$headers = array_merge($headers, $authHeader);
228+
}
229+
225230
foreach ($headers as $value) {
226231
$splitArr= explode(":", $value, 2);
227232
$this->config->addRequestHeader($splitArr[0], $splitArr[1]);
@@ -326,6 +331,15 @@ class ApiClient
326331
curl_setopt($curl, CURLOPT_HEADER, 1);
327332
}
328333

334+
// Adding Client Cert if Required
335+
if($this->merchantConfig->getEnableClientCert())
336+
{
337+
$clientCertPath = $this->merchantConfig->getClientCertDirectory().$this->merchantConfig->getClientCertFile();
338+
curl_setopt($curl, CURLOPT_SSLCERT, $clientCertPath);
339+
curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'P12');
340+
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $this->merchantConfig->getClientCertPassword());
341+
}
342+
329343
// Make the request
330344
$response = curl_exec($curl);
331345

@@ -530,6 +544,11 @@ class ApiClient
530544
'Authorization:'.$getToken
531545
);
532546
}
547+
else if($merchantConfig->getAuthenticationType()==GlobalParameter::OAUTH){
548+
$headers = array(
549+
'Authorization:'.$getToken
550+
);
551+
}
533552
else{
534553
echo "Invalid Authentication type!";
535554
}

lib/Model/CreateAccessTokenRequest.php

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ class CreateAccessTokenRequest implements ArrayAccess
4343
* @var string[]
4444
*/
4545
protected static $swaggerTypes = [
46-
'refreshToken' => 'string',
47-
'grantType' => 'string',
46+
'refresh_token' => 'string',
47+
'grant_type' => 'string',
4848
'code' => 'string',
49-
'clientId' => 'string',
50-
'clientSecret' => 'string'
49+
'client_id' => 'string',
50+
'client_secret' => 'string'
5151
];
5252

5353
/**
5454
* Array of property to format mappings. Used for (de)serialization
5555
* @var string[]
5656
*/
5757
protected static $swaggerFormats = [
58-
'refreshToken' => null,
59-
'grantType' => null,
58+
'refresh_token' => null,
59+
'grant_type' => null,
6060
'code' => null,
61-
'clientId' => null,
62-
'clientSecret' => null
61+
'client_id' => null,
62+
'client_secret' => null
6363
];
6464

6565
public static function swaggerTypes()
@@ -77,11 +77,11 @@ public static function swaggerFormats()
7777
* @var string[]
7878
*/
7979
protected static $attributeMap = [
80-
'refreshToken' => 'refresh_token',
81-
'grantType' => 'grant_type',
80+
'refresh_token' => 'refresh_token',
81+
'grant_type' => 'grant_type',
8282
'code' => 'code',
83-
'clientId' => 'client_id',
84-
'clientSecret' => 'client_secret'
83+
'client_id' => 'client_id',
84+
'client_secret' => 'client_secret'
8585
];
8686

8787

@@ -90,11 +90,11 @@ public static function swaggerFormats()
9090
* @var string[]
9191
*/
9292
protected static $setters = [
93-
'refreshToken' => 'setRefreshToken',
94-
'grantType' => 'setGrantType',
93+
'refresh_token' => 'setRefreshToken',
94+
'grant_type' => 'setGrantType',
9595
'code' => 'setCode',
96-
'clientId' => 'setClientId',
97-
'clientSecret' => 'setClientSecret'
96+
'client_id' => 'setClientId',
97+
'client_secret' => 'setClientSecret'
9898
];
9999

100100

@@ -103,11 +103,11 @@ public static function swaggerFormats()
103103
* @var string[]
104104
*/
105105
protected static $getters = [
106-
'refreshToken' => 'getRefreshToken',
107-
'grantType' => 'getGrantType',
106+
'refresh_token' => 'getRefreshToken',
107+
'grant_type' => 'getGrantType',
108108
'code' => 'getCode',
109-
'clientId' => 'getClientId',
110-
'clientSecret' => 'getClientSecret'
109+
'client_id' => 'getClientId',
110+
'client_secret' => 'getClientSecret'
111111
];
112112

113113
public static function attributeMap()
@@ -141,11 +141,11 @@ public static function getters()
141141
*/
142142
public function __construct(array $data = null)
143143
{
144-
$this->container['refreshToken'] = isset($data['refreshToken']) ? $data['refreshToken'] : null;
145-
$this->container['grantType'] = isset($data['grantType']) ? $data['grantType'] : null;
144+
$this->container['refresh_token'] = isset($data['refresh_token']) ? $data['refresh_token'] : null;
145+
$this->container['grant_type'] = isset($data['grant_type']) ? $data['grant_type'] : null;
146146
$this->container['code'] = isset($data['code']) ? $data['code'] : null;
147-
$this->container['clientId'] = isset($data['clientId']) ? $data['clientId'] : null;
148-
$this->container['clientSecret'] = isset($data['clientSecret']) ? $data['clientSecret'] : null;
147+
$this->container['client_id'] = isset($data['client_id']) ? $data['client_id'] : null;
148+
$this->container['client_secret'] = isset($data['client_secret']) ? $data['client_secret'] : null;
149149
}
150150

151151
/**
@@ -174,41 +174,41 @@ public function valid()
174174

175175

176176
/**
177-
* Gets refreshToken
177+
* Gets refresh_token
178178
* @return string
179179
*/
180180
public function getRefreshToken()
181181
{
182-
return $this->container['refreshToken'];
182+
return $this->container['refresh_token'];
183183
}
184184

185185
/**
186-
* Sets refreshToken
186+
* Sets refresh_token
187187
* @return $this
188188
*/
189189
public function setRefreshToken($refreshToken)
190190
{
191-
$this->container['refreshToken'] = $refreshToken;
191+
$this->container['refresh_token'] = $refreshToken;
192192

193193
return $this;
194194
}
195195

196196
/**
197-
* Gets grantType
197+
* Gets grant_type
198198
* @return string
199199
*/
200200
public function getGrantType()
201201
{
202-
return $this->container['grantType'];
202+
return $this->container['grant_type'];
203203
}
204204

205205
/**
206-
* Sets grantType
206+
* Sets grant_type
207207
* @return $this
208208
*/
209209
public function setGrantType($grantType)
210210
{
211-
$this->container['grantType'] = $grantType;
211+
$this->container['grant_type'] = $grantType;
212212

213213
return $this;
214214
}
@@ -234,41 +234,41 @@ public function setCode($code)
234234
}
235235

236236
/**
237-
* Gets clientId
237+
* Gets client_id
238238
* @return string
239239
*/
240240
public function getClientId()
241241
{
242-
return $this->container['clientId'];
242+
return $this->container['client_id'];
243243
}
244244

245245
/**
246-
* Sets clientId
246+
* Sets client_id
247247
* @return $this
248248
*/
249249
public function setClientId($clientId)
250250
{
251-
$this->container['clientId'] = $clientId;
251+
$this->container['client_id'] = $clientId;
252252

253253
return $this;
254254
}
255255

256256
/**
257-
* Gets clientSecret
257+
* Gets client_secret
258258
* @return string
259259
*/
260260
public function getClientSecret()
261261
{
262-
return $this->container['clientSecret'];
262+
return $this->container['client_secret'];
263263
}
264264

265265
/**
266-
* Sets clientSecret
266+
* Sets client_secret
267267
* @return $this
268268
*/
269269
public function setClientSecret($clientSecret)
270270
{
271-
$this->container['clientSecret'] = $clientSecret;
271+
$this->container['client_secret'] = $clientSecret;
272272

273273
return $this;
274274
}

0 commit comments

Comments
 (0)