Skip to content

Commit

Permalink
Merge pull request #26 from princejoogie/dev
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
princejoogie authored Jan 10, 2022
2 parents 02ddf65 + e3383fe commit c2a9fe1
Show file tree
Hide file tree
Showing 33 changed files with 992 additions and 391 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"cSpell.words": ["livemode", "paymaya", "paymongo", "zustand"]
"cSpell.words": ["gcash", "livemode", "paymaya", "paymongo", "zustand"]
}
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
86 changes: 69 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import PaymongoClient from "paymongo.js";
export const client = PaymongoClient("sk_key");
```

### Payment Methods
### Payment Method

See [PaymentMethod Resource](https://developers.paymongo.com/reference/the-payment-method-object) reference.

- [**Create a Method**](https://developers.paymongo.com/reference/create-a-paymentmethod)

```js
const createResponse = await client.createPaymentMethod({
const createResponse = await client.method.create({
details: {
card_number: "4343434343434345",
exp_month: 3,
Expand All @@ -43,19 +43,19 @@ See [PaymentMethod Resource](https://developers.paymongo.com/reference/the-payme
- [**Retrieve a Method**](https://developers.paymongo.com/reference/create-a-paymentmethod)

```js
const retrieveResponse = await client.retrievePaymentMethod({
const retrieveResponse = await client.method.retrieve({
methodId: "some_method_id",
});
```

### Payment Intents
### Payment Intent

See [PaymentIntent Resource](https://developers.paymongo.com/reference/the-payment-intent-object) reference.

- [**Create a Intent**](https://developers.paymongo.com/reference/create-a-paymentintent)

```js
const createResponse = await client.createPaymentIntent({
const createResponse = await client.intent.create({
amount: 10000,
metadata: {
order_id: "some_order_id",
Expand All @@ -66,28 +66,80 @@ See [PaymentIntent Resource](https://developers.paymongo.com/reference/the-payme
- [**Retrieve a PaymentIntent**](https://developers.paymongo.com/reference/retrieve-a-paymentintent)

```js
const retrieveResponse = await client.retrievePaymentIntent({
const retrieveResponse = await client.intent.retrieve({
intentId: "some_intent_id",
});
```

- [**Attach to PaymentIntent**](https://developers.paymongo.com/reference/attach-to-paymentintent)

```js
const attachResponse = await client.attachPaymentIntent({
const attachResponse = await client.intent.attach({
intentId: "some_intent_id",
methodId: "some_method_id",
});
```

### Payment Webhooks
### Sources

See [Webhook Resource](https://developers.paymongo.com/reference/webhook-resource)
See [Source Resource](https://developers.paymongo.com/reference/the-sources-object) reference.

- [**Create a Source**](https://developers.paymongo.com/reference/create-a-source)

```js
const createResponse = await client.source.create({
type: "gcash", // gcash | grab_pay
currency: "PHP",
amount: 10000,
redirect: {
success: "https://example.com/payments/success",
failed: "https://example.com/payments/error",
},
});
```

- [**Retrieve a Source**](https://developers.paymongo.com/reference/retrieve-a-source)

```js
const retrieveResponse = await client.source.retrieve("some_source_id");
```

### Payments

See [Payment Resource](https://developers.paymongo.com/reference/payment-source) reference.

- [**Create a Payment**](https://developers.paymongo.com/reference/create-a-payment)

```js
const p = await client.payment.create({
amount: 10000,
source: {
id: "some_source_id"
type: "source",
},
});
```

- [**List all Payments**](https://developers.paymongo.com/reference/list-all-payments)

```js
const p = await client.payment.list();
```

- [**Retrieve a Payment**](https://developers.paymongo.com/reference/retrieve-a-payment)

```js
const p = await client.payment.retrieve("some_payment_id");
```

### Webhooks

See [Webhook Resource](https://developers.paymongo.com/reference/webhook-resource) reference.

- [**Create a Webhook**](https://developers.paymongo.com/reference/create-a-webhook)

```js
const webhook = await client.createWebhook({
const webhook = await client.webhook.create({
events: ["payment.failed", "payment.paid", "source.chargeable"],
url: "https://example.com/webhook",
});
Expand All @@ -96,7 +148,7 @@ See [Webhook Resource](https://developers.paymongo.com/reference/webhook-resourc
- [**Update a Webhook**](https://developers.paymongo.com/reference/update-a-webhook)

```js
const webhook = await client.updateWebhook({
const webhook = await client.webhook.update({
webhookId: "some_webhook_id",
events: ["payment.failed"],
});
Expand All @@ -105,32 +157,32 @@ See [Webhook Resource](https://developers.paymongo.com/reference/webhook-resourc
- [**List all Webhooks**](https://developers.paymongo.com/reference/list-all-webhooks)

```js
const webhooks = await client.listWebhooks();
const webhooks = await client.webhook.list();
```

- [**Retrieve a Webhook**](https://developers.paymongo.com/reference/retrieve-a-webhook)

```js
const webhook = await client.retrieveWebhook("some_webhook_id");
const webhook = await client.webhook.retrieve("some_webhook_id");
```

- [**Enable a Webhook**](https://developers.paymongo.com/reference/enable-a-webhook)

```js
const webhook = await client.enableWebhook("some_webhook_id");
const webhook = await client.webhook.enable("some_webhook_id");
```

- [**Disable a Webhook**](https://developers.paymongo.com/reference/disable-a-webhook)

```js
const webhook = await client.disableWebhook("some_webhook_id");
const webhook = await client.webhook.disable("some_webhook_id");
```

---

## Contributing

todo
See [CONTRIBUTING.md](./CONTRIBUTING.md)

---

Expand Down Expand Up @@ -210,4 +262,4 @@ We recommend using [np](https://github.com/sindresorhus/np).

---

Prince Carlo Juguilon
Made by [**Prince Carlo Juguilon**](https://princecaarlo.tech/) together with these awesome [**Contributors**](https://github.com/princejoogie/paymongo.js/graphs/contributors).
40 changes: 27 additions & 13 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@ import { attachPaymentIntent, createPaymentIntent, retrievePaymentIntent } from
import { createPaymentMethod, retrievePaymentMethod } from "./payment/method";
import { createWebhook, disableWebhook, enableWebhook, listWebhooks, retrieveWebhook, updateWebhook } from "./payment/webhook";
import { createSource, retrieveSource } from "./payment/source";
import { createPayment, retrievePayment, listPayments } from "./payment";
export * from "./payment/types";
export interface PaymongoClient {
attachPaymentIntent: typeof attachPaymentIntent;
createPaymentIntent: typeof createPaymentIntent;
retrievePaymentIntent: typeof retrievePaymentIntent;
createPaymentMethod: typeof createPaymentMethod;
retrievePaymentMethod: typeof retrievePaymentMethod;
createWebhook: typeof createWebhook;
disableWebhook: typeof disableWebhook;
enableWebhook: typeof enableWebhook;
listWebhooks: typeof listWebhooks;
retrieveWebhook: typeof retrieveWebhook;
updateWebhook: typeof updateWebhook;
createSource: typeof createSource;
retrieveSource: typeof retrieveSource;
intent: {
attach: typeof attachPaymentIntent;
create: typeof createPaymentIntent;
retrieve: typeof retrievePaymentIntent;
};
method: {
create: typeof createPaymentMethod;
retrieve: typeof retrievePaymentMethod;
};
webhook: {
create: typeof createWebhook;
disable: typeof disableWebhook;
enable: typeof enableWebhook;
list: typeof listWebhooks;
retrieve: typeof retrieveWebhook;
update: typeof updateWebhook;
};
source: {
create: typeof createSource;
retrieve: typeof retrieveSource;
};
payment: {
create: typeof createPayment;
retrieve: typeof retrievePayment;
list: typeof listPayments;
};
}
export declare type ClientFunction = (secretKey: string) => PaymongoClient;
declare const PaymongoClient: ClientFunction;
Expand Down
32 changes: 31 additions & 1 deletion dist/payment/create-payment.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
export declare const createPayment: () => string;
import { PaymentProps, PaymentResponse } from "./types";
/**
* @module createPayment
* @property {number} amount - amount of the payment intent in cents (PHP100 = 100000).
* @property {string} currency - currency of the payment source, defaults to PHP.
* @property {string} description - The description of the payment.
* @property {string} statement_descriptor - The statement descriptor of the payment.
* @property {object} source - The source of the payment.
* @returns {CreatePaymentResponse} - The payment data.
*
* @example
* ```js
* import PaymongoClient from "paymongo.js";
*
* const main = async () => {
* const client = PaymongoClient("pk_test_key");
* const data = await client.createPayment({
* amount: 10000,
* currency: "PHP",
* source: {
* id: "src_utfBfBav5fzXuJiJMDs7J6ye",
* type: "source",
* },
* statement_descriptor: "Test Payment",
description: "Test Payment"
* });
* return data
* }
* ```
*/
export declare const createPayment: ({ amount, currency, source, description, statement_descriptor, }: PaymentProps) => Promise<PaymentResponse>;
4 changes: 3 additions & 1 deletion dist/payment/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from "./create-payment";
export * from "./types";
export * from "./intent";
export * from "./create-payment";
export * from "./retrieve-payment";
export * from "./list-payments";
2 changes: 2 additions & 0 deletions dist/payment/list-payments.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { ListPaymentResponse } from "./types";
export declare const listPayments: () => Promise<ListPaymentResponse>;
18 changes: 18 additions & 0 deletions dist/payment/retrieve-payment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { PaymentResponse } from "./types";
/**
* @module retrievePayment
* @property {string} paymentId - The id of the payment.
* @returns {PaymentResponse} - The payment data.
*
* @example
* ```js
* import PaymongoClient from "paymongo.js";
*
* const main = async () => {
* const client = PaymongoClient("pk_test_key");
* data = await client.retrievePayment("payment_id");
* return data
* }
* ```
*/
export declare const retrievePayment: (paymentId: string) => Promise<PaymentResponse>;
Loading

0 comments on commit c2a9fe1

Please sign in to comment.