My Products
Help
alexandreveeck
CONTRIBUTOR *

Error when creating a payment for credit note

by alexandreveeck (Updated ‎14-02-2024 17:47 by alexandreveeck )
View more

Hi 

I'm trying to create a payment of type credit memo in Visma using this endpoint in the API:
api/v1/customerPayment/

My body:

{
   "referenceNumber": {"Value":"103446"},
   "type":{"Value":"CreditNote"},
   "applicationDate":{"Value":"2024-02-11T00:00:00"},
   "paymentRef":null,
   "customer":{"Value":"10003"},
   "paymentAmount":{"Value":225.0},
   "paymentLines":[{
          "operation":"Insert",
         "documentType":{ "Value":"Invoice"},
          "refNbr":{"Value":"103445"},
          "amountPaid":{"Value":225.0}
    }]}

But I'm having this error response:
{"message":"VismaId: 35795f9d-7de5-47ec-ac62-c472309c7b32. Error creating payment. Cannot create a Payment of type 'CreditNote' or 'VoidPayment'"}

It's possible to create the same payment in the UI. 

Am I missing something?

6 REPLIES 6
Rozhat
VISMA

by Rozhat

I see, then you need to change the type to Payment and documentType to creditNote. 
Can you try to send it like this: 


{

   "referenceNumber": {"Value":"103446"},
   "type":{"Value":"Payment"},
   "applicationDate":{"Value":"2024-02-11T00:00:00"},
   "paymentRef":null,
   "customer":{"Value":"10003"},
   "paymentAmount":{"Value":225.0},
   "paymentLines":[{
          "operation":"Insert",
         "documentType":{ "Value":"CreditNote"},
          "refNbr":{"Value":"103445"},
          "amountPaid":{"Value":225.0}
    }]}

alexandreveeck
CONTRIBUTOR *

by alexandreveeck

This is the result that I was expecting in Visma:

alexandreveeck_0-1708001011622.png

The reference number is the credit note number. And the invoice is referenced in one line of the payment. 

The type of the payment is CreditMemo. 

 

Not sure why I'm not able to do that using the API. 

 

 

Rozhat
VISMA

by Rozhat

Okey, I think I understand the scenario now. You will need to create it via the customerCreditNote endpoint, and then use that creditNote as a customerPayment against a customerInvoice. 

 

{
    "applicationDate": {
        "value": "2024-01-25"
    },
    "applicationPeriod": {
        "value": "202401"
    },
    "cashAccount": {
        "value": "1930"
    },
    "customer": {
        "value": "10015"
    },
    "currency": {
        "value": "NOK"
    },
    "invoiceText": {
        "value": "GRRRRRR"
    },
    "paymentAmount": {
        "value": 1600
    },
    "paymentLines": [
        {
            "documentType": {
                "value": "CreditNote"
            },
            "operation": "Insert",
            "refNbr": {
                "value": "000147"
            }
        },
        {
            "documentType": {
                "value": "Invoice"
            },
            "operation": "Insert",
            "refNbr": {
                "value": "000148"
            }
        }
    ],
    "paymentMethod": {
        "value": "1"
    },
    "paymentRef": {
        "value": "3416651"
    },
    "referenceNumber": {
        "value": "28220162"
    },
    "type": {
        "value": "payment"
    }
}

 

I have tested this at my test-company and it works! 🙂👍

alexandreveeck
CONTRIBUTOR *

by alexandreveeck (Updated ‎16-02-2024 19:00 by alexandreveeck )

Thank you for taking the time to help me. 

 

But the type of the payment needs to be set as CreditNote (in the UI is CreditMemo). The only row should be the invoice matched against the credit note. This is the way our customer does in Visma but for some reason in the API is not possible.

 

I need to have the same result using the API.  Please don't mind the amounts cause is just an example.

 

alexandreveeck_1-1708106159949.png

 

But when I try to send the type as credit note I got the message: 
"Error creating payment. Cannot create a Payment of type 'CreditNote' or 'VoidPayment'"}"

 

But in the swagger we have that option: 

alexandreveeck_2-1708106315549.png

 

Could it be a bug in the API?

 

Rozhat
VISMA

by Rozhat (Updated ‎15-02-2024 10:03 by Rozhat VISMA )

Hi! 

 

You can't use that endpoint to create a credit note. You should try to use this endpoint instead: 

CustomerCreditNoteV2

 

alexandreveeck
CONTRIBUTOR *

by alexandreveeck (Updated ‎15-02-2024 13:03 by alexandreveeck )

I'm trying to create a payment for the credit note, and not the credit note itself