@@ -47,7 +47,7 @@ composer require mastercard/client-encryption
4747A certificate resource can be created from a file by calling ` EncryptionUtils::loadEncryptionCertificate ` :
4848``` php
4949use Mastercard\Developer\Utils\EncryptionUtils;
50- // ...
50+ // …
5151$encryptionCertificate = EncryptionUtils::loadEncryptionCertificate('<insert certificate file path >');
5252```
5353
@@ -60,7 +60,7 @@ Supported certificate formats: PEM, DER.
6060A private key resource can be created from a PKCS #12 key store by calling ` EncryptionUtils::loadDecryptionKey ` the following way:
6161``` php
6262use Mastercard\Developer\Utils\EncryptionUtils;
63- // ...
63+ // …
6464$decryptionKey = EncryptionUtils::loadDecryptionKey(
6565 '<insert PKCS#12 key file path >',
6666 '<insert key alias >',
@@ -72,7 +72,7 @@ $decryptionKey = EncryptionUtils::loadDecryptionKey(
7272A private key resource can be created from an unencrypted key file by calling ` EncryptionUtils::loadDecryptionKey ` the following way:
7373``` php
7474use Mastercard\Developer\Utils\EncryptionUtils;
75- // ...
75+ // …
7676$decryptionKey = EncryptionUtils::loadDecryptionKey('<insert key file path >');
7777```
7878
@@ -98,22 +98,22 @@ The core methods responsible for payload encryption and decryption are `encryptP
9898* ` encryptPayload ` usage:
9999``` php
100100use Mastercard\Developer\Encryption;
101- // ...
101+ // …
102102$encryptedRequestPayload = FieldLevelEncryption::encryptPayload($requestPayload, $config);
103103```
104104
105105* ` decryptPayload ` usage:
106106``` php
107107use Mastercard\Developer\Encryption;
108- // ...
108+ // …
109109$responsePayload = FieldLevelEncryption::decryptPayload($encryptedResponsePayload, $config);
110110```
111111
112112#### Configuring the Field Level Encryption <a name =" configuring-the-field-level-encryption " ></a >
113113Use the ` FieldLevelEncryptionConfigBuilder ` to create ` FieldLevelEncryptionConfig ` instances. Example:
114114``` php
115115use Mastercard\Developer\Encryption;
116- // ...
116+ // …
117117$config = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
118118 ->withEncryptionCertificate($encryptionCertificate)
119119 ->withDecryptionKey($decryptionKey)
@@ -138,7 +138,7 @@ Call `FieldLevelEncryption::encryptPayload` with a JSON request payload and a `F
138138Example using the configuration [ above] ( #configuring-the-field-level-encryption ) :
139139``` php
140140use Mastercard\Developer\Encryption;
141- // ...
141+ // …
142142$payload = '{
143143 "path": {
144144 "to": {
@@ -160,8 +160,8 @@ Output:
160160 "to" : {
161161 "encryptedFoo" : {
162162 "iv" : " 7f1105fb0c684864a189fb3709ce3d28" ,
163- "encryptedKey" : " 67f467d1b653d98411a0c6d3c(...) ffd4c09dd42f713a51bff2b48f937c8" ,
164- "encryptedValue" : " b73aabd267517fc09ed72455c2(...) dffb5fa04bf6e6ce9ade1ff514ed6141"
163+ "encryptedKey" : " 67f467d1b653d98411a0c6d3c… ffd4c09dd42f713a51bff2b48f937c8" ,
164+ "encryptedValue" : " b73aabd267517fc09ed72455c2… dffb5fa04bf6e6ce9ade1ff514ed6141"
165165 }
166166 }
167167 }
@@ -175,14 +175,14 @@ Call `FieldLevelEncryption::decryptPayload` with a JSON response payload and a `
175175Example using the configuration [ above] ( #configuring-the-field-level-encryption ) :
176176``` php
177177use Mastercard\Developer\Encryption;
178- // ...
178+ // …
179179$encryptedPayload = '{
180180 "path": {
181181 "to": {
182182 "encryptedFoo": {
183183 "iv": "e5d313c056c411170bf07ac82ede78c9",
184- "encryptedKey": "e3a56746c0f9109d18b3a2652b76(...) f16d8afeff36b2479652f5c24ae7bd",
185- "encryptedValue": "809a09d78257af5379df0c454dcdf(...) 353ed59fe72fd4a7735c69da4080e74f"
184+ "encryptedKey": "e3a56746c0f9109d18b3a2652b76… f16d8afeff36b2479652f5c24ae7bd",
185+ "encryptedValue": "809a09d78257af5379df0c454dcdf… 353ed59fe72fd4a7735c69da4080e74f"
186186 }
187187 }
188188 }
@@ -211,18 +211,18 @@ Entire payloads can be encrypted using the '$' operator as encryption path:
211211
212212``` php
213213use Mastercard\Developer\Encryption;
214- // ...
214+ // …
215215$config = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
216216 ->withEncryptionCertificate(encryptionCertificate)
217217 ->withEncryptionPath('$', '$')
218- // ...
218+ // …
219219 ->build();
220220```
221221
222222Example:
223223``` php
224224use Mastercard\Developer\Encryption;
225- // ...
225+ // …
226226$payload = '{
227227 "sensitiveField1": "sensitiveValue1",
228228 "sensitiveField2": "sensitiveValue2"
@@ -235,8 +235,8 @@ Output:
235235``` json
236236{
237237 "iv" : " 1b9396c98ab2bfd195de661d70905a45" ,
238- "encryptedKey" : " 7d5112fa08e554e3dbc455d0628(...) 52e826dd10311cf0d63bbfb231a1a63ecc13" ,
239- "encryptedValue" : " e5e9340f4d2618d27f8955828c86(...) 379b13901a3b1e2efed616b6750a90fd379515"
238+ "encryptedKey" : " 7d5112fa08e554e3dbc455d0628… 52e826dd10311cf0d63bbfb231a1a63ecc13" ,
239+ "encryptedValue" : " e5e9340f4d2618d27f8955828c86… 379b13901a3b1e2efed616b6750a90fd379515"
240240}
241241```
242242
@@ -246,22 +246,22 @@ Entire payloads can be decrypted using the '$' operator as decryption path:
246246
247247``` php
248248use Mastercard\Developer\Encryption;
249- // ...
249+ // …
250250$config = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
251251 ->withDecryptionKey(decryptionKey)
252252 ->withDecryptionPath('$', '$')
253- // ...
253+ // …
254254 ->build();
255255```
256256
257257Example:
258258``` php
259259use Mastercard\Developer\Encryption;
260- // ...
260+ // …
261261$encryptedPayload = '{
262262 "iv": "1b9396c98ab2bfd195de661d70905a45",
263- "encryptedKey": "7d5112fa08e554e3dbc455d0628(...) 52e826dd10311cf0d63bbfb231a1a63ecc13",
264- "encryptedValue": "e5e9340f4d2618d27f8955828c86(...) 379b13901a3b1e2efed616b6750a90fd379515"
263+ "encryptedKey": "7d5112fa08e554e3dbc455d0628… 52e826dd10311cf0d63bbfb231a1a63ecc13",
264+ "encryptedValue": "e5e9340f4d2618d27f8955828c86… 379b13901a3b1e2efed616b6750a90fd379515"
265265}';
266266$payload = FieldLevelEncryption::decryptPayload($encryptedPayload, $config);
267267echo (json_encode(json_decode($payload), JSON_PRETTY_PRINT));
@@ -286,7 +286,7 @@ Here is how to configure the library for using HTTP headers instead.
286286Call ` with{Param}HeaderName ` instead of ` with{Param}FieldName ` when building a ` FieldLevelEncryptionConfig ` instance. Example:
287287``` php
288288use Mastercard\Developer\Encryption;
289- // ...
289+ // …
290290$config = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
291291 ->withEncryptionCertificate(encryptionCertificate)
292292 ->withDecryptionKey(decryptionKey)
@@ -296,7 +296,7 @@ $config = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
296296 ->withEncryptedValueFieldName('data')
297297 ->withIvHeaderName('x-iv')
298298 ->withEncryptedKeyHeaderName('x-encrypted-key')
299- // ...
299+ // …
300300 ->withFieldValueEncoding(FieldValueEncoding::HEX)
301301 ->build();
302302```
@@ -320,7 +320,7 @@ $params = FieldLevelEncryptionParams::generate($config);
320320``` php
321321$request->setHeader($config->getIvHeaderName(), $params->getIvValue());
322322$request->setHeader($config->getEncryptedKeyHeaderName(), $params->getEncryptedKeyValue());
323- // ...
323+ // …
324324```
325325
3263263 . Call ` encryptPayload ` with params:
@@ -342,7 +342,7 @@ echo (json_encode(json_decode($encryptedPayload), JSON_PRETTY_PRINT));
342342Output:
343343``` json
344344{
345- "data" : " 53b5f07ee46403af2e92abab900853(...) d560a0a08a1ed142099e3f4c84fe5e5"
345+ "data" : " 53b5f07ee46403af2e92abab900853… d560a0a08a1ed142099e3f4c84fe5e5"
346346}
347347```
348348
@@ -355,13 +355,13 @@ Decryption can be performed using the following steps:
355355``` php
356356$ivValue = $response->getHeader($config->getIvHeaderName());
357357$encryptedKeyValue = $response->getHeader($config->getEncryptedKeyHeaderName());
358- // ...
358+ // …
359359```
360360
3613612 . Create a ` FieldLevelEncryptionParams ` instance:
362362
363363``` php
364- $params = new FieldLevelEncryptionParams($config, $ivValue, $encryptedKeyValue, ... , );
364+ $params = new FieldLevelEncryptionParams($config, $ivValue, $encryptedKeyValue, … , );
365365```
366366
3673673 . Call ` decryptPayload ` with params:
@@ -373,7 +373,7 @@ Example using the configuration [above](#configuration-for-using-http-headers):
373373
374374``` php
375375$encryptedPayload = '{
376- "data": "53b5f07ee46403af2e92abab900853(...) d560a0a08a1ed142099e3f4c84fe5e5"
376+ "data": "53b5f07ee46403af2e92abab900853… d560a0a08a1ed142099e3f4c84fe5e5"
377377}';
378378$payload = FieldLevelEncryption::decryptPayload($encryptedPayload, $config, $params);
379379echo (json_encode(json_decode($payload), JSON_PRETTY_PRINT));
@@ -404,10 +404,10 @@ Generators currently supported:
404404
405405Client libraries can be generated using the following command:
406406``` shell
407- java -jar openapi-generator-cli.jar generate -i openapi-spec.yaml -g php -o out
407+ openapi-generator-cli generate -i openapi-spec.yaml -g php -o out
408408```
409409See also:
410- * [ OpenAPI Generator (executable) ] ( https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli )
410+ * [ OpenAPI Generator CLI Installation ] ( https://openapi-generator.tech/docs/installation/ )
411411* [ CONFIG OPTIONS for php] ( https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/php.md )
412412
413413##### Usage of the ` PsrHttpMessageEncryptionInterceptor `
@@ -418,12 +418,12 @@ use OpenAPI\Client\Api\ServiceApi;
418418use OpenAPI\Client\Configuration
419419use Mastercard\Developer\Signers\PsrHttpMessageSigner;
420420use Mastercard\Developer\Interceptors\PsrHttpMessageEncryptionInterceptor;
421- // ...
421+ // …
422422
423423$stack = new GuzzleHttp\HandlerStack();
424424$stack->setHandler(new GuzzleHttp\Handler\CurlHandler());
425425$fieldLevelEncryptionConfig = FieldLevelEncryptionConfigBuilder::aFieldLevelEncryptionConfig()
426- // ...
426+ // …
427427 ->build();
428428$fieldLevelEncryptionInterceptor = new PsrHttpMessageEncryptionInterceptor($fieldLevelEncryptionConfig);
429429$stack->push(GuzzleHttp\Middleware::mapRequest([$fieldLevelEncryptionInterceptor, 'interceptRequest']));
@@ -434,5 +434,5 @@ $client = new GuzzleHttp\Client($options);
434434$config = new Configuration();
435435$config->setHost('https://sandbox.api.mastercard.com');
436436$serviceApi = new ServiceApi($client, $config);
437- // ...
437+ // …
438438```
0 commit comments