Skip to content

Commit

Permalink
Added github action flow for release
Browse files Browse the repository at this point in the history
  • Loading branch information
tejas-hosamani committed Aug 15, 2020
1 parent 4afacbe commit 6ab6a4f
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 56 deletions.
16 changes: 16 additions & 0 deletions .editorConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 4
singleQuote = false
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: '🚀 release'

on:
release:
types: [published]

jobs:
release:
name: 🚀 release
runs-on: ubuntu-latest
steps:
- name: 📚 checkout
uses: actions/[email protected]
- name: 🟢 node
uses: actions/[email protected]
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: 🚀 publish
run: npm publish --access public
working-directory: .
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
112 changes: 56 additions & 56 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
const axios = require("axios").default;

const ENVIRENMENT = {
production: "https://www.instamojo.com/api/1.1/",
sandbox: "https://test.instamojo.com/api/1.1/",
production: "https://www.instamojo.com/api/1.1/",
sandbox: "https://test.instamojo.com/api/1.1/",
};

axios.defaults.baseURL = ENVIRENMENT["production"];

const ENDPOINT = {
createPayment: "payment-requests/",
requestLinks: "links/",
paymentStatus: "payment-requests/",
refunds: "refunds/",
createPayment: "payment-requests/",
requestLinks: "links/",
paymentStatus: "payment-requests/",
refunds: "refunds/",
};

const isSandboxMode = isSandbox => {
if (isSandbox) {
axios.defaults.baseURL = ENVIRENMENT["sandbox"];
} else {
axios.defaults.baseURL = ENVIRENMENT["production"];
}
const isSandboxMode = (isSandbox) => {
if (isSandbox) {
axios.defaults.baseURL = ENVIRENMENT["sandbox"];
} else {
axios.defaults.baseURL = ENVIRENMENT["production"];
}
};

const setKeys = (apiKey, authKey) => {
axios.defaults.headers.common["X-Api-Key"] = apiKey;
axios.defaults.headers.common["X-Auth-Token"] = authKey;
axios.defaults.headers.common["X-Api-Key"] = apiKey;
axios.defaults.headers.common["X-Auth-Token"] = authKey;
};

const PaymentData = options => {
const { purpose, amount } = options;
if (!purpose || !amount) {
console.error(
new Error(
`Purpose and Amount are mandatory fields. And Amount can't be 0.
const PaymentData = (options) => {
const { purpose, amount } = options;
if (!purpose || !amount) {
console.error(
new Error(
`Purpose and Amount are mandatory fields. And Amount can't be 0.
Try something like:
Instamojo.PaymentData({
purpose: 'Product name',
amount: 20
});`
)
);
process.exit(1);
}
return {
purpose: "", // REQUIRED
amount: 0, // REQUIRED
currency: "INR",
buyer_name: "",
email: "",
phone: null,
send_email: false,
send_sms: false,
allow_repeated_payments: false,
webhook: "",
redirect_url: "",
...options,
};
)
);
process.exit(1);
}
return {
purpose: "", // REQUIRED
amount: 0, // REQUIRED
currency: "INR",
buyer_name: "",
email: "",
phone: null,
send_email: false,
send_sms: false,
allow_repeated_payments: false,
webhook: "",
redirect_url: "",
...options,
};
};

const createNewPaymentRequest = async data => {
const createPaymentRequest = axios.create();
try {
const response = await createPaymentRequest.post(
ENDPOINT.createPayment,
data
);
return response.data;
} catch (error) {
if (error.response && error.response.data) {
return error.response.data;
}
const createNewPaymentRequest = async (data) => {
const createPaymentRequest = axios.create();
try {
const response = await createPaymentRequest.post(
ENDPOINT.createPayment,
data
);
return response.data;
} catch (error) {
if (error.response && error.response.data) {
return error.response.data;
}

return error.response;
}
return error.response;
}
};

module.exports = {
isSandboxMode,
setKeys,
PaymentData,
createNewPaymentRequest,
isSandboxMode,
setKeys,
PaymentData,
createNewPaymentRequest,
};

0 comments on commit 6ab6a4f

Please sign in to comment.