跳到主要内容

创建 SwissQR 账单 API

此端点的作用

PDF4me 创建 SwissQR 账单 瑞士人 QR 符合瑞士规定的付款单 QR-账单标准(瑞士支付标准, SPS)通过单个 REST 拨打电话。发送 债权人和最终债务人的详细信息 IBAN金额、货币、参考类型、语言、分隔符样式和输出格式(可选)包含源文档 Base64,blob ID,或 URL 将滑移层覆盖在现有滑移层上 PDF。 这 API 返回 PDFPNGJPEG, 或者 TIFF 根据 格式类型

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

每一个 PDF4me REST API 通话必须包含您的 API 关键在于 Authorization 标题。从开发者控制面板创建或选择一个密钥,并妥善保管。

端点

邮政/api/v2/CreateSwissQrBill

您不容错过的重要事实

瑞士IBAN格式经过严格验证
债权人 他们要走了 必须从 CH 后面跟着19位数字。无效密码。 IBAN 返回错误。
生产环境请使用结构化地址类型 (S)。
crAddressTypeudAddressTypeS 因此,街道、门牌号、邮政编码和城市分别存储。大多数瑞士银行自动对账系统都要求采用这种布局。 K (合并)仅当无法拆分地址分量时才使用。
将参考类型与您的对账工作流程相匹配
对于没有结构化参考信息的付款。 QRR 用于瑞士国内纸币上的 27 位数字参考编号。 得分 为了 ISO 11649 债权人证明。请提供。 参考 使用时在体内 QRR 或者 SCOR

REST API 端点

方法: 邮政
网址: https://api.pdf4me.com/api/v2/CreateSwissQrBill

IsAsync真的PascalCase) 为了 202 Accepted 并进行民意调查 地点 URLGET 直到你收到 200 以及该文件 JSON。 使用 错误的 对于同步 200 回复。

Postman 请求设置

环境价值
MethodPOST
URLhttps://api.pdf4me.com/api/v2/CreateSwissQrBill
HeadersContent-Type: application/json
AuthorizationBasic Auth with your API key, or header Authorization: Basic YOUR_API_KEY
AsyncIf the response is 202, poll the URL in the Location header (GET) until you get 200 and the file bytes (or JSON with document fields, depending on API version).

参数

始终需要: 他们要走了crNamecrAddressTypecrStreetOrAddressLine1crStreetOrAddressLine2crPostalCodecrCity数量货币udNameudAddressTypeudStreetOrAddressLine1udStreetOrAddressLine2udPostalCodeudCity参考类型语言类型分隔线格式类型, 和 IsAsync

条件: 文档内容文档名称 在 PDF 上叠加时; 参考 什么时候 参考类型QRR 或者 得分分页选项页码 什么时候 格式类型pdf

选修的: 非结构化消息账单信息av1av2简介

范围必需的适用于它的作用例子
docContentConditionalOverlay on existing PDFOmit or empty string = standalone QR slip only. Otherwise Base64 PDF/image bytes (no data: prefix), blob id from POST /api/v2/UploadBlob, or HTTPS URL to the source file.""
docNameConditionalWith docContentFile name for input/output context. Omit or empty when no source document.invoice.pdf
ibanYesEvery requestCreditor Swiss IBAN.CH0200700110003765824
crNameYesEvery requestCreditor name or company as registered with the bank.Test AG
crAddressTypeYesEvery requestS = structured (street + building) or K = combined address lines.S
crStreetOrAddressLine1YesEvery requestIf S: street name (max ~70 chars). If K: first address line.Test Strasse
crStreetOrAddressLine2YesEvery requestIf S: house number (max ~16). If K: second address line.1
crPostalCodeYesEvery requestCreditor postal code (max ~16).8000
crCityYesEvery requestCreditor city (max ~35).Zurich
amountYesEvery requestPayment amount without leading zeros (string). Example: "1000" = 1000.00.1000
currencyYesEvery requestCHF or EUR.CHF
udNameYesEvery requestUltimate debtor name or company (required by API; may be empty strings if unused).Test Debt AG
udAddressTypeYesEvery requestS or K; same rules as crAddressType.S
udStreetOrAddressLine1YesEvery requestDebtor street or address line 1.Test Deb Strasse
udStreetOrAddressLine2YesEvery requestDebtor street number or address line 2.2
udPostalCodeYesEvery requestDebtor postal code.8000
udCityYesEvery requestDebtor city.Zurich
referenceTypeYesEvery requestNON = no reference, QRR = QR reference, SCOR = creditor reference.NON
referenceConditionalreferenceType = QRR or SCORRequired for QRR or SCOR; max 27 characters. Omit for NON.21000000000313947143000017
languageTypeYesEvery requestEnglish, German, French, or Italian.English
seperatorLineYesEvery requestAPI spelling is seperatorLine (one a). LineWithScissor, DottedLine, or SolidLine.LineWithScissor
formatTypeYesEvery requestOutput format: pdf, png, jpeg, tiff, or null (default PDF behavior).pdf
pagingOptionsConditionalformatType = pdffirst, last, AddPageAtEnd, or custom. Omit or null for non-PDF formats.first
pageNumberConditionalpagingOptions = customInteger >= 1; single page index when pagingOptions is custom.1
unstructuredMessageNoOptionalFree-form payment note. Max 140 characters.Thank you for your business
billingInfoNoOptionalCustomer billing information.Invoice for services rendered
av1NoOptionalAlternative scheme parameter 1.
av2NoOptionalAlternative scheme parameter 2.
profilesNoOptionalCustom API profile JSON string. See API documentation for profile options.{ "someOption": true }
IsAsyncYesEvery requestPascalCase IsAsync. true = HTTP 202 and poll Location. false = synchronous HTTP 200.true

