【问题标题】:More Square Checkout Example problems - no verification ID available更多 Square Checkout 示例问题 - 没有可用的验证 ID
【发布时间】:2018-08-13 15:57:53
【问题描述】:

Square Checkout API 设置指南示例位于:

https://docs.connect.squareup.com/payments/checkout/setup

说您需要存储 CheckoutId 以供以后验证。不幸的是,编写示例的人(除了我在其他地方提到的许多编码错误之外)没有完成示例并提供验证码。如果他们有,他们可能已经看到没有交易 id 匹配能力。

也许我遗漏了一些东西,但如果你比较 Checkout 对象

object(SquareConnect\Model\CreateCheckoutResponse)#25 (2) {
  ["checkout":protected]=>
  object(SquareConnect\Model\Checkout)#26 (10) {
    ["id":protected]=>
    string(30) "xxxxxxxxxx"
    ["checkout_page_url":protected]=>
    string(106) "removed for security"
    ["ask_for_shipping_address":protected]=>
    bool(false)
    ["merchant_support_email":protected]=>
    NULL
    ["pre_populate_buyer_email":protected]=>
    string(16) "client@email.com"
    ["pre_populate_shipping_address":protected]=>
    NULL
    ["redirect_url":protected]=>
    string(43) "whateverreturn.php"
    ["order":protected]=>
    object(SquareConnect\Model\Order)#27 (7) {
      ["id":protected]=>
      NULL
      ["location_id":protected]=>
      string(30) "xxxxxxxxxx"
      ["reference_id":protected]=>
      NULL
      ["line_items":protected]=>
      array(1) {
        [0]=>
        object(SquareConnect\Model\OrderLineItem)#28 (13) {
          ["name":protected]=>
          string(16) "MyCheckout Title"
          ["quantity":protected]=>
          string(1) "1"
          ["note":protected]=>
          NULL
          ["catalog_object_id":protected]=>
          NULL
          ["variation_name":protected]=>
          NULL
          ["modifiers":protected]=>
          NULL
          ["taxes":protected]=>
          NULL
          ["discounts":protected]=>
          NULL
          ["base_price_money":protected]=>
          object(SquareConnect\Model\Money)#29 (2) {
            ["amount":protected]=>
            int(60000)
            ["currency":protected]=>
            string(3) "USD"
          }
          ["gross_sales_money":protected]=>
          object(SquareConnect\Model\Money)#30 (2) {
            ["amount":protected]=>
            int(60000)
            ["currency":protected]=>
            string(3) "USD"
          }
          ["total_tax_money":protected]=>
          object(SquareConnect\Model\Money)#31 (2) {
            ["amount":protected]=>
            int(0)
            ["currency":protected]=>
            string(3) "USD"
          }
          ["total_discount_money":protected]=>
          object(SquareConnect\Model\Money)#32 (2) {
            ["amount":protected]=>
            int(0)
            ["currency":protected]=>
            string(3) "USD"
          }
          ["total_money":protected]=>
          object(SquareConnect\Model\Money)#33 (2) {
            ["amount":protected]=>
            int(60000)
            ["currency":protected]=>
            string(3) "USD"
          }
        }
      }
      ["total_money":protected]=>
      object(SquareConnect\Model\Money)#34 (2) {
        ["amount":protected]=>
        int(60000)
        ["currency":protected]=>
        string(3) "USD"
      }
      ["total_tax_money":protected]=>
      object(SquareConnect\Model\Money)#35 (2) {
        ["amount":protected]=>
        int(0)
        ["currency":protected]=>
        string(3) "USD"
      }
      ["total_discount_money":protected]=>
      object(SquareConnect\Model\Money)#36 (2) {
        ["amount":protected]=>
        int(0)
        ["currency":protected]=>
        string(3) "USD"
      }
    }
    ["created_at":protected]=>
    string(20) "2018-08-13T15:42:57Z"
    ["additional_recipients":protected]=>
    NULL
  }
  ["errors":protected]=>
  NULL
}

到响应对象:

