> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mercoa.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server.

The Mercoa Wallet is a payment method designed for business-to-business (B2B) payments within the Mercoa platform. It enables seamless payments between payors and recipients, acting as both a funding source and a payment destination. Only one Mercoa Wallet per entity is supported.

## [API Reference](/api-reference/entity/payment-method/wallet/get-wallet-balance)

## Key Features

* **Wallet as a Payment Method:** The Mercoa Wallet is a top-level payment method, available as both a funding source and as a payment destination on invoices and transactions.
* **D+0 Transfer Speed Advantage:** Wallet-to-bank payments are D+0 transfers to the vendor (same-day ACH), which is much faster than D+2 or D+3 for ordinary bank-to-bank transfers.
* **Payment Method Flexibility:** Use as a funding source or payment destination for invoices.

## Allowed and Blocked Payment Flows

Wallets can be used in the following payment flows only:

| Source Payment Method | Destination Payment Method | Allowed? | Notes                                  |
| --------------------- | -------------------------- | -------- | -------------------------------------- |
| Wallet                | Bank Account               | **Yes**  | D+0 transfer (Same-Day ACH settlement) |
| Bank Account          | Wallet                     | **Yes**  | D+2 transfer (ACH)                     |
| Card                  | Wallet                     | **Yes**  | D+1 transfer                           |

> **Note:** Wallet-to-check or wallet-to-card disbursements aren't supported.

#### Example: Creating a Wallet Payment Method

### Request

POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod](https://api.mercoa.com/entity/\{entityId}/paymentMethod)

**`Wallet`**

```curl Wallet
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "type": "wallet"
}'
```

**`Wallet`**

```python Wallet
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod"

payload = { "type": "wallet" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`Wallet`**

```typescript Wallet
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.paymentMethod.create("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", {
    type: "wallet"
});

```

**`Wallet`**

```go Wallet
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod"

	payload := strings.NewReader("{\n  \"type\": \"wallet\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Wallet`**

```ruby Wallet
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": \"wallet\"\n}"

response = http.request(request)
puts response.read_body
```

**`Wallet`**

```java Wallet
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": \"wallet\"\n}")
  .asString();
```

**`Wallet`**

```php Wallet
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod', [
  'body' => '{
  "type": "wallet"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`Wallet`**

```csharp Wallet
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": \"wallet\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Wallet`**

```swift Wallet
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["type": "wallet"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Wallet Balance Management

* **`availableBalance`**: The current wallet balance that is immediately available for use. This is updated when the user's deposited funds settle, when the user withdraws funds, or when a wallet-funded invoice payment is processed.
* **`pendingBalance`**: The current balance of the incoming wallet funds. This is updated when the user initiates a deposit, and is reset to zero once the deposit settles.

## Wallet Onboarding & Usage Guide

The following steps outline how to enable, create, fund, and use a Mercoa Wallet as a payment method.\
You can perform these actions via the Mercoa dashboard or directly using the Mercoa API.

### 1. **Enable Wallet Payment Methods**

In the Mercoa dashboard, enable the "Wallet" option under the [Payment Methods](https://mercoa.com/dashboard/paymentmethods) section and click Save.

### 2. **Create a Wallet Payment Method**

In the Mercoa dashboard, navigate to your entity's admin page and create a new wallet payment method under Payment Methods.

By API, use the [Create Payment Method](/api-reference/entity/payment-method/create) endpoint:

### Request

POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod](https://api.mercoa.com/entity/\{entityId}/paymentMethod)

**`Wallet`**

```curl Wallet
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "type": "wallet"
}'
```

**`Wallet`**

```python Wallet
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod"

payload = { "type": "wallet" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`Wallet`**

```typescript Wallet
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.paymentMethod.create("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", {
    type: "wallet"
});

```

**`Wallet`**

```go Wallet
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod"

	payload := strings.NewReader("{\n  \"type\": \"wallet\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Wallet`**

```ruby Wallet
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": \"wallet\"\n}"

response = http.request(request)
puts response.read_body
```

**`Wallet`**

```java Wallet
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": \"wallet\"\n}")
  .asString();
```

**`Wallet`**

```php Wallet
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod', [
  'body' => '{
  "type": "wallet"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`Wallet`**

```csharp Wallet
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": \"wallet\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Wallet`**

```swift Wallet
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["type": "wallet"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

> **Note:** You may only create one Wallet payment method per entity.

### 3. **Fund the Wallet**

Wallets can be funded from a bank account or card. To add funds from a bank account:

### Request

POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/add-wallet-funds](https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/add-wallet-funds)

**`Default`**

```curl Default
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "amount": 100,
  "sourcePaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
}'
```

**`Default`**

```python Default
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds"

payload = {
    "amount": 100,
    "sourcePaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
    "currency": "USD"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`Default`**

```typescript Default
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.paymentMethod.wallet.addWalletFunds("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "pm_4794d597-70dc-4fec-b6ec-c5988e759769", {
    amount: 100,
    currency: "USD",
    sourcePaymentMethodId: "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a"
});

```

**`Default`**

```go Default
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds"

	payload := strings.NewReader("{\n  \"amount\": 100,\n  \"sourcePaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Default`**

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": 100,\n  \"sourcePaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}"

response = http.request(request)
puts response.read_body
```

**`Default`**

```java Default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": 100,\n  \"sourcePaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}")
  .asString();
```

**`Default`**

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds', [
  'body' => '{
  "amount": 100,
  "sourcePaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`Default`**

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": 100,\n  \"sourcePaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Default`**

```swift Default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "amount": 100,
  "sourcePaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/add-wallet-funds")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 4. **Check Wallet Balance**

You can get your wallet balance using:

### Request

GET [https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/wallet-balance](https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/wallet-balance)

**`Default`**

```curl Default
curl https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance \
     -H "Authorization: Bearer <token>"
```

**`Default`**

```python Default
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`Default`**

```typescript Default
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.paymentMethod.wallet.getWalletBalance("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "pm_4794d597-70dc-4fec-b6ec-c5988e759769");

```

**`Default`**

```go Default
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Default`**

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

**`Default`**

```java Default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance")
  .header("Authorization", "Bearer <token>")
  .asString();
```

**`Default`**

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

**`Default`**

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

**`Default`**

```swift Default
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/wallet-balance")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 5. **Withdraw funds**

To withdraw funds from your Wallet, update the `destinationPaymentMethodId`:

### Request

POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/withdraw-wallet-funds](https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/withdraw-wallet-funds)

**`Default`**

```curl Default
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "amount": 100,
  "destinationPaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
}'
```

**`Default`**

```python Default
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds"

