-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate project from js to ts (#35)
- Loading branch information
Showing
29 changed files
with
8,734 additions
and
3,505 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2016, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Tests + Coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js v18 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run the tests | ||
run: npm run test -- --coverage | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,18 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
# Coverage directory | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Build files | ||
/dist | ||
|
||
# Others | ||
.idea | ||
.DS_Store | ||
|
||
|
||
package-lock\.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nodejs 18.19.0 | ||
npm 10.2.3 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,152 +1,82 @@ | ||
# moneryze | ||
|
||
**Currently only supports vault transactions, more will be added soon** | ||
|
||
[![NPM version](https://img.shields.io/npm/v/moneryze.svg)](https://www.npmjs.com/package/moneryze) | ||
[![Build Status](https://travis-ci.org/Wuon/moneryze.svg?branch=master)](https://travis-ci.org/Wuon/moneryze) | ||
[![Coverage Status](https://coveralls.io/repos/github/Wuon/moneryze/badge.svg?branch=master)](https://coveralls.io/github/Wuon/moneryze?branch=master) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
> A wrapper to access the Moneris API, forked from AlejandroEsquivel's great work (AlejandroEsquivel/moneris-js), forked from shaynair's great work (shaynair/moneris-js) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
![Codecov](https://img.shields.io/codecov/c/github/wuon/moneryze) | ||
![npm](https://img.shields.io/npm/dy/moneryze) | ||
|
||
> The hope for this module is to create clean, robust, promise wrapped queries that extend just beyond payments. Shaynair's work supported generalized queries to Moneris, Alejandro's work handled the imperfect formatting. My hope is to extend and complete the wrapper, transforming the project into something easy to implement by any developer. | ||
> A wrapper to access the Moneris API, forked from AlejandroEsquivel's great work ([AlejandroEsquivel/moneris-js](https://github.com/AlejandroEsquivel/moneris-js)), which was also based on shaynair's original implementation ([shaynair/moneris-js](https://github.com/shaynair/moneris-js)). The hope for this module is to create clean, robust, promise wrapped queries which modernize the original implementations from predecessors. Shaynair's work supported generalized queries to Moneris, and Alejandro's work handled the imperfect formatting. My hope is to extend and complete the wrapper, transforming the project into something easy to implement by any developer. | ||
[Installation](#installation) | | ||
[Usage](#usage) | | ||
[Example](#example) | | ||
[License](#license) | ||
|
||
## Installation | ||
|
||
With [npm](https://npmjs.org/): | ||
|
||
```bash | ||
npm install moneryze --save | ||
npm install moneryze | ||
``` | ||
|
||
Note: You need **an engine that supports ES6 (e.g. Babel or Node 4.0+)**. | ||
|
||
## General Usage | ||
|
||
**`const moneris = require('moneryze');`** | ||
|
||
Queries the Moneris API with the information provided. | ||
|
||
- `config`: **Required.** An object with the following fields. | ||
- `app_name`: Optional. If given, will add `app_name` as a prefix to receipt names. | ||
- `api_token`: **Required.** Your API token. | ||
- `store_id`: **Required.** Your store ID. | ||
- `crypt_type`: Optional. If given, will set the default crypt_type for all transactions. `7` by default. | ||
- `test`: Optional. If true, uses Moneris Test endpoints. You can get a `api_token` and `store_id` for this endpoint from Moneris's Documentation. `false` by default. | ||
|
||
.init() must be called before any other operation, otherwise an error will be thrown | ||
|
||
## Examples | ||
|
||
### .init() | ||
|
||
```bash | ||
moneris.init({ | ||
app_name: 'Test', | ||
store_id: 'store5', | ||
api_token: 'yesguy', | ||
crypt_type: '7', | ||
test: true, | ||
}); | ||
``` | ||
|
||
### .resAddCC() | ||
|
||
- `pan`: **Required.** Card number. | ||
- `expdate`: **Required.** Expiry date of the card. | ||
|
||
```bash | ||
moneris.resAddCC({ | ||
pan: '4242424242424242', | ||
expdate: '2011', | ||
}); | ||
``` | ||
Note: The minimum node version to utilize this package is v18.x.x | ||
|
||
### .resPurchaseCC() | ||
## Usage | ||
|
||
- `token`: **Required.** Customer's moneris token. | ||
- `amount`: **Required.** Amount to charge. | ||
- `description`: Optional. A short message attached to the purchase. | ||
```typescript | ||
import { Moneryze } from "moneryze"; | ||
|
||
```bash | ||
moneris.resPurchaseCC({ | ||
token: 'D8WyyItuNb6mHn4biiPqAwM42', | ||
amount: 11.98, | ||
description: 'bubble tea', | ||
const moneryze = new Moneryze({ | ||
appName: "Test", | ||
storeId: "store5", | ||
apiToken: "yesguy", | ||
cryptType: "7", | ||
isTest: true, | ||
countryCode: "CA", | ||
}); | ||
``` | ||
|
||
### .purchase() | ||
|
||
- `pan`: **Required.** Card number. | ||
- `expdate`: **Required.** Expiry date of the card. | ||
- `amount`: **Required.** Amount to charge. | ||
- `description`: Optional. A short message attached to the purchase. | ||
|
||
```bash | ||
moneris.resPurchaseCC({ | ||
pan: '4242424242424242', | ||
expdate: '2011', | ||
amount: 11.98, | ||
description: 'bubble tea', | ||
moneryze.send("res_add_cc", { | ||
pan: "4242424242424242", | ||
expdate: "2011", | ||
}); | ||
``` | ||
|
||
### .refund() | ||
To see the full list of what can be interfaced, it is highly recommended you examine the integration guide from Moneris [here](https://github.com/Moneris/eCommerce-Unified-API-PHP/blob/master/Unified-API-IG-PHP-v1.6.3.pdf). | ||
|
||
- `order_id`: **Required.** The ID of the order from the transaction. | ||
- `txn_number`: **Required.**. The number from the transaction. | ||
- `amount`: **Required.** Amount to refund. | ||
To see some integration examples with this library, look [here](https://github.com/Wuon/moneryze/tree/main/examples). | ||
|
||
```bash | ||
moneris.refund({ | ||
order_id: 'mvt2713618548', | ||
txn_number: '911464-0_10', | ||
amount: 11.98, | ||
}); | ||
``` | ||
### Configuration options | ||
|
||
### .preauth() | ||
```typescript | ||
export type MoneryzeConfig = { | ||
appName?: string; | ||
storeId: string; | ||
apiToken: string; | ||
cryptType?: string; | ||
isTest?: boolean; | ||
countryCode: Country; | ||
}; | ||
|
||
- `order_id`: **Required.** The ID of the order for the preauthorization. | ||
- `amount`: **Required.** Amount to preauthorize. | ||
- `pan`: **Required.** Card number. | ||
- `expdate`: **Required.** Expiry date of the card. | ||
const config: MoneryzeConfig = { | ||
// Describe options here! | ||
}; | ||
|
||
```bash | ||
moneris.refund({ | ||
order_id: 'mvt2713618548', | ||
amount: 11.98, | ||
pan: '4242424242424242', | ||
expdate: '2011' | ||
}); | ||
const moneryze = new Moneryze(config); | ||
``` | ||
|
||
### .completion() | ||
|
||
- `order_id`: **Required.** The ID of the order for the preauthorization. | ||
- `amount`: **Required.** Completion amount. | ||
- `txn_number`: **Required.**. The number from the transaction. | ||
|
||
```bash | ||
moneris.completion({ | ||
order_id: 'mvt2713618548', | ||
amount: 11.98, | ||
txn_number: '911464-0_10', | ||
}); | ||
``` | ||
- `appName`: Optional. If given, will add `appName` as a prefix to receipt names (eg: `Test-Purchase-1703974946117-1529`). Will default to `moneryze` if not specified. | ||
- `apiToken`: **Required.** Your API token. | ||
- `storeId`: **Required.** Your store ID. | ||
- `cryptType`: Optional. If given, will set the default crypt_type for all transactions. `7` by default. | ||
- `isTest`: Optional. If true, uses Moneris Test endpoints. You can get a `api_token` and `store_id` for this endpoint from Moneris's Documentation. `false` by default. | ||
- `countryCode`: **Required**. Defines the region in which endpoint to interface with Moneris. Currently only suppports `CA` (Canada) or `US` (United States). | ||
|
||
## License | ||
|
||
[MIT](http://g14n.info/mit-license) | ||
|
||
## Notes | ||
|
||
With love and passion, | ||
Thanks for supporting this package! 🫡 | ||
|
||
wuon |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const PROTOCOL = "https"; | ||
export const PORT = 443; | ||
export const HOST = "www3.moneris.com"; | ||
export const TEST_HOST = "esqa.moneris.com"; | ||
export const US_HOST = "esplusqa.moneris.com"; | ||
export const FILE = "/gateway2/servlet/MpgRequest"; | ||
export const US_FILE = "/gateway_us/servlet/MpgRequest"; | ||
export const MPI_FILE = "/mpi/servlet/MpiServlet"; | ||
export const API_VERSION = '"API_VERSION": "PHP NA - 1.2.3"'; | ||
export const CLIENT_TIMEOUT = 30; |
Oops, something went wrong.