Invoice Management ================== Index ------------ Invoice management resources: - [List of all invoices](#invoices) - [Get an invoice detail](#invoice) - [Get an invoice PDF](#invoice-pdf) - [Get an invoice PDF as RAW data](#invoice-raw-pdf) Credit card, internet banking and credit payments: - [Pay it](#get-inv-pay) - [Pay with a stored card](#put-pay) - [Pay with credit](#put-credit-pay) - [List of all payment cards, detail, add new card](#paymentcards) List of all invoices {#invoices} -------------------------- There are 3 types invoices: `invoice`, `proforma` and `payed-by-credit`. Only the type `invoice` is a real commercial invoice (in terms of taxation and accounting), the other types are only informative. Some services (i.e.: Setup fee) don't have `startTime` and `endTime`, so you can see `null` in these fields. Available parameters: - `page` (int, not required) - `pagesize` (int, not required) Example of usage: add `?page=1&pagesize=20` to the end of the address. Default page size is unlimited. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:userId/invoice HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "items": [ { "id": 20000, "type": "invoice", "number": "201008662", "variable": "201010029", "createTime": 1279951821, "dateOfPerformance": 1279951821, "dueDate": 1280556621, "price": 13.28, "priceWithVat": 15.94, "vatPercent": 20, "currency": "eur", "items": [ { "serviceName": "domain", "name": "websupport.sk", "price": 13.28, "priceWithVat": 15.94, "startTime": 1279749600, "endTime": 1311306526 }, { "serviceName": "thehosting", "name": "hostingname_1", "price": 10, "priceWithVat": 12, "startTime": 1279749600, "endTime": 1311306526 } ], "billing": { "name": "Company s.r.o.", "city": "Lorem Ipsum", "street": "Dolor sit 128", "zip": "12345", "country": "sk", "companyRegId": "", "taxId": "", "vatId": "" }, "market": { "name": "Slovensko", "identifier": "sk" } }, { "id": 30000, "type": "invoice", "number": "201114081", "variable": "201116129", "createTime": 1309080824, "price": 12.3, "priceWithVat": 14.76, "vatPercent": 20, "currency": "eur", "items": [ { "serviceName": "domain", "name": "websupport.sk", "price": 12.3, "priceWithVat": 14.76, "startTime": 1311199200, "endTime": 1342756126 } ], "billing": { "name": "Company s.r.o.", "city": "Lorem Ipsum", "street": "Dolor sit 128", "zip": "12345", "country": "sk", "companyRegId": "", "taxId": "", "vatId": "" }, "market": { "name": "Slovensko", "identifier": "sk" } } ], "pager": { "page": 1, "pagesize": null, "items": 2 } } ``` >Response `404` (not found) ```json { "message": "User not found.", "code": 404 } ``` Get an invoice detail {#invoice} ------------------------- >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:id" -v -u key:signature -H "Date: request_date_time" ``` *if you don't know invoice id, you can also get **unpaid** invoices by **order id** on url `/v1/user/:userId/invoice/by-order/:orderId` >Request ```http GET https://rest.websupport.sk/v1/user/:userId/invoice/:id HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "id": 20000, "type": "invoice", "number": "201008662", "variable": "201010029", "createTime": 1279951821, "price": 13.28, "priceWithVat": 15.94, "vatPercent": 20, "currency": "eur", "items": [ { "serviceName": "domain", "name": "websupport.sk", "price": 13.28, "priceWithVat": 15.94, "startTime": 1279749600, "endTime": 1311306526 }, { "serviceName": "thehosting", "name": "hostingname_1", "price": 10, "priceWithVat": 12, "startTime": 1279749600, "endTime": 1311306526 } ], "billing": { "name": "Company s.r.o.", "city": "Lorem Ipsum", "street": "Dolor sit 128", "zip": "12345", "country": "sk", "companyRegId": "", "taxId": "", "vatId": "" }, "market": { "name": "Slovensko", "identifier": "sk" } } ``` Get an invoice PDF {#invoice-pdf} ------------------------- Returns base64 encoded PDF file. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:id/pdf" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:userId/invoice/:id/pdf HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "id": "25000", "pdf": "JVBERi0xLjQKJb...." // very long line (base64 encoded pdf) } ``` Get an invoice PDF as RAW data {#invoice-raw-pdf} ------------------------- Returns a PDF file as binary data, **not JSON!** Headers are modified too. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:id/raw-pdf" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:userId/invoice/:id/raw-pdf HTTP/1.1 ``` >Response `200` ``` Binary data ``` Pay it {#get-inv-pay} ----------------------------------- You can pay your invoice with **credit card** or using **internet banking**. At this moment we support [TatraPay](http://www.tatrabanka.sk/en/business-banking/accounts-payments-cards/electronic-banking/tatrapay.html), [VUB ePayments](http://www.vub.sk/en/for-companies/nonstop-banking/ecommerce-online-retailers/epayments/) internet banking **ComfortPay** recurring payment system and Visa or MasterCard credit cards. Add `?mobile=1` at the end of each url, if you want mobile version of internet banking / credit card payment page. **Note:** if you choose ComfortPay payment system, we will store your payment card so you can use it next time through [pay with a stored card](#put-pay) method. If you don't want to store your payment card, please use CardPay system (tbcardpay). >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay" -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "tbtatrapay": "https://admin.websupport.sk/sk/invoice/pay/invoiceId/109430586/type/tatrapay", "tbcardpay": "https://admin.websupport.sk/sk/invoice/pay/invoiceId/109430586/type/creditCard-0", "vubeplatby": "https://admin.websupport.sk/sk/invoice/pay/invoiceId/109430586/type/vubeplatby", "comfortpay": "https://admin.websupport.sk/sk/invoice/pay/invoiceId/109430586/type/creditCard-0" } ``` >Response `404` (invoice not found, not confirmed or already paid) ```json { "code": 404, "message": "Invoice not found." } ``` Pay with a stored card {#put-pay} ----------------------------- You can pay your invoice with **payment card** that you have assigned to your account in the past. List of available payment cards for logged user can be fetched with [/v1/user/:userId/paymentcard](v1.order#paymentcards) api method. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay/byPaymentCard/:paymentCardId" -u key:signature -H "Date: request_date_time" -X PUT ``` >Request ```http PUT https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay/byPaymentCard/:paymentCardId HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "status": true } ``` >Response `404` (invoice not found, not confirmed or already paid) ```json { "code": 404, "message": "Invoice not found." } ``` Pay with credit {#put-credit-pay} --------------------------------- >Curl ```sh curl "https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay/byCredit" -u key:signature -H "Date: request_date_time" -X PUT ``` >Request ```http PUT https://rest.websupport.sk/v1/user/:userId/invoice/:invoiceId/pay/byCredit HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "status": true } ``` >Response `404` (invoice not found, not confirmed or already paid) ```json { "code": 404, "message": "Invoice not found." } ``` List of all payment cards, detail, add new card ... {#paymentcards} -------------------------- Go to [order section](v1.order#paymentcards) for more info.