payload = {
    "amount": 100,
    "destinationPaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
    "currency": "USD"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`Default`**

```typescript Default
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.paymentMethod.wallet.withdrawWalletFunds("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "pm_4794d597-70dc-4fec-b6ec-c5988e759769", {
    amount: 100,
    currency: "USD",
    destinationPaymentMethodId: "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a"
});

```

**`Default`**

```go Default
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds"

	payload := strings.NewReader("{\n  \"amount\": 100,\n  \"destinationPaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Default`**

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": 100,\n  \"destinationPaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}"

response = http.request(request)
puts response.read_body
```

**`Default`**

```java Default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": 100,\n  \"destinationPaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}")
  .asString();
```

**`Default`**

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds', [
  'body' => '{
  "amount": 100,
  "destinationPaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`Default`**

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": 100,\n  \"destinationPaymentMethodId\": \"pm_f19d27ad-e493-4bf5-a28b-9cb323de495a\",\n  \"currency\": \"USD\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Default`**

```swift Default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "amount": 100,
  "destinationPaymentMethodId": "pm_f19d27ad-e493-4bf5-a28b-9cb323de495a",
  "currency": "USD"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/withdraw-wallet-funds")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 6. Paying Invoices Using Your Mercoa Wallet

Replacing `paymentSourceId` with the Wallet ID lets you create invoices with Mercoa Wallet.

### Request

POST [https://api.mercoa.com/invoice](https://api.mercoa.com/invoice)

**`CreateInvoice`**

```curl CreateInvoice
curl -X POST https://api.mercoa.com/invoice \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "status": "NEW",
  "amount": 100,
  "currency": "USD",
  "invoiceDate": "2021-01-01T00:00:00Z",
  "dueDate": "2021-01-31T00:00:00Z",
  "invoiceNumber": "INV-123",
  "noteToSelf": "For the month of January",
  "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
  "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18",
  "paymentDestinationOptions": {
    "type": "check",
    "delivery": "MAIL",
    "printDescription": true
  },
  "lineItems": [
    {
      "amount": 100,
      "currency": "USD",
      "description": "Product A",
      "name": "Product A",
      "quantity": 1,
      "unitPrice": 100,
      "category": "EXPENSE",
      "serviceStartDate": "2021-01-01T00:00:00Z",
      "serviceEndDate": "2021-01-31T00:00:00Z",
      "metadata": {
        "key1": "value1",
        "key2": "value2"
      },
      "glAccountId": "600394"
    }
  ],
  "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506"
}'
```

**`CreateInvoice`**

```python CreateInvoice
import requests

