本文介绍了Checkout API 设置指南引用了杀死测试页面且 API 中不存在的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The following code snippets in the Checkout API Setup Guide at

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

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

导致页面失败且不在 API 中:

cause the page to fail and are not in the API:

$checkoutId = $result->getId();

$checkoutUrl = $result->getCheckoutPageUrl();

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

In fact, I cannot find reference to those commands anywhere in the technical docs or API reference except on the Setup Guide.

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

Is the Setup Guide wrong or am I missing something? Is Checkout not fully live? I am not sure why a setup example would not be more supported or reference existing documentation.

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

Update: In the file provided with the SDK, the file Checkout.md describes that getId() and getCheckoutPageUrl() are getters for protected properties:

注意:所有属性都受到保护,只能通过 getter 和 setter 访问.

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

I get that... they just don't seem to work.

推荐答案

查看GitHub 上的方形 PHP SDK 文档.看起来那个文件可能有错误,我认为你想要的代码是这样的:

Check out the Square PHP SDK documentation on GitHub. Looks like there might be a mistake in that document, I think the code you want is something like:

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

(they key missing part being a ->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;
}

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

Let me know if that doesn't work for you.

这篇关于Checkout API 设置指南引用了杀死测试页面且 API 中不存在的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 03:49