# Payment Method Service

The following service can be used to make test payment methods. This is required when making test users in the test environment. If you only require Payment Method API functionality, you can import the module separately to the main SDK.

For example:

```javascript
const { PaymentMethod } = require('n-membership-sdk');
const paymentMethodSdk = new PaymentMethod(config);
```

## Table of Contents

* [Config](#config)
	* [createTestPaymentMethodKey](#createTestPaymentMethodKey)
	* [How to obtain a key](#how-to-obtain-a-key)
* [Methods](#methods)
	* [createTestPaymentMethod](#createTestPaymentMethod)


## Config

* See common configuration options in the [README file](./README.doc)
* `createTestPaymentMethodKey`

```javascript
const config = new TestConfiguration({
	createTestPaymentMethodKey: 'secret',
});
```

### createTestPaymentMethodKey

This is required to use the [createTestPaymentMethod](#createTestPaymentMethod) method.

### How to obtain a key

Do one of the following:

1. Check in Doppler for your app to see if a createTestPaymentMethodKey already exists.
2. Request a new key via the gateway portal with the policy **Create Payment Method TEST**. This policy only exists in the test environment, and is not attainable for the production environment.

## Methods

### createTestPaymentMethod

```javascript
paymentMethodSdk.createTestPaymentMethod();
```

| Parameters           | Required | Type   | Example     | Description                            |
| -------------------- | -------- | -------| ----------- | -------------------------------------- |
|                      |          |        |             |                                        |

**Response**:
```javascript
{
	id: '1234-1234-1234',
	success: true,
}
```

* **id**: This is the id of the payment method, which will need to be passed to the paymentOptions of the `subscriptionSDK.createSubscription()` when making a test user.