我在PayPal上通过沙盒模式完成了一项交易,我使用的是Wordpress平台。问题是我的插入查询没有被执行。
交易完成后,我将页面从沙盒重定向到 xyz.com/payments-recieved ,在这里我打印了数组并获得了
Array
(
[tx] => 44K35922JH447994H
[st] => Completed
[amt] => 29.00
[cc] => USD
[cm] =>
[item_number] =>
[sig] => NXsJYzHJsIoReedCjkhnpWPQgoqLa5j4fAxcqk+CxJqgVHjdlBB/yWx0h4JVez/e2k+OOKeuhdgh/YxcD0bcR8JwmCd3GFE5N2UxoOws2JusqegLytKpcp6PmEb92aj9B1+e6MMHOf5VKjwX0z50imRiRtjYUSRasFT5IKiNbyA=
)
之后我试图将所有细节插入表中,这是我的完整代码。
<?php
/*
Template Name: All Payments History
*/
get_header();
echo "Thanks for choosing our plan<br />";
echo "<pre>";print_r($_REQUEST);
global $wpdb; //global query variable
if($_GET['st']=="Completed") /*check if transaction successfull or not*/
{
$item_transaction = $_GET['tx'];
$item_price = $_GET['amt'];
$item_currency = $_GET['cc'];
$item_no = $_GET['item_number'];
$wpdb->insert("wp_paypal_payments_tracking", array(
"transaction_id" => $item_transaction,
"amount" => $item_price,
"currency_type" => $item_currency,
"item_number" => $item_no,
));
echo "Payment Done Successfully";
}
get_footer();
?>
我们如何解决插入查询是否有任何问题在我的代码中,请让我知道并帮助我。
最诚挚的问候!!!
答案 0 :(得分:1)
您可以使用查询插入,其中wp_paypal_payments_tracking是您的表名,您可以更改它
if ( !empty( $_REQUEST) && $_REQUEST['st']=='completed' ){
$wpdb->insert( 'wp_paypal_payments_tracking', array(
'tx' => $_REQUEST['tx'],
'st' => $_REQUEST['st'],
'amt' => $_REQUEST['amt'],
'cc' => $_REQUEST['cc'],
'cm' => $_REQUEST['cm'],
'item_number' => $_REQUEST['item_number'],
'sig' => $_REQUEST['sig'],
);
}