地址类型选项

适用于 crAddressTypeudAddressType

S(结构化)推荐用于自动对账
将街道、门牌号、邮政编码和城市分别记录在不同的字段中。大多数瑞士银行系统需要这些信息来进行自动对账。
K(综合)两条自由格式地址线
将地址存储为两行合并的自由格式文本。这种存储方式更易于填写,但与自动对账的兼容性较差。

分隔线选项(seperatorLine

用剪刀画线
带有剪刀符号的穿孔切割线。瑞士印刷发票的默认样式。
虚线
发票和撕取单之间的虚线分隔线。
实线
没有剪刀符号的实线分隔线。

参考类型选项

没有结构化参考
简单支付的默认设置。使用 非结构化消息 改为自由格式笔记,而不是 参考
QRR27 位二维码参考
瑞士国内纸币 PostFinance 或瑞士银行 IBANs你必须发送 参考 以 27 位数字字符串的形式。
得分ISO 11649 债权人参考
跨境 SEPA样式匹配。发送 参考ISO 11649 格式(以……开头) RF)。

输出格式(formatType) 和 PDF 分页

什么时候 格式类型pdf, 放 分页选项 控制位置 QR 放置滑片。对于图像输出,请省略。 分页选项 或者将其设置为 无效的

formatType: pdfpagingOptions: first
Place QR slip on the first page.
formatType: pdfpagingOptions: last
Place QR slip on the last page.
formatType: pdfpagingOptions: AddPageAtEnd
Append a new page with the QR slip at the end.
formatType: pdfpagingOptions: custom + pageNumber
Place on a specific page (e.g. pageNumber: 1).
formatType: png | jpeg | tiffpagingOptions: null
No paging; returns image bytes.

输出字段

场地类型它包含什么
docNameStringOutput file name.
docContentBase64Generated file (PDF or image per formatType). Decode before saving or streaming.

请求示例

示例 A:独立式 QR 账单(无输入) PDF

省略 文档内容 或者发送一个空字符串,仅生成 QR 付款单。

{
"docContent": "",
"docName": "",
"iban": "CH0200700110003765824",
"crName": "Test AG",
"crAddressType": "S",
"crStreetOrAddressLine1": "Test Strasse",
"crStreetOrAddressLine2": "1",
"crPostalCode": "8000",
"crCity": "Zurich",
"amount": "1000",
"currency": "CHF",
"udName": "Test Debt AG",
"udAddressType": "S",
"udStreetOrAddressLine1": "Test Deb Strasse",
"udStreetOrAddressLine2": "2",
"udPostalCode": "8000",
"udCity": "Zurich",
"referenceType": "NON",
"languageType": "English",
"seperatorLine": "LineWithScissor",
"formatType": "pdf",
"pagingOptions": "first",
"IsAsync": true
}

示例 B:叠加 QR 在现有基础上 PDFBase64

代替 文档内容 你的 PDF 作为 Base64 (不 数据: 前缀)。

{
"docContent": "JVBERi0xLjQKJeLjz9MKMy...",
"docName": "invoice.pdf",
"iban": "CH0200700110003765824",
"crName": "Test AG",
"crAddressType": "S",
"crStreetOrAddressLine1": "Test Strasse",
"crStreetOrAddressLine2": "1",
"crPostalCode": "8000",
"crCity": "Zurich",
"amount": "1000",
"currency": "CHF",
"udName": "Test Debt AG",
"udAddressType": "S",
"udStreetOrAddressLine1": "Test Deb Strasse",
"udStreetOrAddressLine2": "2",
"udPostalCode": "8000",
"udCity": "Zurich",
"referenceType": "NON",
"languageType": "English",
"seperatorLine": "LineWithScissor",
"formatType": "pdf",
"pagingOptions": "custom",
"pageNumber": 1,
"IsAsync": true
}

示例 C:复制粘贴有效 JSON

