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

被刻印的时光 ゝ 提交于 2019-12-13 03:56:21

问题


The following code snippets in the Checkout API Setup Guide at

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

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

$checkoutId = $result->getId();

AND

$checkoutUrl = $result->getCheckoutPageUrl();

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

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.

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

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

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


回答1:


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:

(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.



来源:https://stackoverflow.com/questions/51799860/checkout-api-setup-guide-references-commands-that-kill-test-pages-and-do-not-exi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!