---
id: replaceinvoice
title: Replace Invoice
hide_title: true
description: "Replacing an invoice with new articles"
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Flag from '../../../../src/components/flag/flag';
import Ingress from '../../../../src/components/ingress/ingress.react';

<Ingress title="Replace Invoice">
Change a pending invoice. This API will replace all current articles with the new specified articles.
</Ingress>

## Parameters

| Field                  | min Occurs | nillable | Max | Type                        | Description                                                                               |
| ---------------------- | ---------- | -------- | --- | --------------------------- | ----------------------------------------------------------------------------------------- |
| Username               | 1          | false    | 50  | string                      | The username used to authorize the request.                                               |
| Password               | 1          | false    | 50  | string                      | The password used to authorize the request.                                               |
| ClientIpAddress        | 1          | false    | 50  | string                      | The IP address of the customer performing the purchase at the partner's web shop.         |
| CorrelationId          | 1          | false    | 50  | string                      | CorrelationID is sent back in the response.                                               |
| CountryCode            | 1          | false    | 2   | string                      | The country code (ISO 3166-1 alpha-2) for the country.                                    |
| InvoiceNo              | 1          | false    | 50  | string                      | The invoice number previously returned in AddInvoice.                                     |
| InvoiceRows            | 1          | false    | -   | [InvoiceRow[]](#invoicerow) | The list of articles that shall replace current invoice rows.                             |
| PurchaseClassification | 1          | true     | 50  | string                      | This field is used for an alternative credit evaluation. Contact Walley for more details. |
| StoreId                | 1          | false    | -   | int                         | The StoreId used for identification of store.                                             |

#### InvoiceRow

| Parameter    | Required | Type    | Max | Description                                                        |
| :----------- | :------- | :------ | :-- | :----------------------------------------------------------------- |
| ArticleId    | x        | string  | 50  | The ArticleId of the product.                                      |
| Description  | x        | string  | 50  | The description of the product.                                    |
| Quantity     | x        | int     | 8   | The quantity of the product. 1-99999999 (0 not allowed)            |
| QuantityUnit | -        | string  | 50  | The quantity unit of the product, e.g. pcs, meter, number, kg etc. |
| UnitPrice    | x        | decimal | 6,2 | Price per unit incl. VAT.                                          |
| VAT          | x        | decimal | 6,2 | VAT in per cent                                                    |

## Response

| Field         | min Occurs | nillable | Max | Type    | Description                            |
| ------------- | ---------- | -------- | --- | ------- | -------------------------------------- |
| CorrelationId | 1          | true     | 50  | string  | CorrelationID from the request if any. |
| InvoiceStatus | 1          | false    | -   | integer | Status of the invoice                  |
| TotalAmount   | 1          | false    | -   | decimal | Total amount of the invoice            |

### Example Requests

| &nbsp;       | Value                                                              |
| ------------ | ------------------------------------------------------------------ |
| Environment: | UAT                                                                |
| Service:     | PaymentService                                                     |
| URL:         | https://ecommercetest.collector.se/v3.0/PaymentServiceV10.svc?wsdl |
| Function:    | ReplaceInvoice                                                     |
| Description: | The operation reaplaces all invoice rows an the specified invoice. |
| Notes:       | N/A                                                                |

<Tabs defaultValue="reqB2C" values={[
{ label: 'B2C Request', value: 'reqB2C', },
{ label: 'B2C Response', value: 'resB2C', }]}>
<TabItem value="reqB2C">

```xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://schemas.ecommerce.collector.se/v30/PaymentService">
   <soapenv:Header>
      <pay:Username>USERNAME</pay:Username>
      <pay:Password>PASSWORD</pay:Password>
   </soapenv:Header>
   <soapenv:Body>
      <pay:ReplaceInvoiceRequest>
         <pay:CorrelationId>ReplaceInvoiceV10</pay:CorrelationId>
         <pay:CountryCode>SE</pay:CountryCode>
         <pay:InvoiceNo>62396765</pay:InvoiceNo>
         <pay:InvoiceRows>
            <!--Zero or more repetitions:-->
            <pay:InvoiceRow>
               <pay:ArticleId>Article 11</pay:ArticleId>
               <pay:Description>Description 11</pay:Description>
               <pay:Quantity>11</pay:Quantity>
               <pay:QuantityUnit>pcs</pay:QuantityUnit>
               <pay:UnitPrice>11</pay:UnitPrice>
               <pay:VAT>25</pay:VAT>
            </pay:InvoiceRow>
         </pay:InvoiceRows>
         <pay:PurchaseClassification xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
         <pay:StoreId>1234</pay:StoreId>
      </pay:ReplaceInvoiceRequest>
   </soapenv:Body>
</soapenv:Envelope>
```

</TabItem>
<TabItem value="resB2C">

```xml
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <ReplaceInvoiceResponse xmlns="http://schemas.ecommerce.collector.se/v30/PaymentService">
         <AvailableReservationAmount>5659.00</AvailableReservationAmount>
         <CorrelationId>ReplaceInvoiceV10</CorrelationId>
         <InvoiceStatus>1</InvoiceStatus>
         <TotalAmount>121</TotalAmount>
      </ReplaceInvoiceResponse>
   </s:Body>
</s:Envelope>


```

</TabItem>
</Tabs>

### Error Codes

Please see separate page [Error Codes](/docs/paymentsApi/integration/error-codes)

| Fault Code                         | Description                                             |
| :--------------------------------- | :------------------------------------------------------ |
| VALIDATION_INVOICE_NUMBER_REQUIRED | The InvoiceNumber field was not present in the request. |
