npm package: @plasma-platform/service-payment-gate
Description: Payment gate service api
Author: Mirza Sergey
Latest version: 3.0.1

![version](https://badgen.net/npm/v/@plasma-platform/service-payment-gate)
![nextVersion](https://badgen.net/npm/v/@plasma-platform/service-payment-gate/next)
![downloads](https://badgen.net/npm/dt/@plasma-platform/service-payment-gate)
![license](https://badgen.net/npm/license/@plasma-platform/service-payment-gate)
![dependency](https://badgen.net/npm/dependents/@plasma-platform/service-payment-gate)  

* * *

[Full documentation](https://templatemonster.gitlab.io/PlasmaPlatform/Frontend/plasma-platform/?path=/story/plasma-platform-sdk--service-payment-gate)  
install:  
`npm i @plasma-platform/service-payment-gate -S`  

# Short documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [PaymentClientService](#paymentclientservice)
    -   [Parameters](#parameters)
    -   [messages](#messages)
    -   [createExtendedPayment](#createextendedpayment)
        -   [Parameters](#parameters-1)
        -   [Examples](#examples)
    -   [createPayment](#createpayment)
        -   [Parameters](#parameters-2)
        -   [Examples](#examples-1)
    -   [retryPayment](#retrypayment)
        -   [Parameters](#parameters-3)
        -   [Examples](#examples-2)
    -   [getSavedPaymentMethodCount](#getsavedpaymentmethodcount)
        -   [Parameters](#parameters-4)
        -   [Examples](#examples-3)
    -   [getCommonPaymentMethodsProjects](#getcommonpaymentmethodsprojects)
        -   [Parameters](#parameters-5)
        -   [Examples](#examples-4)
    -   [getCommonPaymentMethods](#getcommonpaymentmethods)
        -   [Parameters](#parameters-6)
        -   [Examples](#examples-5)
    -   [getUserSavedPaymentMethods](#getusersavedpaymentmethods)
        -   [Parameters](#parameters-7)
        -   [Examples](#examples-6)

## PaymentClientService

Payment client Micro Service API SDK

### Parameters

-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** service url
-   `token` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** user access token if available (optional, default `null`)

### messages

Object with class service messages

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

### createExtendedPayment

Create extended payment

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) arguments for payments
    -   `args.currency` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** currency ISO-3 code (default: USD)
    -   `args.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** locale code, max length 2 (default en)
    -   `args.cartId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) cart id
    -   `args.project` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) project id
    -   `args.paymentMethodIds` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** (required) payment method ids
    -   `args.savedPaymentMethodId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Saved arguments for payments
    -   `args.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required)  user Email
    -   `args.phone` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) user phone number
    -   `args.bonuses` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Amount of bonuses to use for payment.
    -   `args.trackingInfo` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** tracking info for payment
    -   `args.paymentOptions` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** payment options

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.createExtendedPayment({
    cartId: 111,
    project:'monster',
    paymentMethodIds: ['dsfsdhfi9i8304ufds'],
    email: 'user@mail.com',
    phone: '123456789',
  });
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with new cart properties

### createPayment

Create payment

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) arguments for payments
    -   `args.currency` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** currency ISO-3 code (default: USD)
    -   `args.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** locale code, max length 2 (default en)
    -   `args.cartId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) cart id
    -   `args.project` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) project id
    -   `args.paymentMethodIds` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** (required) payment method ids
    -   `args.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required)  user Email
    -   `args.phone` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) user phone number
    -   `args.trackingInfo` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** tracking info for payment
    -   `args.paymentOptions` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** payment options

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.createPayment({
    cartId: 111,
    project:'monster',
    paymentMethodIds: ['dsfsdhfi9i8304ufds'],
    email: 'user@mail.com',
    phone: '123456789',
  });
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with new cart properties

### retryPayment

Retry payment

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) arguments for payments
    -   `args.orderId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) cart id
    -   `args.paymentMethodId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) payment method id
    -   `args.trackingInfo` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** tracking info for payment

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.retryPayment({
    orderId: 111,
    paymentMethodId: 'dsfsdhfi9i8304ufds',
  });
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with new payment url

### getSavedPaymentMethodCount

Get saved payment method count

#### Parameters

-   `email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) client email

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.getSavedPaymentMethodCount('user@mail.com');
})();
```

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** payment method count

### getCommonPaymentMethodsProjects

Get common payment methods

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) list of arguments for payment methods
    -   `args.project` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) project name
    -   `args.countryCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** country code max length 2 (default us)
    -   `args.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locale code, max length 2 (default en)

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.getCommonPaymentMethodsProjects({project: 'monster'});
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** payment method count

### getCommonPaymentMethods

Get common payment methods

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) list of arguments for payment methods
    -   `args.project` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) project name
    -   `args.countryCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** country code max length 2 (default us)
    -   `args.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locale code, max length 2 (default en)

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.getCommonPaymentMethods({project: 'monster'});
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** payment method count

### getUserSavedPaymentMethods

Get user saved payment methods

#### Parameters

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (required) list of arguments for payment methods
    -   `args.project` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (required) project name
    -   `args.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locale code, max length 2 (default en)

#### Examples

```javascript
(async () => {
  const paymentClientService = new PaymentClientService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const data = await paymentClientService.getUserSavedPaymentMethods({project: 'monster', locale: 'en'});
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** payment method count