You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Xero API为发票配置在线支付选项?

可以通过Xero API设置在线支付选项

要在API创建的发票中开启在线支付(比如绑定Stripe),你需要在请求的invoiceData里添加OnlineInvoice对象,指定启用在线支付并关联对应的支付服务ID。

关键修改步骤:

  1. 添加OnlineInvoice字段
    在你的invoiceData对象中加入以下结构:

    "OnlineInvoice": {
      "EnableOnlinePayment": true,
      "PaymentServiceID": "你的Stripe支付服务ID"
    }
    
    • EnableOnlinePayment设为true即可开启在线支付选项
    • PaymentServiceID是你在Xero后台配置的Stripe支付服务的唯一ID,可通过调用Xero的PaymentServices API获取(路径:https://api.xero.com/api.xro/2.0/PaymentServices)
  2. 修改后的完整代码
    把上述字段整合到你的Google Apps Script代码中,修改后的invoiceData如下:

    var invoiceData = {
      "Type": "ACCREC",
      "BrandingThemeID": data.branding,
      "Contact": {
        "Name": data.clientName
      },
      "Date": new Date(data.issueDate).toISOString().slice(0, 10),
      "DueDate": new Date(data.dueDate).toISOString().slice(0, 10),
      "Reference": data.clientReference,
      "LineItems": [
        {
          "ItemCode": data.item,
          "Quantity": data.quantity,
          "UnitAmount": data.amount,
        }
      ],
      // 新增在线支付配置
      "OnlineInvoice": {
        "EnableOnlinePayment": true,
        "PaymentServiceID": "替换为你的支付服务ID"
      }
    };
    

注意事项

  • 确保你的Xero账户已经配置好对应的支付服务(比如Stripe),否则PaymentServiceID无效
  • 调用PaymentServices API时需要使用和创建发票相同的授权头信息,返回结果中每个支付服务会包含其PaymentServiceID

内容的提问来源于stack exchange,提问作者Rafa Guillermo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 14:28:26