Campy
Campy

Reputation: 181

How to track sandbox Paypal recurring transactions in Wordpress by manually with MySQL

I have created 3 tables for price listing by using a price listing plugin and add 'PayNow' button for recurring payments through PayPal. Now I am using the sandbox for testing purposes. I have set custom URL for 'PayNow' button like this https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&[email protected]&item_name=Bronze%27s%20Pack&a3=29.00&p3=1&t3=D&srt=12&sra=1&src=1&currency_code=USD&return=http://example.com/payments-recieved/

When I click on 'PayNow' button it will redirect to Paypal and be showing the recurring offers for daily basis. After all the things done payment completed then I have the redirect to payment received a page in Wordpress and I have called there a PHP template where I print array and got these values.

Array
(
    [tx] => 4M134216E2452352C
    [st] => Completed
    [amt] => 29.00
    [cc] => USD
    [cm] => 
    [item_number] => 
    [sig] => VMCQP7/uVkdAsN/sNNRcpYeFRTzD57Y3u2NnJcPi06O530J1JUmk7Wm6hoyOXdWJWZHnwMHh00JcsZvMmcqnuzswZlbh7nc2regh2hXFiTPj0WoIlMEMuTesclA6uq5At760uJoQxRKVw0ryj8poJSUpT7xxncecCNdK66Rn/CU=
)

I check my sandbox Paypal account history it will show the recurring payments with the current date, next date cycle, and the last date of the cycle. On PHP template page the array receives the complete transactions. But I don't find the transaction in database tables history.

How we got the entry of the transaction in database track every record for future references. Can we insert the transaction manually if yes then how will we do this? Please help me out and give me the best solution.

Many Thanks!!!

Upvotes: 4

Views: 125

Answers (1)

Candy Man
Candy Man

Reputation: 95

Try this mate, I think it will help you,

<?php
    /*
        Template Name: All Payments History
    */
        get_header();
    echo "<pre>";print_r($_REQUEST);
    global $wpdb; //global query variable
    $wpdb->show_errors();

    if (!empty( $_REQUEST) && $_REQUEST['st']=='Completed'){
        $wpdb->insert('wp_paypal_payments_tracking', array(
            'transaction_id' => $_REQUEST['tx'], 
            'transaction_status' => $_REQUEST['st'],
            'amount' => $_REQUEST['amt'], 
            'currency_type' => $_REQUEST['cc'],
            'item_number' => $_REQUEST['item_number'], 
            ));
        echo "Payment Done Successfully, We will update you soon!!!"; 
    }
    get_footer();
    ?>

Upvotes: 1

Related Questions