> For the complete documentation index, see [llms.txt](https://wyre-1.gitbook.io/wyre-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wyre-1.gitbook.io/wyre-docs/bank-transfers/api-calls/creating-a-payment-method-ach.md).

# Creating a Payment Method- ACH

When you create a Payment Method using this API it will return with a status of `PENDING`. The Payment Method must be approved before it can be used. Once approved, the Payment Method will transition from `PENDING` to `ACTIVE`

## Using The LOCAL\_TRANSFER Payment Method as a Transfer source

When using the Payment Method as the source of a Transfer you will need to use the SRN with the suffix `:ach`. This will tell our system to route the transaction to the ACH network.

For example, to use the above payment method you would make a request that looks like: POST /v3/transfers

```go
{
  "source": "paymentmethod:PA-W7YN28ABCHT:ach",
  "dest": "account:AC-XX38VYXUA84",
  "sourceCurrency":"USD",
  "destCurrency":"USD",
  "sourceAmount": "100"
}
```

## Create ACH Payment Method

<mark style="color:green;">`POST`</mark> `https://api.sendwyre.com/v2/paymentMethods`&#x20;

#### Request Body

| Name              | Type   | Description                                                    |
| ----------------- | ------ | -------------------------------------------------------------- |
| publicToken       | string | Public token                                                   |
| paymentMethodType | string | `LOCAL_TRANSFER` is the required value for `paymentMethodType` |
| country           | string | `US` is the only supported country for this paymentMethodType  |

{% tabs %}
{% tab title="200 " %}

```
{
    "id": "PA-W7YN28ABCHT",
    "owner": "account:AC-XX38VYXUA84",
    "createdAt": 1542771684392,
    "name": "Plaid Checking 0000",
    "defaultCurrency": "USD",
    "status": "PENDING",
    "statusMessage": null,
    "waitingPrompts": [],
    "linkType": "LOCAL_TRANSFER",
    "beneficiaryType": "UNKNOWN",
    "supportsDeposit": true,
    "nameOnMethod": null,
    "last4Digits": "0000",
    "brand": null,
    "expirationDisplay": null,
    "countryCode": "US",
    "nickname": null,
    "rejectionMessage": null,
    "disabled": false,
    "supportsPayment": true,
    "chargeableCurrencies": [ "USD" ],
    "depositableCurrencies": [ "USD" ],
    "chargeFeeSchedule": null,
    "depositFeeSchedule": null,
    "minCharge": null,
    "maxCharge": null,
    "minDeposit": null,
    "maxDeposit": null,
    "documents": [],
    "srn": "paymentmethod:PA-W7YN28ABCHT"
}
```

{% endtab %}
{% endtabs %}

## Examples

{% tabs %}
{% tab title="JSON" %}

```
{
  "publicToken": "public-sandbox-c78b1564-44c9-426a-9ea3-3fdadcba2e10|AGdQ3KZwl9tdaedkMZAduw8vJD5GvyU1N48Zj",
  "paymentMethodType": "LOCAL_TRANSFER",
  "country": "US"
}
```

{% endtab %}

{% tab title="Python" %}

```
'''
This is a Python 3.7 Module that creates a payment method in
the test env
'''
import requests
import time
import os
import urllib.parse
import hashlib
import hmac
import json


class WyreApi:
    API_KEY = os.getenv("WYRE_APIKEY")
    SEC_KEY = os.getenv("WYRE_TOKEN")
    API_URL = "https://api.testwyre.com"
    API_VER2 = "/v2"
    API_CREATE_PAYMENT = "/paymentMethods"

    def calc_auth_sig_hash(self, url_body):
        '''
          calculates a signature per Wyre API:
          https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth
        '''  
        message, secret = bytes(
            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')
        newhash = hmac.new(secret, message, hashlib.sha256)
        return newhash.hexdigest()

    def calcTimeStamp(self):
        '''
          creates a timestamp to the millisecond
        '''
        return str(round(time.time() * 1000))

      
      
    def createPaymentACH(self, post_data):
        '''
            Create a user payment ACH 
            POST https://api.sendwyre.com/v2/paymentMethods
            params: publicToken, PaymentMethodType, Country=US
        '''
        if not post_data:
            print("Need to send payment object with public Token")
            return

        params = {
            "timestamp": self.calcTimeStamp()
        }
        url = WyreApi.API_URL + WyreApi.API_VER2 + WyreApi.API_CREATE_PAYMENT + "?" + \
            urllib.parse.urlencode(params, encoding="utf-8")

        headers = {
            "X-API-Key": WyreApi.API_KEY,
            "X-API-Signature": self.calc_auth_sig_hash(url + json.dumps(post_data))
        }

        response = requests.post(url, headers=headers, json=post_data)
        if response.status_code == 200:
            return json.loads(response.text)
        else:
            print(response.text)


if __name__ == "__main__":

    # initialize a Wyre Object
    wyre = WyreApi()

    paymentOjb = {
        # SRN https://docs.sendwyre.com/docs/srns
        "account": "account:AC_XXXXXXXXX",
        "publicToken": "ENTER YOUR PUBLIC TOKEN ACQUIRE FROM https://docs.sendwyre.com/docs/create-ach-payment-method",
        "paymentMethodType": "LOCAL_TRANSFER",
        "country": "US"
    }

    payment = wyre.createPaymentACH(paymentOjb)
    if payment:
        print(payment)
```

{% endtab %}
{% endtabs %}

####
