签出 API 安装指南引用了杀死测试页并且不存在于 API 中的命令

Checkout API Setup Guide references commands that kill test pages AND do not exist in API

结帐 API 设置指南中的以下代码片段

https://docs.connect.squareup.com/payments/checkout/setup 引用 GetID()

导致页面失效不在API:

$checkoutId = $result->getId();

$checkoutUrl = $result->getCheckoutPageUrl();

事实上,除了安装指南外,我在技术文档或 API 参考中找不到对这些命令的引用。

设置指南有误还是我遗漏了什么? Checkout 不是完全在线吗?我不确定为什么设置示例不会得到更多支持或参考现有文档。

更新:在随SDK提供的文件中,文件Checkout.md描述了getId()和getCheckoutPageUrl()是受保护属性的getter:

Note: All properties are protected and only accessed via getters and setters.

我明白了……它们似乎不起作用。

查看 GitHub 上的 Square PHP SDK documentation。看起来那个文档中可能有错误,我认为你想要的代码是这样的:

(他们缺少的关键部分是 ->getCheckout()

try {
    $result = $checkoutClient->createCheckout(
      $locationId,
      $checkout
    );
    //Save the checkout ID for verifying transactions
    $checkoutId = $result->getCheckout()->getId();
    //Get the checkout URL that opens the checkout page.
    $checkoutUrl = $result->getCheckout()->getCheckoutPageUrl();
    print_r('Complete your transaction: ' + $checkoutUrl);
} catch (Exception $e) {
    echo 'Exception when calling CheckoutApi->createCheckout: ', $e->getMessage(), PHP_EOL;
}

如果这对您不起作用,请告诉我。