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

Google Pay与PayPal集成适配咨询:已弃用API报错及替代接口选型问题

解决Google Pay与PayPal集成的API选择问题

首先明确:你正在使用的PayPal v1 Payments API(/v1/payments/payment)已经被完全弃用,这就是你收到INTERNAL_SERVICE_ERROR的核心原因——PayPal不再维护这个旧接口,必须切换到最新的v2 Orders API才能正常完成集成。

正确的API选择:PayPal Orders API(v2)

PayPal的v2 Orders API是当前唯一支持Google Pay集成的官方接口,而且它完全支持支付捕获功能——你之前觉得v2不支持捕获是误解,v2把支付流程拆分成了创建订单和捕获订单两个明确的步骤,和v1的逻辑完全对应。

核心流程说明

  1. 创建订单:调用POST /v2/checkout/orders,在请求体中把Google Pay的令牌放在payment_source.google_pay字段下;如果是用信用卡令牌测试,就放在payment_source.card字段。
  2. 捕获订单:订单创建成功后,调用POST /v2/checkout/orders/{order_id}/capture完成支付捕获,这一步会返回最终的支付结果。

简化的请求示例(Google Pay令牌场景)

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "USD",
        "value": "30.11",
        "breakdown": {
          "item_total": {
            "currency_code": "USD",
            "value": "30.00"
          },
          "tax_total": {
            "currency_code": "USD",
            "value": "0.07"
          },
          "shipping": {
            "currency_code": "USD",
            "value": "0.03"
          },
          "handling": {
            "currency_code": "USD",
            "value": "1.00"
          },
          "shipping_discount": {
            "currency_code": "USD",
            "value": "-1.00"
          },
          "insurance": {
            "currency_code": "USD",
            "value": "0.01"
          }
        }
      },
      "description": "The payment transaction description.",
      "invoice_id": "48787589673",
      "soft_descriptor": "ECHI5786786",
      "items": [
        {
          "name": "hat",
          "description": "Brown hat.",
          "quantity": "5",
          "unit_amount": {
            "currency_code": "USD",
            "value": "3.00"
          },
          "tax": {
            "currency_code": "USD",
            "value": "0.01"
          },
          "sku": "1"
        },
        {
          "name": "handbag",
          "description": "Black handbag.",
          "quantity": "1",
          "unit_amount": {
            "currency_code": "USD",
            "value": "15.00"
          },
          "tax": {
            "currency_code": "USD",
            "value": "0.02"
          },
          "sku": "product34"
        }
      ],
      "shipping": {
        "address": {
          "full_name": "Brian Robinson",
          "address_line_1": "4th Floor",
          "address_line_2": "Unit #34",
          "admin_area_2": "San Jose",
          "admin_area_1": "CA",
          "postal_code": "95131",
          "country_code": "US"
        },
        "phone": {
          "phone_number": {
            "national_number": "011862212345678"
          }
        }
      }
    }
  ],
  "payment_source": {
    "google_pay": {
      "token": "YOUR_GOOGLE_PAY_TOKEN_HERE"
    }
  },
  "note_to_payer": "Contact us for any questions on your order."
}

关键注意事项

  • 如果你用信用卡令牌测试,只需要把payment_source替换成:
    "payment_source": {
      "card": {
        "token": "YOUR_CREDIT_CARD_TOKEN_HERE"
      }
    }
    
  • 确保使用的API域名是api-m.sandbox.paypal.com(沙箱环境)或api-m.paypal.com(生产环境),和你之前的域名一致,但接口路径必须是v2的规范路径。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 11:12:39