-
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.
feature:(payment):check payment status
- start the implementation of a `checkPaymentStatus` method that allows the user to send a request the gourl api to check the status of a payment. The method takes an `options` parameter that include a set of data associated with the payment whose status is to be confirmed. [Starts #26]
- Loading branch information
Showing
10 changed files
with
213 additions
and
82 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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Cryptobox_1 = __importDefault(require("./lib/Cryptobox")); | ||
exports.default = Cryptobox_1.default; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
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,21 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Converts an object into a valid URI query string | ||
* @param { object } data - An object whose key-value pairs | ||
* will be converted into a URI string | ||
* | ||
* @return { string } A HTTP query string starting with the | ||
* question mark (?). | ||
*/ | ||
exports.default = (data = {}) => { | ||
let result = '?'; | ||
for (let key in data) { | ||
let { value } = Object.getOwnPropertyDescriptor(data, key); | ||
value = `${value}`.split(' ').join('+'); | ||
result += `${key}=${encodeURIComponent(value)}&`; | ||
} | ||
// remove trailing `&` | ||
result = result.slice(0, result.length - 1); | ||
return result; | ||
}; |
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,20 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = (period) => { | ||
period = period.replace(' ', '').toUpperCase().trim(); | ||
if (period.substring(-1) === 'S') { | ||
period = period.substring(0, -1); | ||
} | ||
const arr = []; | ||
for (let i = 1; i <= 90; i++) { | ||
arr.push(`${i}MINUTE`); | ||
arr.push(`${i}HOUR`); | ||
arr.push(`${i}DAY`); | ||
arr.push(`${i}WEEK`); | ||
arr.push(`${i}MONTH`); | ||
} | ||
if (period !== 'NOEXPIRY' && !arr.includes(period)) { | ||
throw new Error(`Invalid Cryptobox Period - ${period}`); | ||
} | ||
return period.replace(/(minute|hour|day|week|month)/i, (match) => ` ${match}`); | ||
}; |
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 +1,3 @@ | ||
import Cryptobox from './lib/Cryptobox'; | ||
|
||
export default Cryptobox; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default interface PaymentStatusOption { | ||
privateKey?: string; | ||
boxID: string; | ||
orderID: string; | ||
userID: string; | ||
language?: string; | ||
period: string; | ||
ipAddress: string; | ||
userAgent: string; | ||
} |
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,22 @@ | ||
/** | ||
* Converts an object into a valid URI query string | ||
* @param { object } data - An object whose key-value pairs | ||
* will be converted into a URI string | ||
* | ||
* @return { string } A HTTP query string starting with the | ||
* question mark (?). | ||
*/ | ||
export default (data: object = {}): string => { | ||
let result = '?'; | ||
|
||
for (let key in data) { | ||
let { value } = Object.getOwnPropertyDescriptor(data, key)!; | ||
value = `${value}`.split(' ').join('+'); | ||
result += `${key}=${encodeURIComponent(value)}&`; | ||
} | ||
|
||
// remove trailing `&` | ||
result = result.slice(0, result.length - 1); | ||
|
||
return result; | ||
}; |
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,24 @@ | ||
export default (period: string): string => { | ||
period = period.replace(' ', '').toUpperCase().trim(); | ||
if (period.substring(-1) === 'S') { | ||
period = period.substring(0, -1); | ||
} | ||
|
||
const arr: string[] = []; | ||
for (let i = 1; i <= 90; i++) { | ||
arr.push(`${i}MINUTE`); | ||
arr.push(`${i}HOUR`); | ||
arr.push(`${i}DAY`); | ||
arr.push(`${i}WEEK`); | ||
arr.push(`${i}MONTH`); | ||
} | ||
|
||
if (period !== 'NOEXPIRY' && !arr.includes(period)) { | ||
throw new Error(`Invalid Cryptobox Period - ${period}`); | ||
} | ||
|
||
return period.replace( | ||
/(minute|hour|day|week|month)/i, | ||
(match) => ` ${match}` | ||
); | ||
}; |