> ## Documentation Index
> Fetch the complete documentation index at: https://wpay-feat-edp-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Associate a PayPal account to a buyer

> Associate a PayPal account to a customer record.

There are a few ways to associate a PayPal account with a buyer.

## Associate by `buyer_id`

The easiest way to associate a buyer with a PayPal account is to pass along a
`buyer_id` when creating a PayPal account.

This will find a buyer with that `id` and associate the PayPal account with it. If
a buyer with that `id` could not be found it's ignored.

<CodeGroup>
  ```bash cURL
  curl -i -X POST "https://api.example.gr4vy.app/payment-methods" \
      -H "Authorization: Bearer [JWT_TOKEN]" \
      -H "Content-Type: application/json" \
      -d '{
          "method": "paypal",
          "redirect_url": "https://example.com/callback",
          "buyer_id": "fe26475d-ec3e-4884-9553-f7356683f7f9"
        }'
  ```

  ```js Node
  const fetch = require("node-fetch");

  fetch("https://api.example.gr4vy.app/payment-methods", {
    method: "POST",
    headers: {
      Authorization: "Bearer [JWT_TOKEN]",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      method: "paypal",
      redirect_url: "https://example.com/callback",
      buyer_id: "fe26475d-ec3e-4884-9553-f7356683f7f9",
    }),
  });
  ```
</CodeGroup>

## Associate by `buyer_external_identifier`

Alternatively, a PayPal account can be associated with a buyer by using it's
`external_identifier`. If a buyer with that `external_identifier` could not be
found it's ignored.

<CodeGroup>
  ```bash cURL
  curl -i -X POST "https://api.example.gr4vy.app/payment-methods" \
      -H "Authorization: Bearer [JWT_TOKEN]" \
      -H "Content-Type: application/json" \
      -d '{
          "method": "paypal",
          "redirect_url": "https://example.com/callback",
          "buyer_external_identifier": "412231123"
        }'
  ```

  ```js Node
  const fetch = require("node-fetch");

  fetch("https://api.example.gr4vy.app/payment-methods", {
    method: "POST",
    headers: {
      Authorization: "Bearer [JWT_TOKEN]",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      method: "paypal",
      redirect_url: "https://example.com/callback",
      buyer_external_identifier: "412231123",
    }),
  });
  ```
</CodeGroup>
