Checkout API get email of buyer on redirect

五迷三道 提交于 2019-12-24 10:08:34

问题


So using the square checkout api, after the user uses the square checkout, I get a transaction id and checkout id, but it seems theres no way to get the information the buyer entered at checkout. How can I get the email and name of said buyer?

Tried getting the info through the checkout id but it seems its not possible

// pull out the transaction ID returned by Square Checkout
$returnedTransactionId = $_GET["transactionId"];

// Create a new API object to verify the transaction
$transactionClient = new \SquareConnect\Api\TransactionsApi($defaultApiClient);

// Ping the Transactions API endpoint for transaction details
try {

  // Get transaction details for this order from the Transactions API endpoint
  $apiResponse = $transactionClient->retrieveTransaction(
    $locationId,
    $returnedTransactionId
  );

} catch (Exception $e) {
  echo "The SquareConnect\Configuration object threw an exception while " .
       "calling TransactionsApi->retrieveTransaction: ",
       $e->getMessage(), PHP_EOL;
  exit;
}

回答1:


Once you retrieve the transaction like you're already doing, the response will have a field called tenders, and in this array field you'll find a field called customer_id. Using this customer_id, you can call RetrieveCustomer and get the customer's information, including their name and email.



来源:https://stackoverflow.com/questions/56166643/checkout-api-get-email-of-buyer-on-redirect

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