{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/v2/paymentMethods","auth":"required","method":"post","examples":{"codes":[{"code":"{\n\t\"plaidProcessorToken\": \"processor-sandbox-0asd1-a92nc\",\n\t\"paymentMethodType\": \"LOCAL_TRANSFER\",\n\t\"country\": \"US\"\n}","language":"json"},{"code":"'''\nThis is a Python 3.7 Module that creates a payment method in\nthe test env\n'''\nimport requests\nimport time\nimport os\nimport urllib.parse\nimport hashlib\nimport hmac\nimport json\n\n\nclass WyreApi:\n    API_KEY = os.getenv(\"WYRE_APIKEY\")\n    SEC_KEY = os.getenv(\"WYRE_TOKEN\")\n    API_URL = \"https://api.testwyre.com\"\n    API_VER2 = \"/v2\"\n    API_CREATE_PAYMENT = \"/paymentMethods\"\n\n    def calc_auth_sig_hash(self, url_body):\n        '''\n          calculates a signature per Wyre API:\n          https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth\n        '''  \n        message, secret = bytes(\n            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')\n        newhash = hmac.new(secret, message, hashlib.sha256)\n        return newhash.hexdigest()\n\n    def calcTimeStamp(self):\n      \t'''\n        \tcreates a timestamp to the millisecond\n        '''\n        return str(round(time.time() * 1000))\n\n      \n      \n    def createPaymentACH(self, post_data):\n        '''\n            Create a user payment ACH \n            POST https://api.sendwyre.com/v2/paymentMethods\n            params: publicToken, PaymentMethodType, Country=US\n        '''\n        if not post_data:\n            print(\"Need to send payment object with public Token\")\n            return\n\n        params = {\n            \"timestamp\": self.calcTimeStamp()\n        }\n        url = WyreApi.API_URL + WyreApi.API_VER2 + WyreApi.API_CREATE_PAYMENT + \"?\" + \\\n            urllib.parse.urlencode(params, encoding=\"utf-8\")\n\n        headers = {\n            \"X-API-Key\": WyreApi.API_KEY,\n            \"X-API-Signature\": self.calc_auth_sig_hash(url + json.dumps(post_data))\n        }\n\n        response = requests.post(url, headers=headers, json=post_data)\n        if response.status_code == 200:\n            return json.loads(response.text)\n        else:\n            print(response.text)\n\n\nif __name__ == \"__main__\":\n\n    # initialize a Wyre Object\n    wyre = WyreApi()\n\n    paymentOjb = {\n        # SRN https://docs.sendwyre.com/docs/srns\n        \"account\": \"account:AC_XXXXXXXXX\",\n        \"publicToken\": \"ENTER YOUR PUBLIC TOKEN ACQUIRE FROM https://docs.sendwyre.com/docs/create-ach-payment-method\",\n        \"paymentMethodType\": \"LOCAL_TRANSFER\",\n        \"country\": \"US\"\n    }\n\n    payment = wyre.createPaymentACH(paymentOjb)\n    if payment:\n        print(payment)\n","language":"python"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n    \"id\": \"PA-W7YN28ABCHT\",\n    \"owner\": \"account:AC-XX38VYXUA84\",\n    \"createdAt\": 1542771684392,\n    \"name\": \"Plaid Checking 0000\",\n    \"defaultCurrency\": \"USD\",\n    \"status\": \"PENDING\",\n    \"statusMessage\": null,\n    \"waitingPrompts\": [],\n    \"linkType\": \"LOCAL_TRANSFER\",\n    \"beneficiaryType\": \"UNKNOWN\",\n    \"supportsDeposit\": true,\n    \"nameOnMethod\": null,\n    \"last4Digits\": \"0000\",\n    \"brand\": null,\n    \"expirationDisplay\": null,\n    \"countryCode\": \"US\",\n    \"nickname\": null,\n    \"rejectionMessage\": null,\n    \"disabled\": false,\n    \"supportsPayment\": true,\n    \"chargeableCurrencies\": [ \"USD\" ],\n    \"depositableCurrencies\": [ \"USD\" ],\n    \"chargeFeeSchedule\": null,\n    \"depositFeeSchedule\": null,\n    \"minCharge\": null,\n    \"maxCharge\": null,\n    \"minDeposit\": null,\n    \"maxDeposit\": null,\n    \"documents\": [],\n    \"srn\": \"paymentmethod:PA-W7YN28ABCHT\"\n}","name":""}]},"settings":"","params":[{"name":"plaidProcessorToken","type":"string","default":"","desc":"plaidProcessorToken","required":true,"in":"body","ref":"","_id":"5bf5bb0f5d31d801394c453e"},{"name":"paymentMethodType","type":"string","default":"","desc":"`LOCAL_TRANSFER` is the required value for `paymentMethodType`","required":true,"in":"body","ref":"","_id":"5bf5bb0f5d31d801394c453d"},{"name":"country","type":"string","default":"","desc":"`US` is the only supported country for this paymentMethodType","required":true,"in":"body","ref":"","_id":"5bf5bb0f5d31d801394c453c"}]},"next":{"description":"","pages":[]},"title":"ACH - Create Payment Method (Processor Token Model)","type":"endpoint","slug":"ach-create-payment-method-processor-token-model","excerpt":"Create an ACH Payment Method","body":"[block:api-header]\n{\n  \"title\": \"Plaid + Wyre Integration\"\n}\n[/block]\nPartners utilize their own Plaid account and [activate the Wyre integration](https://dashboard.plaid.com/team/integrations) within the Plaid dashboard.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/cd3ce69-PlaidIntegrations.png\",\n        \"PlaidIntegrations.png\",\n        1249,\n        391,\n        \"#333\"\n      ]\n    }\n  ]\n}\n[/block]\nThis integration enables end users on Wyre's platform to verify their account quickly through Plaid’s front-end module. Wyre partners will then generate Plaid Processor Tokens on behalf of their end users. This token will allow Wyre to immediately retrieve a user's bank details in order to deposit or withdraw funds on the Wyre platform.\n\nThis integration requires [Plaid API keys](https://dashboard.plaid.com/signin?redirect=%2Fteam%2Fkeys).\n[block:api-header]\n{\n  \"title\": \"Create a Plaid Processor Token\"\n}\n[/block]\nA Plaid processor token is used to enable Plaid integrations with partners. Please refer to the [Plaid Processor Token using Wyre](https://plaid.com/docs/auth/partnerships/wyre) page for creating a token.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1a7ea3e-Screen_Shot_2021-01-25_at_3.02.38_PM.png\",\n        \"Screen Shot 2021-01-25 at 3.02.38 PM.png\",\n        1030,\n        896,\n        \"#333\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Plaid Link & Processor Token Flow\"\n}\n[/block]\n**Plaid Link Client Example:**\nThe `index.html` and `plaid.js` files live in the same directory. You can run a simple html project locally using something like [http-server](https://www.npmjs.com/package/http-server) for testing. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!doctype html>\\n\\n<html lang=\\\"en\\\">\\n<head>\\n  <meta charset=\\\"utf-8\\\">\\n\\n  <title>Wyre Plaid</title>\\n\\n</head>\\n\\n<body>\\n    <button id=\\\"linkButton\\\">Open Plaid Link</button>\\n    <script src=\\\"https://cdn.plaid.com/link/v2/stable/link-initialize.js\\\"></script>\\n    <script src=\\\"./plaid.js\\\"></script>\\n</body>\\n</html>\",\n      \"language\": \"html\",\n      \"name\": \"Index.html (Plaid Link Initializer)\"\n    },\n    {\n      \"code\": \"const button = document.querySelector('button');\\nlet activatePlaid = async() => {\\n    // Get a new Link token\\n    const fetchLinkToken = async () => {\\n        const response = await fetch('http://localhost:5000/your-api/plaid/create_link_token', { \\n            method: 'POST' \\n        });\\n        const responseJSON = await response.json();\\n        console.log(responseJSON.link_token)\\n        return responseJSON.link_token;\\n    };\\n    const configs = {\\n        // 1. Pass a new link_token to Link.\\n        token: await fetchLinkToken(),\\n        onSuccess: async (public_token, metadata) => {\\n            // 2a. Send the public_token to your app server.\\n            // The onSuccess function is called when the user has successfully\\n            // authenticated and selected an account to use.\\n            fetch('http://localhost:5000/your-api/plaid/exchange_public_token', {\\n                method: 'POST',\\n                headers: {\\n                    'Accept': 'application/json',\\n                    'Content-Type': 'application/json'\\n                },\\n                body: JSON.stringify({\\n                    public_token: public_token,\\n                    account: metadata.accounts[0].id //Account id of checking or savings\\n                })\\n            });\\n        },\\n        onExit: async (err, metadata) => {\\n            // 2b. Gracefully handle the invalid link token error. A link token\\n            // can become invalidated if it expires, has already been used\\n            // for a link session, or is associated with too many invalid logins.\\n            if (err != null && err.error_code === 'INVALID_LINK_TOKEN') {\\n            linkHandler.destroy();\\n            linkHandler = Plaid.create({\\n                ...configs,\\n                token: await fetchLinkToken(),\\n            });\\n            }\\n            if (err != null) {\\n            // Handle any other types of errors.\\n            }\\n            // metadata contains information about the institution that the\\n            // user selected and the most recent API request IDs.\\n            // Storing this information can be helpful for support.\\n        },\\n    };\\n    let linkHandler = Plaid.create(configs);\\n    linkHandler.open(); \\n}   \\n\\ndocument.getElementById('linkButton').onclick = () => {\\n   activatePlaid()\\n};\",\n      \"language\": \"javascript\",\n      \"name\": \"plaid.js (Handler & Server Calls)\"\n    }\n  ]\n}\n[/block]\n**Plaid Processor Token Server-Side Web API Example**\nThis can operate as a simple Express app and be deployed to a serverless provider like Firebase for example. This project uses the [Plaid SDK](https://www.npmjs.com/package/plaid) version `7.0.0`. The variables in the sample below are passed from the \"Plaid Link Client Example\" above.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"//This example is set up as a Firebase Cloud Function, but could also be deployed to Heroku or your preferred provider.\\nconst functions = require('firebase-functions');\\nconst express = require('express');\\nconst cors = require('cors');\\nconst plaid = require('plaid');\\nconst app = express();\\napp.use(cors({ origin: true }));\\napp.use(express.static('public'));\\n\\n// Change sandbox to development to test with live users;\\n// Change to production when you're ready to go live!\\n// Using Express\\napp.use(express.json());\\napp.use(express.urlencoded({\\n    extended: true\\n}));\\n\\nconst plaidClient = new plaid.Client({\\n  clientID: YOUR_PLAID_CLIENT_ID,\\n  secret: YOUR_PLAID_SECRET,\\n  env: plaid.environments.sandbox\\n});\\n\\napp.post('/create_link_token', async (request, response) => {\\n  try {\\n    const tokenResponse = await plaidClient.createLinkToken({\\n      user: {\\n        client_user_id: Date.now().toString(),\\n      },\\n      client_name: 'Plaid Test App',\\n      products: [\\\"auth\\\"],\\n      country_codes: ['US'],\\n      language: 'en',\\n      webhook: 'https://webhook.site/0125021f',\\n    });\\n    console.log(tokenResponse)\\n    response.status(200).send(tokenResponse);\\n  } catch (err) {\\n    // Display error on client\\n    return response.status(400).send({ error: err.message });\\n  }\\n});\\n\\napp.post('/exchange_public_token', async (request, response) => {\\n    try {\\n        const exchangeTokenResponse = await plaidClient.exchangePublicToken(\\n          request.body.public_token\\n        );\\n        console.log(exchangeTokenResponse)\\n        const accessToken = exchangeTokenResponse.access_token;\\n        console.log(accessToken)\\n        // Create a processor token for a specific account id.\\n        let processorTokenResponse = await plaidClient.createProcessorToken(\\n          accessToken,\\n          request.body.account,\\n          'wyre'\\n        );\\n        console.log(processorTokenResponse)\\n        let processorToken = processorTokenResponse.processor_token;\\n        console.log(processorToken)\\n        response.status(200).end();\\n      } catch (err) {\\n        // handle error\\n        console.log(err)\\n        return response.status(400).send({ error: err.message });\\n      }\\n});\\n\\nexports.plaid = functions.https.onRequest(app);\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nPlease refer to the [Payment Method Resources](doc:payment-method-overview) page for more information on payment methods.\n\nWhen 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`\n[block:api-header]\n{\n  \"title\": \"Using The LOCAL_TRANSFER Payment Method as a Transfer source\"\n}\n[/block]\nWhen using the Payment Method as the source of a [Transfer](doc:create-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.\n\nFor example, to use the above payment method you would make a request that looks like:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"source\\\": \\\"paymentmethod:PA-W7YN28ABCHT:ach\\\",\\n  \\\"dest\\\": \\\"account:AC-XX38VYXUA84\\\",\\n  \\\"sourceCurrency\\\":\\\"USD\\\",\\n  \\\"destCurrency\\\":\\\"USD\\\",\\n  \\\"sourceAmount\\\": \\\"100\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"POST /v3/transfers\"\n    }\n  ]\n}\n[/block]","updates":[],"order":4,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"600f12c77dbb3f002b7b48dc","createdAt":"2021-01-25T18:49:43.593Z","user":"5a568b873f58350012e0d314","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Payment Methods","slug":"payment-methods","order":10,"from_sync":false,"reference":true,"_id":"5bc633b08c4b0b000d6a7eaa","project":"550f74bb6fc8130d0038aad3","version":"550f75de61d9d30d00af9e01","createdAt":"2018-10-16T18:53:36.184Z","__v":0},"version":{"version":"3","version_clean":"3.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["550f75de61d9d30d00af9e02","551027e38579861900a86698","551029e08579861900a8669a","551029e7498062190006328a","5bc633a722d682005c9ad9e4","5bc633b08c4b0b000d6a7eaa","5bc633b48f3ff600626e3e18","5bc63538e5a6ba000d22ee6d","5bc63587a18a6b000decd295","5bc635c0937fcb0056223d9c","5bc6360f42f41800319aeaa6","5be5d13ff1d319002baca9ce","5be5d2287cd14d00291fbfdb","5be8b3b09f7cb70023c56a39","5be8b3cbb910100044e20206","5c1d769a4f6aed001fe527f0","5c402942010f0d001496dded","5e8127d61c906800374eeb1c","5f2768c98622b8005106544a","5f2768d05702ca0011f7655e","5f276e5348d2b600321aef9b","5f276fd300e519001139200a","5f9a2cb79dafe500259281a7","5fd92bf362bb7301b00e48ba","60ef489344d5cf002cd7414d"],"_id":"550f75de61d9d30d00af9e01","__v":25,"releaseDate":"2015-03-23T02:09:34.221Z","project":"550f74bb6fc8130d0038aad3","createdAt":"2015-03-23T02:09:34.221Z","forked_from":"550f74bb6fc8130d0038aad6"},"project":"550f74bb6fc8130d0038aad3","__v":25,"parentDoc":null}

