@pixelpay/sdk-core 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/deploy.js +92 -0
- package/index.html +9 -11
- package/lib/browser/index.js +3 -3
- package/lib/libraries/CardinalManager.js +7 -4
- package/lib/libraries/CardinalManager.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -2
- package/tests/Tokenization.test.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ El formato se basa en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
5
5
|
y este proyecto se adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
Tipos de cambios: `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`.
|
|
7
7
|
|
|
8
|
+
## [v2.4.1] - 2025-05-20
|
|
9
|
+
### Added
|
|
10
|
+
- Se agregó soporte para autenticación de 3D Secure con Cardinal API
|
|
11
|
+
|
|
8
12
|
## [v2.4.0] - 2025-03-13
|
|
9
13
|
### Added
|
|
10
14
|
- Se agregó autenticación de 3D Secure con Cybersource
|
package/deploy.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
|
|
2
|
+
const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront');
|
|
3
|
+
const { version } = require('./package.json');
|
|
4
|
+
const dotenv = require('dotenv');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
const filePath = path.join('lib', 'browser', 'index.js');
|
|
11
|
+
const isBeta = version.includes('beta');
|
|
12
|
+
|
|
13
|
+
const bucketName = process.env.S3_BUCKET_NAME;
|
|
14
|
+
const cloudfrontDistributionId = process.env.CLOUDFRONT_DISTRIBUTION_ID;
|
|
15
|
+
const domain = process.env.DOMAIN_NAME;
|
|
16
|
+
|
|
17
|
+
const s3Path = 'sdk/';
|
|
18
|
+
const versionedFile = `${s3Path}sdk-core@${version}.js`;
|
|
19
|
+
const latestFile = `${s3Path}sdk-core.js`;
|
|
20
|
+
|
|
21
|
+
const awsCredentials = {
|
|
22
|
+
region: process.env.AWS_REGION,
|
|
23
|
+
credentials: {
|
|
24
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
25
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const s3 = new S3Client(awsCredentials);
|
|
30
|
+
const cloudfront = new CloudFrontClient(awsCredentials);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Uploads a file to an Amazon S3 bucket.
|
|
34
|
+
* @param {string} fileName - The name of the file to be uploaded to the S3 bucket.
|
|
35
|
+
* @returns {Promise<void>} A promise that resolves when the file is successfully uploaded.
|
|
36
|
+
*/
|
|
37
|
+
async function uploadToS3(fileName) {
|
|
38
|
+
try {
|
|
39
|
+
const fileContent = fs.readFileSync(filePath);
|
|
40
|
+
|
|
41
|
+
const params = {
|
|
42
|
+
Bucket: bucketName,
|
|
43
|
+
Key: fileName,
|
|
44
|
+
Body: fileContent,
|
|
45
|
+
ContentType: 'application/javascript',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await s3.send(new PutObjectCommand(params));
|
|
49
|
+
console.log(`Archivo subido con éxito: https://${bucketName}.s3.amazonaws.com/${fileName}`);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(`Error al subir el archivo (${fileName}):`, error);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Invalidates the CloudFront cache for a specific file.
|
|
58
|
+
* @param {string} fileName - The name of the file (including its path) to invalidate in the CloudFront cache.
|
|
59
|
+
* @returns {Promise<void>} A promise that resolves when the cache invalidation is successfully completed.
|
|
60
|
+
*/
|
|
61
|
+
async function invalidateCloudFrontCache(fileName) {
|
|
62
|
+
try {
|
|
63
|
+
const params = {
|
|
64
|
+
DistributionId: cloudfrontDistributionId,
|
|
65
|
+
InvalidationBatch: {
|
|
66
|
+
Paths: {
|
|
67
|
+
Quantity: 1,
|
|
68
|
+
Items: [`/${fileName}`],
|
|
69
|
+
},
|
|
70
|
+
CallerReference: `${Date.now()}`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
await cloudfront.send(new CreateInvalidationCommand(params));
|
|
75
|
+
console.log(`Caché invalidado en CloudFront para /${fileName}`);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Error al invalidar caché:', error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
(async () => {
|
|
82
|
+
await uploadToS3(versionedFile);
|
|
83
|
+
console.log(`Archivo disponible en: ${domain}/${versionedFile}`);
|
|
84
|
+
|
|
85
|
+
if (!isBeta) {
|
|
86
|
+
await uploadToS3(latestFile);
|
|
87
|
+
await invalidateCloudFrontCache(latestFile);
|
|
88
|
+
console.log(`Archivo disponible en: ${domain}/${latestFile}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log('Publicación completada');
|
|
92
|
+
})();
|
package/index.html
CHANGED
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
<div class="row">
|
|
57
57
|
<div class="column">
|
|
58
58
|
<fieldset>
|
|
59
|
-
<legend>
|
|
60
|
-
<input type="text" name="
|
|
59
|
+
<legend>ORDER ID</legend>
|
|
60
|
+
<input type="text" name="order_id" placeholder="ORDER-TEST" value="ORDER-FA168BDFFCB2">
|
|
61
61
|
</fieldset>
|
|
62
62
|
</div>
|
|
63
63
|
<div class="column">
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
<div class="column">
|
|
149
149
|
<fieldset>
|
|
150
150
|
<legend>Expire Year</legend>
|
|
151
|
-
<input type="number" name="expire_year" value="
|
|
151
|
+
<input type="number" name="expire_year" value="2028">
|
|
152
152
|
</fieldset>
|
|
153
153
|
</div>
|
|
154
154
|
<div class="column">
|
|
@@ -199,14 +199,12 @@
|
|
|
199
199
|
|
|
200
200
|
</main>
|
|
201
201
|
|
|
202
|
-
<script src="https://
|
|
202
|
+
<!-- <script src="https://cdn.jsdelivr.net/npm/@pixelpay/sdk-core"></script> -->
|
|
203
203
|
<script src="./lib/browser/index.js"></script>
|
|
204
204
|
|
|
205
205
|
<script>
|
|
206
206
|
function prepareEndpoint(settings) {
|
|
207
|
-
|
|
208
|
-
settings.setupEndpoint('https://quaint-sun-m6hdeua0rg1q.vapor-farm-e1.com');
|
|
209
|
-
settings.setupCredentials('2212294583', '189cd6e744b68421551c545047fb9fe2');
|
|
207
|
+
settings.setupSandbox();
|
|
210
208
|
}
|
|
211
209
|
|
|
212
210
|
function getCard() {
|
|
@@ -233,7 +231,7 @@
|
|
|
233
231
|
|
|
234
232
|
function getOrder() {
|
|
235
233
|
const order = new Models.Order();
|
|
236
|
-
order.id = document.querySelector('input[name="
|
|
234
|
+
order.id = document.querySelector('input[name="order_id"]').value || 'TEST-1234';
|
|
237
235
|
order.currency = document.querySelector('select[name="currency"]').value;
|
|
238
236
|
order.amount = parseFloat(document.querySelector('input[name=amount]').value);
|
|
239
237
|
order.customer_name = 'Jhon Doe';
|
|
@@ -328,7 +326,7 @@
|
|
|
328
326
|
|
|
329
327
|
const service = new Services.Transaction(settings);
|
|
330
328
|
const capture = new Requests.CaptureTransaction();
|
|
331
|
-
capture.payment_uuid = document.querySelector('input[name="
|
|
329
|
+
capture.payment_uuid = document.querySelector('input[name="order_id"]').value
|
|
332
330
|
capture.transaction_approved_amount = 1.00;
|
|
333
331
|
|
|
334
332
|
service.doCapture(capture).then(response => {
|
|
@@ -351,7 +349,7 @@
|
|
|
351
349
|
|
|
352
350
|
const service = new Services.Transaction(settings);
|
|
353
351
|
const voidTx = new Requests.VoidTransaction();
|
|
354
|
-
voidTx.payment_uuid = document.querySelector('input[name="
|
|
352
|
+
voidTx.payment_uuid = document.querySelector('input[name="order_id"]').value
|
|
355
353
|
voidTx.void_reason = 'Transaction Test';
|
|
356
354
|
|
|
357
355
|
service.doVoid(voidTx).then(response => {
|
|
@@ -370,7 +368,7 @@
|
|
|
370
368
|
const service = new Services.Transaction(settings);
|
|
371
369
|
|
|
372
370
|
const statusTx = new Requests.StatusTransaction();
|
|
373
|
-
statusTx.payment_uuid = document.querySelector('input[name="
|
|
371
|
+
statusTx.payment_uuid = document.querySelector('input[name="order_id"]').value
|
|
374
372
|
|
|
375
373
|
service.getStatus(statusTx).then(response => {
|
|
376
374
|
showResponse(response.toJson())
|