@mandarvl/vanilla-pay-international 1.0.0 → 1.0.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/README.md CHANGED
@@ -59,7 +59,7 @@ async function main() {
59
59
 
60
60
  console.log(payment);
61
61
 
62
- const paymentDetails = await vanillaPay.payment.get(payment.id);
62
+ const paymentDetails = await vanillaPay.payment.get(payment.id, 'mobile_money');
63
63
  console.log(paymentDetails);
64
64
  } catch (err) {
65
65
  console.error(err);
@@ -100,8 +100,8 @@ if (isValid) {
100
100
 
101
101
  ### 4. Supported Payment Methods
102
102
 
103
- * `mobile_money` (Mvola, Orange Money, Airtel Money, etc.)
104
- * `international` (Visa, Mastercard, PayPal)
103
+ * `mobile_money` (Mvola, Orange Money, Airtel Money)
104
+ * `international` (Bank Cards and Paypal)
105
105
 
106
106
  ---
107
107
 
package/dist/payment.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Service } from "./shared/service";
2
- import { PaymentDetails, PaymentRequest, PaymentResponse } from "./shared/type";
2
+ import { PaymentDetails, PaymentMethod, PaymentRequest, PaymentResponse } from "./shared/type";
3
3
  declare class PaymentService extends Service {
4
4
  init(payData: PaymentRequest): Promise<PaymentResponse>;
5
- get(id: string): Promise<PaymentDetails>;
5
+ get(idOrRef: string, paymentMethod: PaymentMethod): Promise<PaymentDetails>;
6
6
  }
7
7
  export default PaymentService;
package/dist/payment.js CHANGED
@@ -37,11 +37,22 @@ class PaymentService extends service_1.Service {
37
37
  }
38
38
  });
39
39
  }
40
- get(id) {
40
+ get(idOrRef, paymentMethod) {
41
41
  var _a;
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  try {
44
- const { data } = yield this.httpClient.get(`/api/webpayment/${const_1.CURRENT_API_VERSION}/status/${id}`);
44
+ let id = idOrRef;
45
+ const parts = id.split('.');
46
+ if (parts.length === 3) { // this should be encoded
47
+ const [, payloadB64,] = parts;
48
+ id = Buffer.from(util_1.Util.base64UrlToBase64(payloadB64), 'base64').toString();
49
+ }
50
+ const { data } = yield this.httpClient.get(`/api/webpayment/${const_1.CURRENT_API_VERSION}/status/${id}`, {
51
+ params: {
52
+ mode_paiement: paymentMethod
53
+ }
54
+ });
55
+ console.log(data);
45
56
  return Object.assign(Object.assign({}, util_1.Util.formatPaymentData(data.Data)), { id });
46
57
  }
47
58
  catch (error) {
@@ -1,6 +1,7 @@
1
- import { PaymentDetails } from "./type";
1
+ import { PaymentDetails } from './type';
2
2
  export declare class Util {
3
3
  static formatAndValidatePayload(vpiSignature: string, body: any, keySecret: string): PaymentDetails | false;
4
4
  static formatPaymentData(data: any): PaymentDetails;
5
+ static base64UrlToBase64(u: string): string;
5
6
  private static hashData;
6
7
  }
@@ -33,6 +33,12 @@ class Util {
33
33
  mobileMoneyReference: data.referenceMM
34
34
  };
35
35
  }
36
+ static base64UrlToBase64(u) {
37
+ u = u.replace(/-/g, '+').replace(/_/g, '/');
38
+ while (u.length % 4)
39
+ u += '=';
40
+ return u;
41
+ }
36
42
  static hashData(key, payload) {
37
43
  const hashedData = (0, crypto_1.createHmac)('SHA256', key).update(payload).digest('hex');
38
44
  return hashedData;
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@mandarvl/vanilla-pay-international",
3
- "version": "1.0.0",
4
- "description": "A Node.JS package for Vanilla Pay International API",
5
- "private": false,
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "clean": "rm -rf dist",
10
- "build": "npm run clean && tsc",
11
- "prepublishOnly": "npm run build",
12
- "deploy": "npm publish --access public"
13
- },
14
- "author": "Manda Ravalison",
15
- "keywords": [
16
- "vanilla pay",
17
- "vanilla pay international",
18
- "online payment",
19
- "visa",
20
- "mastercard",
21
- "paypal",
22
- "mobile money",
23
- "mvola",
24
- "orange money",
25
- "airtel money"
26
- ],
27
- "files": ["dist"],
28
- "license": "MIT",
29
- "dependencies": {
30
- "axios": "^1.4.0",
31
- "crypto-js": "^4.1.1"
32
- },
33
- "devDependencies": {
34
- "dotenv": "^16.4.5",
35
- "@types/dotenv": "^8.2.0",
36
- "@types/crypto-js": "^4.1.2",
37
- "@types/node": "^20.1.4",
38
- "typescript": "^5.0.4"
39
- },
40
- "exports": {
41
- ".": {
42
- "types": "./dist/index.d.ts",
43
- "require": "./dist/index.js",
44
- "import": "./dist/index.js"
45
- }
46
- }
47
- }
1
+ {
2
+ "name": "@mandarvl/vanilla-pay-international",
3
+ "version": "1.0.1",
4
+ "description": "A Node.JS package for Vanilla Pay International API",
5
+ "private": false,
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "clean": "rm -rf dist",
10
+ "build": "npm run clean && tsc",
11
+ "prepublishOnly": "npm run build",
12
+ "deploy": "npm publish --access public"
13
+ },
14
+ "author": "Manda Ravalison",
15
+ "keywords": [
16
+ "vanilla pay",
17
+ "vanilla pay international",
18
+ "online payment",
19
+ "visa",
20
+ "mastercard",
21
+ "paypal",
22
+ "mobile money",
23
+ "mvola",
24
+ "orange money",
25
+ "airtel money"
26
+ ],
27
+ "files": ["dist"],
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "axios": "^1.4.0",
31
+ "crypto-js": "^4.1.1"
32
+ },
33
+ "devDependencies": {
34
+ "dotenv": "^16.4.5",
35
+ "@types/dotenv": "^8.2.0",
36
+ "@types/crypto-js": "^4.1.2",
37
+ "@types/node": "^20.1.4",
38
+ "typescript": "^5.0.4"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "require": "./dist/index.js",
44
+ "import": "./dist/index.js"
45
+ }
46
+ }
47
+ }