{
"docContent": "",
"docName": "",
"iban": "CH0200700110003765824",
"crName": "Test AG",
"crAddressType": "S",
"crStreetOrAddressLine1": "Test Strasse",
"crStreetOrAddressLine2": "1",
"crPostalCode": "8000",
"crCity": "Zurich",
"amount": "1000",
"currency": "CHF",
"udName": "Test Debt AG",
"udAddressType": "S",
"udStreetOrAddressLine1": "Test Deb Strasse",
"udStreetOrAddressLine2": "2",
"udPostalCode": "8000",
"udCity": "Zurich",
"referenceType": "NON",
"languageType": "English",
"seperatorLine": "LineWithScissor",
"formatType": "pdf",
"pagingOptions": "first",
"IsAsync": true
}

引用类型有效载荷

无参考文献(非):

{ "referenceType": "NON" }

QR参考码(QRR):

{
"referenceType": "QRR",
"reference": "21000000000313947143000017"
}

债权人参考编号(SCOR,ISO 11649):

{
"referenceType": "SCOR",
"reference": "RF18539007547034"
}

formatType 和 pageingOptions 代码片段

{ "formatType": "png", "pagingOptions": null }
{ "formatType": "pdf", "pagingOptions": "last" }
{ "formatType": "pdf", "pagingOptions": "AddPageAtEnd" }
{ "formatType": "pdf", "pagingOptions": "custom", "pageNumber": 1 }

代码示例

集成示例

常见的 REST 集成模式Typical ways developers call Create SwissQR Bill.
ERP发票导出 → 瑞士二维码账单PDF
  1. 您的ERP系统会导出发票数据和PDF文件。
  2. 将 PDF 文件进行 Base64 编码 文档内容
  3. POST 付款字段 参考类型 QRR 和 27 位数字 参考
  4. 解码 文档内容 从回复中获取并存储或通过电子邮件发送二维码账单 PDF 文件。
独立式滑套或网钩覆盖层
  1. 仅需撕取式收据,请附上空白收据并邮寄。 文档内容格式类型 pdf 或 png 格式。
  2. 对于通过 webhook 发送的发票,将 PDF 文件进行 Base64 编码。 文档内容, 放 分页选项最后的 或者 风俗以及 POST 付款字段。
  3. 解读回应 文档内容 并上传到对象存储或附加到电子邮件 API。

常见问题解答

Which currencies does the API accept?+
Set currency to CHF for domestic Swiss payments or EUR for cross-border transactions. The amount and currency must match what you print on the slip.
What is the difference between NON, QRR, and SCOR?+
They are values for the referenceType field. NON means no structured reference is encoded in the QR code; you can still add unstructuredMessage such as an invoice number. QRR is for domestic Swiss QR-bills: send reference as a 27-digit numeric string when referenceType is QRR. SCOR follows ISO 11649 (starts with RF); send reference when referenceType is SCOR.
Should I use Structured (S) or Combined (K) addresses?+
Use S (Structured) for almost all production integrations. Set crAddressType to S, put the street in crStreetOrAddressLine1, the house number in crStreetOrAddressLine2, and fill crPostalCode and crCity. Use the same pattern for the ultimate debtor with udAddressType and udStreetOrAddressLine fields. Use K (Combined) only when you cannot split the address into separate fields.
Is docContent required?+
No. Omit docContent or send an empty string to generate a standalone QR payment slip. To embed the slip on an invoice, send docContent as Base64 PDF bytes, a blob id from UploadBlob, or a direct HTTPS URL, and set docName when needed for context.
What do formatType and pagingOptions control?+
formatType sets the output: pdf, png, jpeg, or tiff. When formatType is pdf, pagingOptions chooses where the slip is placed: first page, last page, AddPageAtEnd, or custom with pageNumber. For image formats, omit pagingOptions or set it to null.
What does IsAsync do?+
IsAsync controls how the response is delivered. When IsAsync is false (or omitted in samples that use synchronous mode), a successful call returns HTTP 200 with docName and docContent in one JSON body. When IsAsync is true, the API returns HTTP 202 Accepted and a Location header with a poll URL. Send GET requests to that URL until you receive 200 with the same docName and docContent fields. Use async for large batches or slow networks; use sync for simple request-response scripts.
How do I test the API without writing code?+
Open the Create SwissQR Bill API Tester, paste your API key, then fill payment, creditor, and debtor fields, referenceType, languageType, seperatorLine, and IsAsync. Add docContent only when overlaying on a PDF. Use the parameter table on this page as a checklist.
Is the response binary or Base64?+
The response is always JSON, never a raw application/pdf stream. On success the body contains docName (output filename) and docContent (the full PDF encoded as a Base64 string). Decode docContent in your language (for example Buffer.from in Node.js, base64.b64decode in Python, Convert.FromBase64String in C#) before writing the file. Invalid IBAN, missing required fields, or malformed Base64 in docContent typically produce HTTP 400 with an error message in JSON.
What IBAN format is required?+
The iban field must be a valid Swiss creditor IBAN: CH followed by 19 digits (21 characters total), linked to a PostFinance or Swiss bank account. Invalid IBANs cause the request to fail.

相关行动

在其他平台上执行相同的任务

获取帮助