【问题标题】:WooCommerce: Call the Thankyou from my php fileWooCommerce:从我的 php 文件中调用Thankyou
【发布时间】:2020-09-02 07:31:29
【问题描述】:

我是 WooCommerce 的新手。付款后,我被重定向到另一个 PHP 文件 (testpayresult.php)。从这个文件中,我需要重定向到 WooCommerce 中的Thankyou 页面。我如何做到这一点?

将订单详情发送到支付网关 API:

echo '<script src="https://test.oppwa.com/v1/paymentWidgets.js?checkoutId='. $responseData->id . '"></script>';
echo '<form action="/wp-content/plugins/woo-payment-gateway-for-taurus-datafast/testpayresult.php" class="paymentWidgets" data-brands="VISA MASTER AMEX DINER DISCOVER"> </form>';
echo '<form action="/wp-content/plugins/woo-payment-gateway-for-taurus-datafast/testpayresult.php" class="paymentWidgets" data-brands="VISA MASTER AMEX DINER DISCOVER"> </form>';

testpayresult.php 文件:

<?php
echo "Payment Over";
echo "<br />POST<br />";
$resourcePath  = '/v1/checkout/' . $_GET["id"] . "/payment";  //$_GET["resourcePath"];
echo "<br /> Resource Path: " . $resourcePath;
$entityId  = $_GET["id"];
echo "<br /> Entity Id: " . $entityId;

//echo "<br /><br /> Thanks Page URL: " . get_option( 'woocommerce_thanks_page_id' );
echo "<br />";

function check_transaction_status($presourcePath, $pentityId)
{
    $url = "https://test.oppwa.com" . $presourcePath;
    $url .= "?entityId=8ac7a4ca7402389d0174023e6b6b001c";
    
    echo "<br />URL: " . $url;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization:Bearer OGE4Mjk0MTg1YTY1YmY1ZTAxNWE2YzhjNzI4YzBkOTV8YmZxR3F3UTMyWA=='
    ));
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    // this should be set to true in production
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $responseData = curl_exec($ch);

    if (curl_errno($ch)) {
        return curl_error($ch);
    }

    curl_close($ch);
    return $responseData;
}

$response = check_transaction_status($resourcePath, $entityId);

【问题讨论】:

  • 要获得订单的 WooCommerce 感谢页面 url,至少需要订单 ID...
  • 如何在 testpayresultfile.php 中获取订单 ID?它由 wooshop-taurus-datafast.php 文件中的 generate_taurusdatafast_form($order) 函数中的提交调用 Github中的代码github.com/abrahamtaurus/datafast/blob/master/…

标签: woocommerce payment-processing


【解决方案1】:

如何在 testpayresultfile.php 中获取订单 ID?

由wooshop-taurus-datafast.php文件中generate_taurusdatafast_form($order)函数中的submit调用

Code in Github

【讨论】:

    猜你喜欢
    • 2014-09-28
    • 2022-12-15
    • 2019-01-08
    • 1970-01-01
    • 2017-01-20
    • 2023-03-29
    • 2017-08-20
    • 1970-01-01
    • 2017-10-22
    相关资源
    最近更新 更多