url = "https://api.mercoa.com/invoice"

payload = {
    "status": "NEW",
    "amount": 100,
    "currency": "USD",
    "invoiceDate": "2021-01-01T00:00:00Z",
    "dueDate": "2021-01-31T00:00:00Z",
    "invoiceNumber": "INV-123",
    "noteToSelf": "For the month of January",
    "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
    "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
    "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18",
    "paymentDestinationOptions": {
        "type": "check",
        "delivery": "MAIL",
        "printDescription": True
    },
    "lineItems": [
        {
            "amount": 100,
            "currency": "USD",
            "description": "Product A",
            "name": "Product A",
            "quantity": 1,
            "unitPrice": 100,
            "category": "EXPENSE",
            "serviceStartDate": "2021-01-01T00:00:00Z",
            "serviceEndDate": "2021-01-31T00:00:00Z",
            "metadata": {
                "key1": "value1",
                "key2": "value2"
            },
            "glAccountId": "600394"
        }
    ],
    "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`CreateInvoice`**

```typescript CreateInvoice
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.invoice.create({
    status: "NEW",
    amount: 100,
    currency: "USD",
    invoiceDate: new Date("2021-01-01T00:00:00.000Z"),
    dueDate: new Date("2021-01-31T00:00:00.000Z"),
    invoiceNumber: "INV-123",
    noteToSelf: "For the month of January",
    payerId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    paymentSourceId: "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
    vendorId: "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
    paymentDestinationId: "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18",
    paymentDestinationOptions: {
        type: "check",
        delivery: "MAIL",
        printDescription: true
    },
    lineItems: [{
            amount: 100,
            currency: "USD",
            description: "Product A",
            name: "Product A",
            quantity: 1,
            unitPrice: 100,
            category: "EXPENSE",
            serviceStartDate: new Date("2021-01-01T00:00:00.000Z"),
            serviceEndDate: new Date("2021-01-31T00:00:00.000Z"),
            metadata: {
                "key1": "value1",
                "key2": "value2"
            },
            glAccountId: "600394"
        }],
    creatorEntityId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    creatorUserId: "user_e24fc81c-c5ee-47e8-af42-4fe29d895506"
});

```

**`CreateInvoice`**

```go CreateInvoice
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/invoice"

	payload := strings.NewReader("{\n  \"status\": \"NEW\",\n  \"amount\": 100,\n  \"currency\": \"USD\",\n  \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n  \"dueDate\": \"2021-01-31T00:00:00Z\",\n  \"invoiceNumber\": \"INV-123\",\n  \"noteToSelf\": \"For the month of January\",\n  \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n  \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n  \"paymentDestinationOptions\": {\n    \"type\": \"check\",\n    \"delivery\": \"MAIL\",\n    \"printDescription\": true\n  },\n  \"lineItems\": [\n    {\n      \"amount\": 100,\n      \"currency\": \"USD\",\n      \"description\": \"Product A\",\n      \"name\": \"Product A\",\n      \"quantity\": 1,\n      \"unitPrice\": 100,\n      \"category\": \"EXPENSE\",\n      \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n      \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n      \"metadata\": {\n        \"key1\": \"value1\",\n        \"key2\": \"value2\"\n      },\n      \"glAccountId\": \"600394\"\n    }\n  ],\n  \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`CreateInvoice`**

```ruby CreateInvoice
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/invoice")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"status\": \"NEW\",\n  \"amount\": 100,\n  \"currency\": \"USD\",\n  \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n  \"dueDate\": \"2021-01-31T00:00:00Z\",\n  \"invoiceNumber\": \"INV-123\",\n  \"noteToSelf\": \"For the month of January\",\n  \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n  \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n  \"paymentDestinationOptions\": {\n    \"type\": \"check\",\n    \"delivery\": \"MAIL\",\n    \"printDescription\": true\n  },\n  \"lineItems\": [\n    {\n      \"amount\": 100,\n      \"currency\": \"USD\",\n      \"description\": \"Product A\",\n      \"name\": \"Product A\",\n      \"quantity\": 1,\n      \"unitPrice\": 100,\n      \"category\": \"EXPENSE\",\n      \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n      \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n      \"metadata\": {\n        \"key1\": \"value1\",\n        \"key2\": \"value2\"\n      },\n      \"glAccountId\": \"600394\"\n    }\n  ],\n  \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\"\n}"

response = http.request(request)
puts response.read_body
```

**`CreateInvoice`**

```java CreateInvoice
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/invoice")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"status\": \"NEW\",\n  \"amount\": 100,\n  \"currency\": \"USD\",\n  \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n  \"dueDate\": \"2021-01-31T00:00:00Z\",\n  \"invoiceNumber\": \"INV-123\",\n  \"noteToSelf\": \"For the month of January\",\n  \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n  \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n  \"paymentDestinationOptions\": {\n    \"type\": \"check\",\n    \"delivery\": \"MAIL\",\n    \"printDescription\": true\n  },\n  \"lineItems\": [\n    {\n      \"amount\": 100,\n      \"currency\": \"USD\",\n      \"description\": \"Product A\",\n      \"name\": \"Product A\",\n      \"quantity\": 1,\n      \"unitPrice\": 100,\n      \"category\": \"EXPENSE\",\n      \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n      \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n      \"metadata\": {\n        \"key1\": \"value1\",\n        \"key2\": \"value2\"\n      },\n      \"glAccountId\": \"600394\"\n    }\n  ],\n  \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\"\n}")
  .asString();
