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

## Make a payment {#make-a-payment}

These test cases describe submitting a payment request to a supplier.

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

**Sample request**

`POST /payments`

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

```JSON
{
  "currencyAlphaCode": "USD",
  "payerRef": "bsxsdyyxxsdd",
  "amount": "5.78",
  "_links": {
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  },
  "expiryMonth": 9,
  "clientRef": "12345124dd1",
  "addendum": {
    "ICA": "9999"
  },
  "expiryYear": 2018,
  "supplierTaxId": "ik",
  "taxAmount": "2.19",
  "cardNumber": "5450880581140687"
}
```

**Sample response**

`200`

```JSON
{
  "cardNumber": "***************0687",
  "expiryMonth": 9,
  "expiryYear": 2018,
  "amount": "5.78",
  "currencyAlphaCode": "USD",
  "payerRef": "bsxsdyyxxsdd",
  "taxAmount": "2.19",
  "supplierTaxId": "ik",
  "clientRef": "12345124dd1",
  "addendum": {
    "ICA": "306361"
  },
  "_links": {
    "collection": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
    },
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/440"
    },
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    },
    "status": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928/status"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928"
    }
  }
}
```

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

**Sample request**

`POST /payments`

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

```JSON
{
  "currencyAlphaCode": "USD",
  "payerRef": "bsxsdyyxxfghhh",
  "amount": "1",
  "_links": {
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    }
  },
  "expiryMonth": 9,
  "clientRef": "1234512445w",
  "addendum": {
    "ICA": "306361"
  },
  "expiryYear": 2018,
  "supplierTaxId": "ik",
  "taxAmount": "2"
}
```

**Sample response**

`400`

```JSON
{
  "logref": "0.384e6168.1695201497.d260cae",
  "message": "Invalid request",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
    }
  },
  "_embedded": {
    "errors": [
      {
        "logref": "0.384e6168.1695201497.d260cae",
        "message": "<cardNumber> cannot be null nor empty",
        "_links": {
          "about": {
            "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
          }
        }
      }
    ]
  }
}
```

### Test case -- Fail - Invalid supplier link ID {#test-case--fail---invalid-supplier-link-id}

**Sample request**

`POST /payments`

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

```JSON
{
  "currencyAlphaCode": "USD",
  "payerRef": "bsxsdyyxxfghhh",
  "amount": "1",
  "_links": {
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/ppp"
    }
  },
  "expiryMonth": 9,
  "clientRef": "1234512445w",
  "addendum": {
    "ICA": "306361"
  },
  "expiryYear": 2018,
  "supplierTaxId": "ik",
  "taxAmount": "2",
  "cardNumber": "5450880581140687"
}
```

**Sample response**

`400`

```JSON
{
  "logref": "0.5d277368.1695295212.909f8c4",
  "message": "Invalid request",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
    }
  },
  "_embedded": {
    "errors": [
      {
        "logref": "0.5d277368.1695295212.909f8c4",
        "message": "supplier link invalid ID",
        "_links": {
          "about": {
            "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
          }
        }
      }
    ]
  }
}
```

## Retrieve payment details {#retrieve-payment-details}

These test cases describe retrieving information about a previously submitted payment request.

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

**Sample request**

`GET /payments/{id}`

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

**Sample response**

`200`

```JSON
{
  "cardNumber": "***************0687",
  "expiryMonth": 9,
  "expiryYear": 2018,
  "amount": "5.78",
  "currencyAlphaCode": "USD",
  "payerRef": "bsxsdyyxxsdd",
  "taxAmount": "2.19",
  "supplierTaxId": "ik",
  "clientRef": "12345124dd1",
  "addendum": {
    "ICA": "306361"
  },
  "_links": {
    "collection": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments"
    },
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    },
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    },
    "status": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928/status"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928"
    }
  }
}
```

### Test case -- Fail - Wrong ID {#test-case--fail---wrong-id}

**Sample request**

`GET /payments/{id}`

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

**Sample response**

`404`

```JSON
{
  "logref": "0.5d277368.1695295912.9183a58",
  "message": "No payment was found with ID '2161955'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161955"
    }
  }
}
```

## Retrieve payment status {#retrieve-payment-status}

These test cases describe retrieving the current processing status of a previously submitted payment request.

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

**Sample request**

`GET /payments/{id}/status`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/payments/2161928/status`

**Sample response**

`200`

```JSON
{
  "completed": true,
  "successful": true,
  "paymentDateTime": null,
  "authCode": "AC345",
  "providerResultCode": "SUCCESS",
  "providerResultDetailCode1": "APPROVED",
  "providerResultDetailCode2": null,
  "providerResultText": "Transaction Approved (APPROVED)",
  "_links": {
    "provider": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/providers/7"
    },
    "supplier": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/suppliers/959226"
    },
    "payment": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928"
    },
    "self": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161928/status"
    }
  }
}
```

### Test case -- Fail - Invalid payment ID {#test-case--fail---invalid-payment-id}

**Sample request**

`GET /payments/{id}/status`

Base URL: `https://sandbox.api.mastercard.com/stp-api/v1/payments/2161968/status`

**Sample response**

`404`

```JSON
{
  "logref": "0.b658d617.1695296394.185958d",
  "message": "No payment was found with ID '2161968'",
  "_links": {
    "about": {
      "href": "https://stage.api.mastercard.com/stp-api/v1/payments/2161968/status"
    }
  }
}
```

