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。
答案 0 :(得分: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