```

**`CreateInvoice`**

```php CreateInvoice
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/invoice', [
  'body' => '{
  "status": "NEW",
  "amount": 100,
  "currency": "USD",
  "invoiceDate": "2021-01-01T00:00:00Z",
  "dueDate": "2021-01-31T00:00:00Z",
  "invoiceNumber": "INV-123",
  "noteToSelf": "For the month of January",
  "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
  "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18",
  "paymentDestinationOptions": {
    "type": "check",
    "delivery": "MAIL",
    "printDescription": true
  },
  "lineItems": [
    {
      "amount": 100,
      "currency": "USD",
      "description": "Product A",
      "name": "Product A",
      "quantity": 1,
      "unitPrice": 100,
      "category": "EXPENSE",
      "serviceStartDate": "2021-01-01T00:00:00Z",
      "serviceEndDate": "2021-01-31T00:00:00Z",
      "metadata": {
        "key1": "value1",
        "key2": "value2"
      },
      "glAccountId": "600394"
    }
  ],
  "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`CreateInvoice`**

```csharp CreateInvoice
using RestSharp;

var client = new RestClient("https://api.mercoa.com/invoice");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"status\": \"NEW\",\n  \"amount\": 100,\n  \"currency\": \"USD\",\n  \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n  \"dueDate\": \"2021-01-31T00:00:00Z\",\n  \"invoiceNumber\": \"INV-123\",\n  \"noteToSelf\": \"For the month of January\",\n  \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n  \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n  \"paymentDestinationOptions\": {\n    \"type\": \"check\",\n    \"delivery\": \"MAIL\",\n    \"printDescription\": true\n  },\n  \"lineItems\": [\n    {\n      \"amount\": 100,\n      \"currency\": \"USD\",\n      \"description\": \"Product A\",\n      \"name\": \"Product A\",\n      \"quantity\": 1,\n      \"unitPrice\": 100,\n      \"category\": \"EXPENSE\",\n      \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n      \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n      \"metadata\": {\n        \"key1\": \"value1\",\n        \"key2\": \"value2\"\n      },\n      \"glAccountId\": \"600394\"\n    }\n  ],\n  \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n  \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`CreateInvoice`**

```swift CreateInvoice
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "status": "NEW",
  "amount": 100,
  "currency": "USD",
  "invoiceDate": "2021-01-01T00:00:00Z",
  "dueDate": "2021-01-31T00:00:00Z",
  "invoiceNumber": "INV-123",
  "noteToSelf": "For the month of January",
  "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
  "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18",
  "paymentDestinationOptions": [
    "type": "check",
    "delivery": "MAIL",
    "printDescription": true
  ],
  "lineItems": [
    [
      "amount": 100,
      "currency": "USD",
      "description": "Product A",
      "name": "Product A",
      "quantity": 1,
      "unitPrice": 100,
      "category": "EXPENSE",
      "serviceStartDate": "2021-01-01T00:00:00Z",
      "serviceEndDate": "2021-01-31T00:00:00Z",
      "metadata": [
        "key1": "value1",
        "key2": "value2"
      ],
      "glAccountId": "600394"
    ]
  ],
  "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/invoice")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```