Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangzhiming committed Dec 19, 2020
1 parent daa3dfd commit 7bcf258
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,40 @@ npm install @toolkitx/paypal
Get instance
```ts
import {Paypal, PaypalPageResponse} from '@toolkitx/paypal';
const fastSprint = new Paypal('YOUR_USER_NAME', 'YOUR_PASSWORD');
const paypal = new Paypal('clientId', 'clientSecret', true);
```
Chain
```ts
fastSprint
paypal
.api('URL')
.head(key, value)
.query({key: 'value'})
.get()
// or .post(payload)
```

* Get accounts
* Get products

```ts
const accounts: PaypalPageResponse = await fastSprint.accounts().get();
const products: PaypalPageResponse = await paypal.products().get();
```

* Get single account
* Get single product

```ts
const account = await fastSprint.accounts('ACCOUNT_ID').get();
const product = await paypal.products('Product id').get();
```


* Query accounts
* Query products

```ts
const accounts = await fastSprint.accounts().query({email: 'EXAMPLE@EMAIL'}).get();
```

* Create Session
```ts
const payload = {
account: 'YOUR_ACCOUNT_ID',
items: [
{
product: 'YOUR_PRODUCT_ID',
quantity: 1,
},
],
};
const session = await fastSprint.sessions().post(payload);
const v = await paypal.products().query({param1: 'EXAMPLE'}).get();
```

## Custom Request
```ts
await fastSprint.api('RELATE_URL').get();
await fastSprint.api('RELATE_URL').post(payload);;
await paypal.api('RELATE_URL').get();
await paypal.api('RELATE_URL').post(payload);;
```

0 comments on commit 7bcf258

Please sign in to comment.