object(SquareConnect\Model\RetrieveTransactionResponse)#17 (2) {
  ["errors":protected]=>
  NULL
  ["transaction":protected]=>
  object(SquareConnect\Model\Transaction)#18 (10) {
    ["id":protected]=>
    string(56) "A4ccOMcXsMJL14ZGAJUgQPqVW580zoRoGiVIQdWOgHLyXeThrKgTwLhO"
    ["location_id":protected]=>
    string(30) "xxxxxxxxxx"
    ["created_at":protected]=>
    string(20) "2018-08-13T15:49:50Z"
    ["tenders":protected]=>
    array(1) {
      [0]=>
      object(SquareConnect\Model\Tender)#19 (13) {
        ["id":protected]=>
        string(36) "2d306255-fe2e-59e9-411b-acb2bcec7a51"
        ["location_id":protected]=>
        string(30) "xxxxxxxxxx"
        ["transaction_id":protected]=>
        string(56) "A4ccOMcXsMJL14ZGAJUgQPqVW580zoRoGiVIQdWOgHLyXeThrKgTwLhO"
        ["created_at":protected]=>
        string(20) "2018-08-13T15:49:50Z"
        ["note":protected]=>
        string(18) "Online Transaction"
        ["amount_money":protected]=>
        object(SquareConnect\Model\Money)#20 (2) {
          ["amount":protected]=>
          int(60000)
          ["currency":protected]=>
          string(3) "USD"
        }
        ["tip_money":protected]=>
        NULL
        ["processing_fee_money":protected]=>
        object(SquareConnect\Model\Money)#21 (2) {
          ["amount":protected]=>
          int(1750)
          ["currency":protected]=>
          string(3) "USD"
        }
        ["customer_id":protected]=>
        string(30) "xxxxxxxxxx"
        ["type":protected]=>
        string(4) "CARD"
        ["card_details":protected]=>
        object(SquareConnect\Model\TenderCardDetails)#22 (3) {
          ["status":protected]=>
          string(8) "CAPTURED"
          ["card":protected]=>
          object(SquareConnect\Model\Card)#23 (8) {
            ["id":protected]=>
            NULL
            ["card_brand":protected]=>
            string(4) "VISA"
            ["last_4":protected]=>
            string(4) "1111"
            ["exp_month":protected]=>
            NULL
            ["exp_year":protected]=>
            NULL
            ["cardholder_name":protected]=>
            NULL
            ["billing_address":protected]=>
            NULL
            ["fingerprint":protected]=>
            string(64) "727f3523fa0152dbd702c84c6a9636df646d90100c305080ad7a185b954ad591"
          }
          ["entry_method":protected]=>
          string(5) "KEYED"
        }
        ["cash_details":protected]=>
        NULL
        ["additional_recipients":protected]=>
        NULL
      }
    }
    ["refunds":protected]=>
    NULL
    ["reference_id":protected]=>
    NULL
    ["product":protected]=>
    string(12) "EXTERNAL_API"
    ["client_id":protected]=>
    NULL
    ["shipping_address":protected]=>
    NULL
    ["order_id":protected]=>
    string(56) "A4ccOMcXsMJL14ZGAJUgQPqVW580zoRoGiVIQdWOgHLyXeThrKgTwLhO"
  }
}

没有交易 id、结账 id 或其他您可以匹配的 id 以按照指示验证交易。

【问题讨论】:

    标签: checkout square


    【解决方案1】:

    checkout_id 是发送到redirect_url 的参数之一。结帐交易完成后,它将自动重定向到您指定的网址(redirect_url),格式如下:

    http://www.example.com/order-complete?checkoutId=xxxxxx&orderId=xxxxxx&referenceId=xxxxxx&transactionId=xxxxxx

    checkoutId 参数可以与您提到的示例中保存的id 进行比较。

    参考资料: https://docs.connect.squareup.com/api/connect/v2#type-checkout

    【讨论】:

    • 好的,这很有意义。希望在这个例子中更清楚一点......这里只是一个普通人 - 不是真正的编码器!非常感谢!
    • 好的,刚刚检查过了,你是对的,CheckoutId 在 URL 中作为 $_GET 参数返回,但是......它根本不在 API 响应中。只是看起来很奇怪。在回复中包含这不是一件有用的事情吗!
    猜你喜欢
    • 2020-04-22
    • 1970-01-01
    • 2011-06-27
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 2013-02-15
    • 1970-01-01
    相关资源
    最近更新 更多