简体   繁体   English

如何使用PHP Wordpress将沙盒Paypal返回值插入MySQL表?

[英]How to insert sandbox Paypal return values into MySQL table using PHP Wordpress?

I have done some transactions done by sandbox PayPal and got the transaction completed. 我已经完成了由沙盒PayPal完成的一些交易,并完成了交易。 After completing the transaction I have redirecting the URL to payments received page eg www.example.com/payments-recieved/ . 完成交易后,我已将URL重定向到收款页面,例如www.example.com/payments-recieved/ And I have got some values in an array. 而且我在数组中有一些值。 The array receives the latest transaction details in an array as like this: 数组接收数组中的最新交易详细信息,如下所示:

echo "<pre>";print_r($_REQUEST);

    Array
    (
        [tx] => 3RA54961H14867235
        [st] => Completed
        [amt] => 29.00
        [cc] => USD
        [cm] => 
        [item_number] => 
        [sig] => scLH/oMz+Q0+arHSabEPju068IFOcpsnu5Mb77AkvDJ0S9LO0ZOjvLx68ojre4Y2ZWFB/dWNz3RtzCzwiY5p5zI8uRhbPoBZRwlIOTU8XRqif9Ni2g/E/Wc4LL6gs0fpo618MN4pFnbina2sYi6fyzhOQoS5se+4vBywzhG0X0E=
    )

Now I have to insert these details into Wordpress table how we insert these details please let me know. 现在,我必须将这些详细信息插入Wordpress表中,我们如何插入这些详细信息,请告诉我。 Help me please guys. 帮帮我,伙计们。

Many Thanks in advance... 提前谢谢了...

You can insert using below query, where order_details_table is your table name, you can change it 您可以使用下面的查询插入,其中order_details_table是您的表名,您可以更改它

if ( !empty( $_REQUEST) && $_REQUEST['st']=='completed' ){
    $wpdb->insert( 'order_details_table', array(
        'tx' => $_REQUEST['tx'], 
        'st' => $_REQUEST['st'],
        'amt' => $_REQUEST['amt'], 
        'cc' => $_REQUEST['cc'],
        'cm' => $_REQUEST['cm'], 
        'item_number' => $_REQUEST['item_number'], 
        'sig' => $_REQUEST['sig'],
    );
}

Remeber that this redirection page may not necessarily be like the other wordpress files. 请记住,此重定向页面可能不一定与其他wordpress文件一样。 You can have it like normal PHP file and it would still work. 您可以像普通的PHP文件一样拥有它,并且仍然可以使用。

$response = json_encode($_REQUEST);
if($respone->st == "completed")
{
    $sql = "insert into yourtable (Columns) values (values);
    //Format the above line and do normal way of sql execution
}
else
{
  //do whatever you want
}
//you can still display the status in this page

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM