Step 2. Invoice Test

In this section, you will find information on testing, as well as test data. All users, items, and payment involved in Sandbox transactions are fictitious. You are able to test all the Invoice features, just as they are in the production environment. However, it is not possible to interact with the MobilePay app, therefor it is not possible to accept or reject invoices from the app. Instead, you have access to a testing API: Invoice User Simulation API , which makes it possible to imitate user actions

Making the first call - Invoice 

Get MerchantId

When you have gone through OpenID Connect, then you can start calling the API. All calls to Invoice endpoints require access tokens, and they are used to make API requests on behalf of a user.  The content of the header should look like the following. We recommend you start with getting the merchantId.   Read more here

Get Invoice Issuer 

Afterwards you should get an invoice issuer. Invoice issuer represents merchant’s company information. Read more about Invoice Issuer on GitHub here 

Test Actions 

InvoiceDirect

1. Create an InvoiceDirect
2. Create multiple InvoiceDirect
3. Cancel an unpaid Invoice

InvoiceLink

5. Create multiple InvoiceLink
6. Create an Invoice Link 

Invoice - Testing 

When calling the testing API, you must always supply an authenticated user id. We supply a testing API, Invoice User Simulation, that simulates user actions in the app. With the API, you can: 

  • Get an Invoice PDF 
  • Accept an Invoice
  • Reject an Invoice 

We expect that you have simulated the 3 features listed above, before you start the verification process. Then it can be completed in a day. You should test both InvoiceDirect and InvoiceLink.

Test users and test data

When testing Invoice, then you'll use the Invoice User Simulation API that you'll find here. To create an Invoice, you must supply

  1. Authenticated user id
  2. ConsumerCard
  3. Phone number 

Below you can find a list of test users for Denmark and Finland. If there is an issue with a test user, please try a different user, or contact us at developer@mobilepay.dk

Note: When testing Invoice payments in Sandbox remember to use the same authenticated user id for both creating and approving the invoice.

 


Authenticated user id ConsumerCard Phone number Consumer name

 f1a75bb4-c8a6-41f8-8603-4cf9278cd5ba

 bfb433c8-da95-41a2-a495-0a386139a7fb +4557373259 Test name

 4f474aa2-6161-4094-97fd-62616ff3d21e

 a6d8044d-176b-4639-a55f-d14d1ae11e28 +4599592431 Test name

 d5e4e229-b482-4304-80f1-237d2a3abc48

 4dacb7cd-3a73-4e4b-9479-62a3c59e37b0 +4522509895 Test name

 40b881f7-ac3d-43bb-81e6-2ac9ef279d89

 6cdf304d-d4c5-4126-9775-a286ce16838b  +4554048573 Test name

 147a8bbd-6a87-40e7-9980-937d1b8d0de4

 0431d325-b174-405b-a502-df9ce0f0a3ee  +4585155935 Test name

Authenticated user id ConsumerCard Phone number Consumer name
404f38dd-25dd-4683-831c-a85f1d25b64d bd0c4cb8-847e-41f0-9dec-914a1e59b829 +358806041406 FI Test name
d5ae8716-4f28-49cc-926b-9667cdeed27a 5efac6d4-1c6b-42e9-a14e-d15f145fe429 +358806041436 FI Test name
6b6c72bc-4a90-4cf7-ada1-c0318cc5404d 3d23e95d-c901-4d23-875d-bcb91239cfaa +358806041507 FI Test name
04e1f1d4-47e1-4db9-8f0e-35b29e380890 d1d0db23-1662-449b-aee8-1668b900b477 +358806041536 FI Test name

To accept an Invoice, you also need to supply a valid ConsumerCard. 
 
Note: You cannot use the MobilePay app installed on your phone when you are testing in sandbox environment. As there is no sandbox MobilePay app, you will instead use the Invoice User Simulation API to simulate customer actions.
Error codes

Generally speaking, it means one of two things - something was wrong in your request or the API could not parse the passed data. The good things about error codes is that they both clarify the situation, and communicate the intended functionality.

You will find Error Codes for Invoice on GitHub here 

If you encounter error 10502, you will not find it on GitHub, because that is an user facing error, an error you might get when using the Invoice User Simulation API to imitate user in Sandbox. 

 Error code

Error Description

Details

10502

Invoice has not been visualized.  Hypothetical error 
Callbacks - MobilePay Invoice 

In order to receive callbacks about status changes for an invoice a callback URL must be specified first. But before setting your callback URL you must choose prefered authentication method which we will use for authenticating our requests when calling your callback URL. Currently we support Basic and ApiKeyauthentication methods:

Basic
PUT /api/v1/merchants/{merchantId}/auth/basic
{
"username":"Username",
"password":"MySecretPswd",
"callback_url":
"https://your.url/callbacks/invoice"
}
ApiKey
PUT /api/v1/merchants/{merchantId}/auth/apikey
{
"api_key":"SomeSecretApiKey123",
"callback_url":"https://your.url/callbacks/invoice"
}

Using ApiKey authentication method your provided API key will be simply added to Authorizationheader.

Example of our callback body:

[
{
"InvoiceId":"3c440dfb-b271-4d21-ad1c-f973f2c4f448",
"Status":"Rejected",
"Date":"2018-04-24T07:29:47.7500268+00:00"
},
{
"InvoiceId":"3c440dfb-b271-4d21-ad1c-f973f2c4f449",
"Status":"Invalid",
"ErrorCode":10106,
"ErrorMessage":"<description of error>",
"Date":"2018-04-24T07:29:47.7500268+00:00"
},
...
]

All possible invoice statuses returned in callback body can be found in Get invoice status section.

Note: When status of an invoice is invalid two additional fields will be added: ErrorCode and ErrorMessage. All possible validation errors can be found in validations section.

Callbacks about created InvoiceLinks which were created asynchronously using batch endpoint will contain additional field Links with Rel="user-redirect" and Href to the page where MobilePay users can accept an invoice, e.g.:

Invoice Link - Parameters 

You can create an invoice and receive a link. That link can be sent to the user by any channel like email, sms, etc. and user can choose to pay with MobilePay. Check InvoiceLink flows and how invoice looks in the app here.

POST api/v1/merchants/{merchantId}/invoices/link
Input
Parameter Sub Parameter Type Description
InvoiceIssuer    guid  Required. The ID of the invoicing department/branch of the merchant.
ConsumerAlias
  object
Mobile alias of the MobilePay user to be invoiced.
  Alias string Mobile phone number of the MobilePay user. Should start with a ‘+’ sign and country phone code. 
E.g. +4512345678 or +35812345678
  AliasType string Alias type of the MobilePay user. This will be autofilled in the landing page if user opens the link not on the phone 
Only value allowed is Phone.
ConsumerName   string Name of the MobilePay user.
TotalAmount   decimal Required. The requested amount to be paid. 
>0.00, decimals separated with a dot.
TotalVatAmount   decimal Required. VAT amount. >0.00, decimals separated with a dot.
CountryCode   string(2) Required. Country code. Either DK or FI is allowed.
CurrencyCode   string(3) Required. Currency code. If you set CountryCode as DK then it should be DKK. If you set CountryCode as FIthen it should be EUR.
ConsumerAddressLines           string[]     At least one is required..Address of consumer receiving the invoice.
DeliveryAddressLines           string[]     Delivery address.
InvoiceNumber                 string     Required. Invoice number.
IssueDate                     date       Required. Issue date of invoice. ISO date format: YYYY-MM-DD
DueDate                       date       Required. Payment due date. Must be between today and 400 days ahead, otherwise the request will be declined. ISO date format: YYYY-MM-DD
OrderDate   date Required. Order date of invoice. ISO date format: YYYY-MM-DD
DeliveryDate   date Required. Delivery date of invoice. ISO date format: YYYY-MM-DD
Comment   string Additional information to the consumer.
MerchantContactName             string     Contact name for the individual who issued the invoice.
MerchantOrderNumber             string     The merchant order number for the invoice used internally by the merchant.
BuyerOrderNumber             string     The buyer order number for the invoice used externally by the merchant.
PaymentReference             string(60) Reference used on the payment to do reconciliation. If not filled, invoice number will be used as reference.
InvoiceUrl             string URL to the Invoice PDF provided by merchant.
InvoiceArticles   array At least one is required.
  ArticleNumber string Required. Article Number, e.g. 123456ABC
  ArticleDescription string Required. Article Description.
  VATRate decimal Required. VAT Rate of article.
  TotalVATAmount decimal Required. Total VAT amount of article.
  TotalPriceIncludingVat decimal Required. Total price of article including VAT.
  Unit string Required. Unit, e.g. Pcs, Coli.
  Quantity decimal Required. Quantity of article.
  PricePerUnit             decimal Required. Price per unit.
  PriceReduction decimal Price reduction.
  PriceDiscount decimal Price discount.
  Bonus decimal Bonus of article.

Read more on GitHub here 

Step 3. Invoice Verification

Once you have finished testing the Invoice API in sandbox, you have to go through a small verification process, to ensure that your system is ready for production.