-
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.
Merge pull request #6 from peoray/checkout-methods
Add checkout method
- Loading branch information
Showing
6 changed files
with
67 additions
and
1 deletion.
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,20 @@ | ||
import { Bloc, ICreateCheckout } from '../../dist' | ||
|
||
const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key') | ||
|
||
const createCheckout = async () => { | ||
try { | ||
const data: ICreateCheckout = { | ||
customer_email: 'jerry@orchs.xyz', | ||
customer_name: 'jerry', | ||
country: 'Nigeria', | ||
amount: 100000, | ||
} | ||
const response = await bloc.createCheckout(data) | ||
console.log(response) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
createCheckout() |
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,27 @@ | ||
import { HTTPCore } from '../api' | ||
import { ICheckoutResponse, ICreateCheckout } from '../types' | ||
|
||
/** | ||
* Class representing operations related to Checkouts, extending HTTPCore. | ||
*/ | ||
export class Checkout extends HTTPCore { | ||
/** | ||
* Creates an instance of the Webhook class. | ||
* @param {string} secretKey - The secret key for authentication. | ||
* @param {string} publicKey - The public key for authentication. | ||
*/ | ||
constructor(public secretKey: string, public publicKey: string) { | ||
super(secretKey, publicKey) | ||
} | ||
|
||
/** | ||
* Creates a new checkout using the provided data. | ||
* @param {ICreateCheckout} data - The data to create the checkout. | ||
* @returns {Promise<ICheckoutResponse>} A promise that resolves to the checkout response. | ||
*/ | ||
public async createCheckout( | ||
data: ICreateCheckout | ||
): Promise<ICheckoutResponse> { | ||
return this.post<ICheckoutResponse>(`/checkout/new`, data) | ||
} | ||
} |
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,3 +1,4 @@ | ||
export * from './customer' | ||
export * from './beneficary' | ||
export * from './webhook' | ||
export * from './checkout' |
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,12 @@ | ||
export interface ICreateCheckout { | ||
customer_email: string | ||
customer_name: string | ||
country: string | ||
amount: number | ||
} | ||
|
||
export interface ICheckoutResponse { | ||
success: boolean | ||
data: string | ||
message: 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './customer' | ||
export * from './beneficiary' | ||
export * from './webhook' | ||
export * from './checkout' |