-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added github action flow for release
- Loading branch information
1 parent
4afacbe
commit 6ab6a4f
Showing
3 changed files
with
95 additions
and
56 deletions.
There are no files selected for viewing
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,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 |
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,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}} |
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,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, | ||
}; |