0

I am trying to create a wordpress plugin which hits an API and get redirects to the paypal link for transaction. I am using curl request for hitting the API I am able to redirect the user to the paypal link but now I want to know weather the payment is successful or not and then if we are getting the successful transaction then I will hit another API. My issue is that I don't know how to do that.

Here is my code till What I did:

$(document).on('click','#addautolikesbtn',function (e) {
    var package = $('#package').val();
    jQuery.post(
    ajaxlink.ajax_url,
    {
    'action': 'addorderautolike',
    'data':{
        'package':package
        }
    },
    function (response){
    var res = JSON.parse(response);
    if(res.status == 200){
    console.log(res.url);
    window.location.replace(res.url);
    }
    return true;
            }
        );
    });

add_action('wp_ajax_nopriv_addorderautolike', 'addorderautolike');
add_action('wp_ajax_addorderautolike', 'addorderautolike');
function addorderautolike(){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://********/recurringPayment?package_id='.$_POST['data']['package']);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $res = curl_exec($ch);
    echo $res;
    die();
}
Aman Kumar
  • 123
  • 8
  • you need to define add callback url in paypal form transaction.! – kuldip Makadiya Feb 01 '17 at 12:20
  • You can set up auto-return in your PayPal account, which will take customers to a receipt page. For example, use the following URL and replace example.com with your own URL:example.com/checkout/order-received/ check this URL from which you can debug further status code return from paypal. In which you can check payment is successful or cancel and so on.http://stackoverflow.com/questions/2433329/possible-payment-status-values – Ashish Patel Feb 01 '17 at 12:40

0 Answers0