@cloudcommerce/app-pagarme-v5 2.11.2 → 2.12.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.
@@ -0,0 +1,38 @@
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
+ }());
@@ -0,0 +1 @@
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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pagarme-v5",
3
3
  "type": "module",
4
- "version": "2.11.2",
5
- "description": "E-Com Plus Cloud Commerce app to integrate Pagar.me API v5 with recurring payments",
4
+ "version": "2.12.0",
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",
@@ -11,6 +11,7 @@
11
11
  "files": [
12
12
  "/lib",
13
13
  "/lib-mjs",
14
+ "/assets",
14
15
  "/types",
15
16
  "/*.{js,mjs,ts}"
16
17
  ],
@@ -30,12 +31,12 @@
30
31
  "axios": "^1.6.8",
31
32
  "firebase-admin": "^12.0.0",
32
33
  "firebase-functions": "^4.8.2",
33
- "@cloudcommerce/api": "2.11.2",
34
- "@cloudcommerce/firebase": "2.11.2"
34
+ "@cloudcommerce/api": "2.12.0",
35
+ "@cloudcommerce/firebase": "2.12.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@cloudcommerce/types": "2.11.2",
38
- "@cloudcommerce/test-base": "2.11.2"
38
+ "@cloudcommerce/test-base": "2.12.0",
39
+ "@cloudcommerce/types": "2.12.0"
39
40
  },
40
41
  "scripts": {
41
42
  "build": "bash scripts/build.sh",