Add Commission History Table

Add Commission History Table
Hello,

First, here is an overview of my system. Whenever a member
purchases points and the payment status is “instant” or
the E-check status comes back as “Completed”, the points
are added to the member’s account, the commission is added
his referrer’s account and an email is sent to the
referrer.

Sometimes PayPal’s IPN fails. When this happens, the
url_package_fee table is not updated, the points are not
updated to the member’s account, the referrer’s
commissions are not updated to his account and the email is
not sent to the referrer.

When the PayPal’s IPN fails, I search the url_package_fee
table (this is where the details of the purchases are
updated) to see if the transaction was updated there.
Sometimes the info is there and sometimes it’s not. So it
would be hard for me to tell if the referrer’s commissions
were updated to his account when the PayPal’s IPN fails.

So in order to help me to determine if the referrer’s
commissions where updated to his account when the IPN fails,
please do the following:

Note: Attached is my PayPal IPN file (notify.php) so you can
see the exact code. The only thing you will need to do is
create the commission history table and in the notify.php
file, have the script update this table whenever the payment
status is “Instant” or when the E-check status comes back
as “Completed”.

Below is what needs to be done:

1) Create a Commission History table and name it
“url_commission_history”

In this table put the following variables: (Note: Most of
these variables can be found in the url_package_fee table).

– $user_id (This would be the referrer’s user id which is
the person who is receiving the commissions)

– The commission amount (This is the amount the referrer
received as commission from the purchase). This variable is
already in the notify.php file.

– $package_name

– $buy_date

– $payment_type

– $trans_id

– $user_id (This would be the user id of the referral which
is the member who made the purchase)

– When the transaction status comes back as “Instant” or
the E-check status comes back as “Completed”, the
url_package_fee table is updated, the points are updated to
the member’s account who just made the purchase, the
commissions are updated to the referrer’s account and the
referrer is sent the email. Now right after the email is
sent to the referrer, the last thing the IPN should do is
update the “url_commission_history” table.

Now let’s say that the IPN fails. (Note: Sometimes there is
a partial failure meaning the url_package_fee table is
updated Only and sometimes there is a full IPN failure
meaning the url_package_fee table, the points and the
commissions are not updated and the email is not sent to the
referrer). I always know if there is some kind of IPN
failure, because the points are never updated to the
member’s account.

So when there is one of these failures, I should be able to
go to the “url_commission_history” table to see if it was
updated, since this table is updated last in the IPN
process. Now if the transaction is not in the
“url_commission_history table, I can assume that the
commissions were not updated and that the email was not sent
to the referrer.

The goal here is to be able to accurately determine if the
commissions were added to the referrer’s account whenever
there is a partial or full IPN failure. Let me know what you
think is the best way to logically solve this problem.

– Whenever I delete a member from the admin panel, the
script should check the “url_commission_history” table and
delete all records in this table pertaining to that member.
(I delete member’s account from the admin panel, by click
on the “User Management” link, clicking on the email
address of that member and then clicking on the “Delete”
button underneath his account details).

******* NOTE: The commission history table should only be
updated when the payment status is “Instant” or the
E-check status comes back as “Completed”.

2) Commissions Not Added When E-check is completed. The
following problem only exists when an E-check comes back as
“Completed”. When a payment status is “Instant”, every
thing is working fine.

User ID# 4194 E-check was completed. The points were added
to his account which is correct. But here are the problems:

– The commissions were not added to his referrer’s account
User ID# 4193

– And User ID# 4193 did not receive the referrer’s
commission notification email.

The code is already there, you will just need to figure out
why the commission is not being added to the referrer’s
account and why the email is not being sent to him when an
E-check comes back as “Completed”.

3) Url’s not hyperlinked when I send a Plain Text email to
ALL members.

Whenever I send a Plain Text email to all member’s, the
url’s in that email are never hyperlinked. The url’s
should be hyperlinked. You can log into my admin control
panel and click on the “E-mail Members” links to check
this.

Thanks,

Mike

Leave a Reply

Your email address will not be published.