I have a follow-up on this thread.
I’m trying to understand conceptually how the PayPal communication takes place and how / when the onCPayAfterPaymentStatusUpdateEvent event gets triggered, as I’m getting some odd results under certain situations.
My situation: I have implemented this Auto Action Trigger on three different websites…one is a non-public website behind on my local network, the other two are public sites use for testing. The auto action is relatively simple (summary code included below), where the php code is triggered onCPayAfterPaymentStatusUpdateEvent. The code looks for “Completed” PayPal transactions and then looks for a specific plan ID (the ID of my donation plan), and then gets the donation amount and writes that to cloud storage.
When testing this on all three systems (all in different tabs of the same browser) I received odd results in that it would work on one site at one moment, but then not a bit later. Just very inconsistent. Also, up until today, I was able to get this to work on the non-public website as well, but today I’m receiving an “incorrect PayPal address” error from PayPal on this site.
Questions:
How does the communication flow between the website and PayPal? I’ve set the IPN and PDT (Payment Data Transfer) correctly back at PayPal, but I noticed that the URLs set within PayPal don’t seem to matter in the communication flow or return of payment data with CBSubs.
In addition, with the first site not being public, how does the PayPal information get received by this website? Should the PayPal transaction even work correctly with a non-public site? I don’t fully understand how it worked in the past and returned correctly to my private website from PayPal.
When exactly does the onCPayAfterPaymentStatusUpdateEvent get triggered…when the customer returns to my site from PayPal in their browser?
How does the browser session factor into this functionality? I seem to get inconsistent results if I run transactions on my websites from different tabs within the same browser, and seemingly consistent results if I run transactions on my sites from completely different browsers (Chrome, Firefox, etc.)
Thanks,
Jim
======
Code:
$TransactionStatus = "[var4]";
//Process the basket items only if the transaction status is "Complete"
if ($TransactionStatus == "Completed") {
$paymentBasket = $vars['var2'];
$paymentItems = $paymentBasket->loadPaymentItems();
//Loop through all the payment items.
foreach ( $paymentItems as $item ) {
$itemPlanID = $item->plan_id;
//Process only the $specificplanid
$specificplanid = 3;
if ($itemPlanID == $specificplanid) {
// Get the subscription amount, i.e. the amount of the donation.
$subscription = $item->loadSubscription();
$DonationAmount = $subscription->amount;
< my code to write donation amount to cloud storage >
}
}
}