简体   繁体   中英

Custom Parameter for paypal direct payment rest API

I am using paypal REST API for making direct payments. I want to create internal transaction id before initiating the transaction and use that for identifying the transactions from my end.

I am trying to set id using

 $payment = new Payment();
 $payment->setId($tId);

Paypal is approving the request and payment is getting done but I am not getting this id in response.

Is there any way by which I can send custom parameters to paypal and get them back in response?

You can use custom variable to pass your custom data, and paypal will return it backto you in post in response.

<input type="hidden" name="amount" value="<?php echo $totalAmount; ?>"/>
<input type="hidden" name="business" value="your_paypal_biz_id"/>
<input type="hidden" name="notify_url" value="<?php echo site_url(); ?>/zad_notify.php"/>
<input type="hidden" name="item_name" value="Image editing"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="return" value="<?php echo $paypalReturnUrl; ?>"/>
<input type="hidden" name="cancel_return" value="<?php echo site_url(); ?>/payment_error.php?id=<?php echo $sr_no; ?>"/>
<input type="hidden" name="custom" value="<?php echo $sr_no; ?>" />

alternatively you can also pass your id in notify url as query string parameter and you will get it back in return url file.

 <input type="hidden" name="amount" value="<?php echo $totalAmount; ?>"/>
    <input type="hidden" name="business" value="your_paypal_biz_id"/>
<input type="hidden" name="notify_url" value="<?php echo site_url(); ?>/zad_notify.php?id=5"/>
    <input type="hidden" name="item_name" value="Image editing"/>
    <input type="hidden" name="currency_code" value="USD"/>
    <input type="hidden" name="return" value="<?php echo $paypalReturnUrl; ?>"/>
    <input type="hidden" name="cancel_return" value="<?php echo site_url(); ?>/payment_error.php?id=<?php echo $sr_no; ?>"/>

Hope this help to you, :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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