@cloudcommerce/app-pagarme-v5 2.9.0 → 2.10.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"pagarme-v5-events.js","sourceRoot":"","sources":["../src/pagarme-v5-events.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,EACL,uBAAuB,GAExB,MAAM,4CAA4C,CAAC;AACpD,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AAEtE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,YAAY,EAAE,uBAAuB,CACnC,WAAW,EACX,cAAiC,CAClC;IACD,QAAQ,EAAE,SAAS;SAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;SAChD,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;YACzB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SACrB;aAAM;YACL,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAClC;IACH,CAAC,CAAC;CACL,CAAC"}
1
+ {"version":3,"file":"pagarme-v5-events.js","sourceRoot":"","sources":["../src/pagarme-v5-events.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,EACL,uBAAuB,GAExB,MAAM,4CAA4C,CAAC;AACpD,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AAEtE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,YAAY,EAAE,uBAAuB,CACnC,WAAW,EACX,cAAiC,CAClC;IACD,QAAQ,EAAE,SAAS;SAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;SAChD,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC1B,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;CACL,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pagarme-v5",
3
3
  "type": "module",
4
- "version": "2.9.0",
4
+ "version": "2.10.0",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Pagar.me API v5 with recurring payments",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
8
8
  ".": "./lib/index.js",
9
9
  "./events": "./lib/pagarme-v5-events.js"
10
10
  },
11
+ "files": [
12
+ "/lib",
13
+ "/lib-mjs",
14
+ "/types",
15
+ "/*.{js,mjs,ts}"
16
+ ],
11
17
  "repository": {
12
18
  "type": "git",
13
19
  "url": "git+https://github.com/ecomplus/cloud-commerce.git",
@@ -21,15 +27,15 @@
21
27
  "homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/apps/pagarme-v5#readme",
22
28
  "dependencies": {
23
29
  "@ecomplus/utils": "1.5.0-rc.6",
24
- "axios": "^1.6.7",
30
+ "axios": "^1.6.8",
25
31
  "firebase-admin": "^12.0.0",
26
- "firebase-functions": "^4.8.0",
27
- "@cloudcommerce/firebase": "2.9.0",
28
- "@cloudcommerce/api": "2.9.0"
32
+ "firebase-functions": "^4.8.1",
33
+ "@cloudcommerce/api": "2.10.0",
34
+ "@cloudcommerce/firebase": "2.10.0"
29
35
  },
30
36
  "devDependencies": {
31
- "@cloudcommerce/test-base": "2.9.0",
32
- "@cloudcommerce/types": "2.9.0"
37
+ "@cloudcommerce/test-base": "2.10.0",
38
+ "@cloudcommerce/types": "2.10.0"
33
39
  },
34
40
  "scripts": {
35
41
  "build": "bash scripts/build.sh",
@@ -1,5 +0,0 @@
1
-
2
-
3
- > @cloudcommerce/app-pagarme-v5@2.8.8 build /home/leo/code/ecomplus/cloud-commerce/packages/apps/pagarme-v5
4
- > bash scripts/build.sh
5
-
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- Please refer to GitHub [repository releases](https://github.com/ecomplus/cloud-commerce/releases) or monorepo unified [CHANGELOG.md](https://github.com/ecomplus/cloud-commerce/blob/main/CHANGELOG.md).
@@ -1,38 +0,0 @@
1
- (function pagarmeOnload() {
2
- const apiKey = window._pagarmeKey;
3
- window._pagarmeHash = function pagarmeHash(cardClient) {
4
- return new Promise(async (resolve, reject) => {
5
- const card = {
6
- number: cardClient.number,
7
- holder_name: cardClient.name,
8
- exp_month: cardClient.month,
9
- exp_year: cardClient.year,
10
- cvv: cardClient.cvc,
11
- };
12
- const resp = await fetch(
13
- `https://api.pagar.me/core/v5/tokens?appId=${apiKey}`,
14
- {
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- },
18
- method: 'POST',
19
- body: JSON.stringify({
20
- type: 'card',
21
- card,
22
- }),
23
- },
24
- );
25
-
26
- try {
27
- const data = await resp.json();
28
- if (data.id) {
29
- resolve(data.id);
30
- }
31
- throw new Error(`Error Token ${await resp.text()}`);
32
- } catch (err) {
33
- // console.error(err);
34
- reject(err);
35
- }
36
- });
37
- };
38
- }());
@@ -1 +0,0 @@
1
- !function(){const o=window._pagarmeKey;window._pagarmeHash=function(t){return new Promise(async(a,e)=>{var r={number:t.number,holder_name:t.name,exp_month:t.month,exp_year:t.year,cvv:t.cvc},r=await fetch("https://api.pagar.me/core/v5/tokens?appId="+o,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({type:"card",card:r})});try{var n=await r.json();throw n.id&&a(n.id),new Error("Error Token "+await r.text())}catch(a){e(a)}})}}();
package/scripts/build.sh DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
-
3
- node ../../../scripts/assets-minification.mjs
4
- bash ../../../scripts/build-lib.sh
package/scripts/tests.sh DELETED
@@ -1,9 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [ -z "$PAGARMEV5_API_TOKEN" ]; then
4
- echo -e "PAGARMEV5_API_TOKEN not set\n"
5
- elif [ -z "$PAGARMEV5_PUBLIC_KEY" ]; then
6
- echo -e "PAGARMEV5_PUBLIC_KEY not set\n"
7
- else
8
- node --test tests/
9
- fi
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './pagarme-v5';
@@ -1,27 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
-
3
- import '@cloudcommerce/firebase/lib/init';
4
- import * as functions from 'firebase-functions/v1';
5
- import config from '@cloudcommerce/firebase/lib/config';
6
- import {
7
- createAppEventsFunction,
8
- ApiEventHandler,
9
- } from '@cloudcommerce/firebase/lib/helpers/pubsub';
10
- import handleApiEvent from '../lib-mjs/events-to-pagarme5.mjs';
11
- import handlePagarmeV5Webhook from '../lib-mjs/pagarme5-webhooks.mjs';
12
-
13
- export const pagarmev5 = {
14
- onStoreEvent: createAppEventsFunction(
15
- 'pagarMeV5',
16
- handleApiEvent as ApiEventHandler,
17
- ),
18
- webhooks: functions
19
- .region(config.get().httpsFunctionOptions.region)
20
- .https.onRequest((req, res) => {
21
- if (req.method !== 'POST') {
22
- res.sendStatus(405);
23
- } else {
24
- handlePagarmeV5Webhook(req, res);
25
- }
26
- }),
27
- };
package/src/pagarme-v5.ts DELETED
@@ -1,12 +0,0 @@
1
- import '@cloudcommerce/firebase/lib/init';
2
- import type { AppModuleBody } from '@cloudcommerce/types';
3
- import handleListPayments from '../lib-mjs/list-pagarme5-payments.mjs';
4
- import handleCreateTransaction from '../lib-mjs/create-pagarme5-transaction.mjs';
5
-
6
- export const listPayments = async (modBody: AppModuleBody) => {
7
- return handleListPayments(modBody);
8
- };
9
-
10
- export const createTransaction = async (modBody: AppModuleBody) => {
11
- return handleCreateTransaction(modBody);
12
- };
@@ -1,37 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- import assert from 'node:assert';
3
- import test, { before, describe } from 'node:test';
4
- import {
5
- modulesUrl,
6
- bodyListPayments,
7
- } from '@cloudcommerce/test-base';
8
-
9
- describe('Test payment list of Pagar.me V5 App', async () => {
10
- let req;
11
- let data;
12
- const appId = 112381;
13
-
14
- before(async () => {
15
- req = await fetch(`${modulesUrl}/list_payments?app_id=${appId}`, {
16
- method: 'POST',
17
- body: JSON.stringify(bodyListPayments),
18
- headers: {
19
- 'Content-Type': 'application/json',
20
- },
21
- });
22
-
23
- data = (await req.json()).result;
24
- });
25
-
26
- test('Check Status 200', async () => {
27
- assert.strictEqual(req?.status, 200);
28
- });
29
-
30
- test('Check validated is true', async () => {
31
- assert.equal(data[0].validated, true);
32
- });
33
-
34
- test('Have payment gateways', async () => {
35
- assert.equal(data[0].response.payment_gateways.length > 0, true);
36
- });
37
- });
@@ -1,56 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- import assert from 'node:assert';
3
- import test, { before, describe } from 'node:test';
4
- import {
5
- modulesUrl,
6
- bodyCreateTransaction,
7
- } from '@cloudcommerce/test-base';
8
-
9
- describe('Test to create a transaction in the Pagar.me V5 with banking billet', async () => {
10
- let req;
11
- let data;
12
- const appId = 112381;
13
- before(async () => {
14
- const paymentMethod = {
15
- code: 'account_deposit',
16
- name: 'Pix - Pagar.me',
17
- };
18
- const to = {
19
- zip: '35701134',
20
- province_code: 'MG',
21
- name: 'Wisley Alves',
22
- city: 'Sete Lagoas',
23
- borough: 'Progresso',
24
- street: 'Rua Santo André',
25
- number: 81,
26
- };
27
-
28
- Object.assign(bodyCreateTransaction, {
29
- payment_method: paymentMethod,
30
- to,
31
- domain: 'www.lojatest.com.br',
32
- });
33
-
34
- req = await fetch(`${modulesUrl}/create_transaction?app_id=${appId}`, {
35
- method: 'POST',
36
- body: JSON.stringify(bodyCreateTransaction),
37
- headers: {
38
- 'Content-Type': 'application/json',
39
- },
40
- });
41
-
42
- data = (await req.json()).result;
43
- });
44
-
45
- test('Check Status 200', async () => {
46
- assert.strictEqual(req?.status, 200);
47
- });
48
-
49
- test('Check validated is true', async () => {
50
- assert.equal(data[0].validated, true);
51
- });
52
-
53
- test('Have transaction', async () => {
54
- assert.notEqual(data[0].response.transaction, undefined);
55
- });
56
- });
package/tsconfig.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "declaration": true
5
- }
6
- }