postACH - Create Payment Method (Processor Token Model)

Create an ACH Payment Method

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

plaidProcessorToken:
required
string
plaidProcessorToken
paymentMethodType:
required
string
`LOCAL_TRANSFER` is the required value for `paymentMethodType`
country:
required
string
`US` is the only supported country for this paymentMethodType

Examples


Result Format


Documentation

[block:api-header] { "title": "Plaid + Wyre Integration" } [/block] Partners utilize their own Plaid account and [activate the Wyre integration](https://dashboard.plaid.com/team/integrations) within the Plaid dashboard. [block:image] { "images": [ { "image": [ "https://files.readme.io/cd3ce69-PlaidIntegrations.png", "PlaidIntegrations.png", 1249, 391, "#333" ] } ] } [/block] This integration enables end users on Wyre's platform to verify their account quickly through Plaid’s front-end module. Wyre partners will then generate Plaid Processor Tokens on behalf of their end users. This token will allow Wyre to immediately retrieve a user's bank details in order to deposit or withdraw funds on the Wyre platform. This integration requires [Plaid API keys](https://dashboard.plaid.com/signin?redirect=%2Fteam%2Fkeys). [block:api-header] { "title": "Create a Plaid Processor Token" } [/block] A Plaid processor token is used to enable Plaid integrations with partners. Please refer to the [Plaid Processor Token using Wyre](https://plaid.com/docs/auth/partnerships/wyre) page for creating a token. [block:image] { "images": [ { "image": [ "https://files.readme.io/1a7ea3e-Screen_Shot_2021-01-25_at_3.02.38_PM.png", "Screen Shot 2021-01-25 at 3.02.38 PM.png", 1030, 896, "#333" ] } ] } [/block] [block:api-header] { "title": "Plaid Link & Processor Token Flow" } [/block] **Plaid Link Client Example:** The `index.html` and `plaid.js` files live in the same directory. You can run a simple html project locally using something like [http-server](https://www.npmjs.com/package/http-server) for testing. [block:code] { "codes": [ { "code": "<!doctype html>\n\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n\n <title>Wyre Plaid</title>\n\n</head>\n\n<body>\n <button id=\"linkButton\">Open Plaid Link</button>\n <script src=\"https://cdn.plaid.com/link/v2/stable/link-initialize.js\"></script>\n <script src=\"./plaid.js\"></script>\n</body>\n</html>", "language": "html", "name": "Index.html (Plaid Link Initializer)" }, { "code": "const button = document.querySelector('button');\nlet activatePlaid = async() => {\n // Get a new Link token\n const fetchLinkToken = async () => {\n const response = await fetch('http://localhost:5000/your-api/plaid/create_link_token', { \n method: 'POST' \n });\n const responseJSON = await response.json();\n console.log(responseJSON.link_token)\n return responseJSON.link_token;\n };\n const configs = {\n // 1. Pass a new link_token to Link.\n token: await fetchLinkToken(),\n onSuccess: async (public_token, metadata) => {\n // 2a. Send the public_token to your app server.\n // The onSuccess function is called when the user has successfully\n // authenticated and selected an account to use.\n fetch('http://localhost:5000/your-api/plaid/exchange_public_token', {\n method: 'POST',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n public_token: public_token,\n account: metadata.accounts[0].id //Account id of checking or savings\n })\n });\n },\n onExit: async (err, metadata) => {\n // 2b. Gracefully handle the invalid link token error. A link token\n // can become invalidated if it expires, has already been used\n // for a link session, or is associated with too many invalid logins.\n if (err != null && err.error_code === 'INVALID_LINK_TOKEN') {\n linkHandler.destroy();\n linkHandler = Plaid.create({\n ...configs,\n token: await fetchLinkToken(),\n });\n }\n if (err != null) {\n // Handle any other types of errors.\n }\n // metadata contains information about the institution that the\n // user selected and the most recent API request IDs.\n // Storing this information can be helpful for support.\n },\n };\n let linkHandler = Plaid.create(configs);\n linkHandler.open(); \n} \n\ndocument.getElementById('linkButton').onclick = () => {\n activatePlaid()\n};", "language": "javascript", "name": "plaid.js (Handler & Server Calls)" } ] } [/block] **Plaid Processor Token Server-Side Web API Example** This can operate as a simple Express app and be deployed to a serverless provider like Firebase for example. This project uses the [Plaid SDK](https://www.npmjs.com/package/plaid) version `7.0.0`. The variables in the sample below are passed from the "Plaid Link Client Example" above. [block:code] { "codes": [ { "code": "//This example is set up as a Firebase Cloud Function, but could also be deployed to Heroku or your preferred provider.\nconst functions = require('firebase-functions');\nconst express = require('express');\nconst cors = require('cors');\nconst plaid = require('plaid');\nconst app = express();\napp.use(cors({ origin: true }));\napp.use(express.static('public'));\n\n// Change sandbox to development to test with live users;\n// Change to production when you're ready to go live!\n// Using Express\napp.use(express.json());\napp.use(express.urlencoded({\n extended: true\n}));\n\nconst plaidClient = new plaid.Client({\n clientID: YOUR_PLAID_CLIENT_ID,\n secret: YOUR_PLAID_SECRET,\n env: plaid.environments.sandbox\n});\n\napp.post('/create_link_token', async (request, response) => {\n try {\n const tokenResponse = await plaidClient.createLinkToken({\n user: {\n client_user_id: Date.now().toString(),\n },\n client_name: 'Plaid Test App',\n products: [\"auth\"],\n country_codes: ['US'],\n language: 'en',\n webhook: 'https://webhook.site/0125021f',\n });\n console.log(tokenResponse)\n response.status(200).send(tokenResponse);\n } catch (err) {\n // Display error on client\n return response.status(400).send({ error: err.message });\n }\n});\n\napp.post('/exchange_public_token', async (request, response) => {\n try {\n const exchangeTokenResponse = await plaidClient.exchangePublicToken(\n request.body.public_token\n );\n console.log(exchangeTokenResponse)\n const accessToken = exchangeTokenResponse.access_token;\n console.log(accessToken)\n // Create a processor token for a specific account id.\n let processorTokenResponse = await plaidClient.createProcessorToken(\n accessToken,\n request.body.account,\n 'wyre'\n );\n console.log(processorTokenResponse)\n let processorToken = processorTokenResponse.processor_token;\n console.log(processorToken)\n response.status(200).end();\n } catch (err) {\n // handle error\n console.log(err)\n return response.status(400).send({ error: err.message });\n }\n});\n\nexports.plaid = functions.https.onRequest(app);", "language": "javascript", "name": null } ] } [/block] Please refer to the [Payment Method Resources](doc:payment-method-overview) page for more information on payment methods. 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` [block:api-header] { "title": "Using The LOCAL_TRANSFER Payment Method as a Transfer source" } [/block] When using the Payment Method as the source of a [Transfer](doc:create-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: [block:code] { "codes": [ { "code": "{\n \"source\": \"paymentmethod:PA-W7YN28ABCHT:ach\",\n \"dest\": \"account:AC-XX38VYXUA84\",\n \"sourceCurrency\":\"USD\",\n \"destCurrency\":\"USD\",\n \"sourceAmount\": \"100\"\n}", "language": "json", "name": "POST /v3/transfers" } ] } [/block]