# For Suppliers
source: https://developer.mastercard.com/straight-through-processing/documentation/testing/case-3/index.md

## Register a supplier {#register-a-supplier}

These test cases describe registering a new supplier with STP and enabling it as an eligible recipient for payment requests.

### Test case -- Success {#test-case--success}

**Sample request**

`POST /suppliers`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": " mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    }
  }
}
```

**Sample response**

`201`

```JSON
{
  "name": " TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": " M123457450003"
    }
  ],
  "_links": {
    "collection": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
    },
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/960150"
    }
  }
}
```

### Test case -- Fail - No provider with this ID {#test-case--fail---no-provider-with-this-id}

**Sample request**

`POST /suppliers`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "tns.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/10"
    }
  }
}
```

**Sample response**

`404`

```JSON
{
  "logref": "0.b658d617.1695297256.1970dec",
  "message": "No provider was found with ID '10'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
    }
  }
}
```

### Test case -- Fail - Null nor empty name {#test-case--fail---null-nor-empty-name}

**Sample request**

`POST /suppliers`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers`

```JSON
{
  "name": "",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "tns.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    }
  }
}
```

**Sample response**

`400`

```JSON
{
  "logref": "0.b658d617.1695297599.19dc746",
  "message": "Invalid request",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
    }
  },
  "_embedded": {
    "errors": [
      {
        "logref": "0.b658d617.1695297599.19dc746",
        "message": "<name> cannot be null nor empty",
        "_links": {
          "about": {
            "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
          }
        }
      }
    ]
  }
}
```

## Retrieve details of a supplier {#retrieve-details-of-a-supplier}

These test cases describe retrieving information about an existing supplier.

### Test case -- Success {#test-case--success-1}

**Sample request**

`GET /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959226`

**Sample response**

`200`

```JSON
{
  "name": " TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": " M123457450003"
    }
  ],
  "_links": {
    "collection": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
    },
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  }
}
```

### Test case -- Fail - No supplier with this ID {#test-case--fail---no-supplier-with-this-id}

**Sample request**

`GET /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959234`

**Sample response**

`404`

```JSON
{
  "logref": "0.b658d617.1695297811.1a23e64",
  "message": "No supplier was found with ID '959,234'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959234"
    }
  }
}
```

## Update details of a supplier {#update-details-of-a-supplier}

These test cases describe updating details of an existing supplier.

### Test case -- Success {#test-case--success-2}

**Sample request**

`PUT /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959234`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    }
  }
}
```

**Sample response**

`200`

```JSON
{
  "name": "TESTSTPTEST06_NEW",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": " mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "collection": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers"
    },
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  }
}
```

### Test case -- Fail - No supplier with this ID {#test-case--fail---no-supplier-with-this-id-1}

**Sample request**

`PUT /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959246`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    }
  }
}
```

**Sample response**

`404`

```JSON
{
  "logref": "0.b658d617.1695298241.1ab0896",
  "message": "No supplier was found with ID '95,9246'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959246"
    }
  }
}
```

### Test case -- Fail - No provider with this ID {#test-case--fail---no-provider-with-this-id-1}

**Sample request**

`PUT /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959234`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/70"
    }
  }
}
```

**Sample response**

`404`

```JSON
{
  "logref": "0.b658d617.1695298335.1acafab",
  "message": "No provider was found with ID '70'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  }
}
```

### Test case -- Fail - Null or empty template {#test-case--fail---null-or-empty-template}

**Sample request**

`PUT /suppliers/{id}`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/suppliers/959234`

```JSON
{
  "name": "TESTSTPTEST06",
  "clientRef": "166005",
  "active": true,
  "customFields": [
    {
      "key": "mpgs-in.merchant.id",
      "name": "Merchant ID",
      "value": "M123457450003"
    }
  ],
  "_links": {
    "provider": {
      "href": ""
    }
  }
}
```

**Sample response**

`400`

```JSON
{
  "logref": "0.b658d617.1695298429.1ae94b4",
  "message": "Template must not be null or empty!",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  }
}
```

