Jump to content
Sign in to follow this  
devosc

[Contribution]Paypal IPN - Devosc

Recommended Posts

Have a look in includes/modules/payment/paypal.php

 

The line that inserts the info regarding the image is:

if(tep_not_null(MODULE_PAYMENT_PAYPAL_STORE_LOGO)) $paypal_fields .= tep_draw_hidden_field('image_url', tep_href_link(DIR_WS_IMAGES.MODULE_PAYMENT_PAYPAL_STORE_LOGO, '', 'SSL'));

From the above the image_url is only declared if the value of the defined paypal_store_logo is not null.

 

For the previous reference to paypal/processing.tpl.php page you don't have to remove the image since it is on your site. it's only the code above in payment/paypal.php thats causing the problem.

Edited by gregbaboolal

"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites
Okay.. Now I just noticed I also have the following problems... Lets see how well I can clean this up...

 

BRIEF SUMMARY:

-------------

IPN Date Payment Status Pending Reason

No IPN history available

 

 

Products Model Tax Price (ex) Price (inc) Total (ex) Total (inc)

1 x Microsoft IntelliMouse Pro MSIMPRO 0% $39.99 $39.99 $39.99 $39.99

1 x There's Something About Mary DVD-TSAB 0% $49.99 $49.99 $49.99 $49.99

Sub-Total: $89.98

United Parcel Service (1 x 14lbs) (Ground): $6.62

Handling Fee: $8.95

Total: $105.55

Date Added Customer Notified Status Comments

06/15/2004 20:54:08 Pending

 

Comments

Status:

Notify Customer: Append Comments:

 

 

 

 

If anyone can help out it would be greatfully appreciated!

I guess I just needed to do a transaction all the way through! I followed the instructions on the "test" IPN page, and everytime I did it, it wasn't working correctly for some reason!

 

I finally just said to hell with it, and did a complete order, and it worked fine! It filled all the information out correctly, etc.

 

Just curious about something, that I know the answer is probably no anywayz! Is there a way to get OSC to coordinate it's invoice number from PayPal? Not Paypal coordinating with OSC? (ie: order number 400 in osc has paypal order with 17 digitis. Anyway to pass those 17 digits as the order number for osc to store?)

 

Thanx for all the prompt response in getting this fixed! Works GREAT!

Share this post


Link to post
Share on other sites

I FOUND IT! Everyone that was having trouble with your subtotal getting correctly updated with CCGV, here is the fix:

 

catalog/includes/modules/order_total/ot_subtotal.php

 

FIND:

function process() {
     global $order, $currencies;

     $this->output[] = array('title' => $this->title . ':',
                             'text' => $currencies->format($order->info['subtotal'], true, $order->info['currency'], $order->info['currency_value']),
                             'value' => $order->info['subtotal']);
   }

 

REPLACE WITH:

    function process() {
     global $order, $currencies;

  $od_amount = $_SESSION['od_amount'];
     $subtotal = $order->info['subtotal'] - $od_amount;
     $order->info['subtotal'] = $order->info['subtotal'] - $od_amount;

     $this->output[] = array('title' => $this->title . ':',
                             'text' => $currencies->format($order->info['subtotal'], true, $order->info['currency'], $order->info['currency_value']),
                             'value' => $order->info['subtotal']);
   }

 

And that is all....

 

I think I got that from the CCGV thread a while ago, but I can't find it right now.

 

Lemme know...

 

Noel


9 times out of 10 its a PEBCAK Error (Problem exists between chair and keyboard)

 

Replace that and you're fine...

Share this post


Link to post
Share on other sites

Hi Noel,

Many Thanks for that, I'm sure it will be greatly appreciated, or rather, it is!

 

rmblfish, Sysop

Incorrect Total

PayPal: 0.01

Session: $12.01

 

does this mean it has got the wrong total and why?

I suspect your problems with the IPN Test Panel where similiar, from the above you can see that the amount (mc_gross) sent via the IPN Test Panel is not equal to the osC order total amount (Session above). When you have the 'Cart Test' feature on this will disallow the transaction, since in reality it could be possible for someone to post an order directly to PayPal with in correct payment amounts for that order. So even if the IPN is VALID, does not neccessarily mean that the actual detail$ of the payment are as what is expected, hence the Cart Test compares these 2 totals for further validity.

Edited by gregbaboolal

"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

:D ok thanx greg! think i got a little bit further to the goal...

what is supposed to happen then?

i mean i got the 3 emails and the customer got one about the orderdetails..

does he get another email with an downloadlink or what? :unsure:

i forgot to uncheck the test mode when we was ordering is that the problem?

 

oops and the "Cart Test

Off" should be unchecked when shooting sharp right?

Edited by rmblfish

Share this post


Link to post
Share on other sites

Thanks for the GREAT module, Mr. B.! I just got on the air (www.visibone.com/catalog). Three real sales so far...

 

About the problem with missing customer name in the order confirmation email, I just implemented your solution for v2.3 ( http://forums.oscommerce.com/index.php?sho...ndpost&p=373293 ) thanks for that.

 

Before I made that change the problem was intermittent -- 3 order notification had first & last names 2 did not. I ALSO noticed that when it did not have the names it also had a missing order id in the link. I was working on the theory that what made the difference was whether there was a retry on the IPN transaction id, you know that test in catalog/ipn.php:

if ($ipn->unique_txn_id()) {

Just a wild guess. Will see soon if the problem recurs...

 

-- Bob Stein, VisiBone

Share this post


Link to post
Share on other sites

i was looking to update the price of the product to deduct the amount that was paid by paypal from the products price. i know it is kind of crazy but i need to do this.

the question is which file i have to change

Share this post


Link to post
Share on other sites

Mod looks sweet Greg, great work. I'm about to embark on the install and was wondering if i should hold out for v2.4? Noticed a lot of little fixes since then so thought I'd ask before installing 2.3 and making the changes by referencing the thread.

Share this post


Link to post
Share on other sites

Click here, in regard to CCGV only the preliminary change has been made, the others seem to be more specific which I haven't firgured out to test for yet, some important notes are there for thos who have been using v2.3 (see comments about upgrading), this is a quick update and only briefly tested.

 

To revise the image used during the checkout process when not specfiying an image via the admin (no SSL), then look at paypal/processing.tpl.php for 'oscommerce.gif'.

 

Have changed the debug settings to just on/off.

 

Made the email receiver and business id test case insensitive.

 

Will need to unistall the module via the the admin->modules->payment section, copy over the files in the contrib catalog directory and then reinstall.

 

Two revisions where made in the install docs, see the comments about upgrading.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

I'm a bit confused about the "Enable PayPal Shipping Address" option in the admin panel. According to the PayPal_Shopping_Cart_IPN documentation, this should be set to "No" if you require a PayPal verified shipping address.

 

I set it to no, but the orders are coming through with no shipping address, which makes the order ineligible for PayPal's Seller Protection Policy. Am I doing something wrong, or could I have made an error when modifying the code?

 

I had this problem with version 2.3, and I am still having the problem with 2.4. Any suggestions would be appreciated. Thanks.

 

Peter

Share this post


Link to post
Share on other sites

If I can recall, via your PayPal profile account configure it so that you only receive payments from verified addresses (or do not immediately accept payments), then have in osC->admin->modules->payment->paypal set the shipping option to no.

 

The reasoning for the latter is so that when the customer is prompted to select an address from the PayPal drop down selection list, another option is available on that page so that the customer can choose not to select a shipping address, thus they can proceed with the PayPal payment without choosing an address at all. So the latter osC config setting either enables or disables this option from appearing.

 

So the best way is to proceed with a real test payment and see what shipping options are prompted to the customer.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

thanx Greg! got i little bit further to the goal...

but after i got the 3emails (after a customer has ordered)

what is supposed to happen then?

i mean i got the 3 emails and the customer got one about the orderdetails..

does he get another email with an downloadlink or what?

i forgot to uncheck the test mode when we was ordering is that the problem?

 

oops and the "Cart Test

Off" should be unchecked when shooting sharp right, or?

Share this post


Link to post
Share on other sites

The customer order confirmation email doesn't provide a download link by (osCommerce) default. Normally the customer would be provided the link(s) when they return to checkout_success.php, but should the IPN have not been received and processed within this short period of time, then no link would appear, they would then have to click the 'My Account' link and view the transaction history for that particular transaction which will also provide the dowload links.

You could add some additional text to the email to more clearly explain this, these types of orders are 'virtual' orders and a link to that transaction's history is already provided.

 

When in live mode you should have the cart test 'ON', see this post for a brief reasoning of its usage.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Discovered a couple of things in the first 25 orders thought I'd pass along.

 

About the situation where the order status is stuck in "Pending PayPal Notification" limbo, this has happened about three times so far. (In one case a guy had to update the credit card expiration in his PayPal account and in the process lost track of the payment he was trying to send me.) I have a tiny improvement to this annoying situation. If they log back on and check their order status they see:

 

OrderPaymentLimbo.gif

 

Usually the solution is then to send them a PayPal Money Request. This gets them to the same screen where they can pay as non-PayPal members, where PayPal shows them:

 

PayPal-no-account-Click-Here.gif

 

I'm also emailing anyone who signs up but doesn't place an order. I've had about five of these so far and every one has been someone who wanted to buy but ran into trouble.

 

Which leads to an even more important suggestion: show credit card icons! Many people said they wanted to pay by credit card but couldn't! So I changed the Payment Method choice to look like this:

 

creditcardlogos2.gif

 

Anyone know of any rules broken by this? I could not find anywhere that PayPal disallows the use of their icons in this way (as CCNow did).

Share this post


Link to post
Share on other sites

Hi Bob, no you are freely allowed to use PayPal payment icons.

In regard to the 'Pending PayPal Notification' issue and above, during the checkout should the customer click back from the PayPal site they can still resume that checkout sequence (updating the order if neccessary) so they should not be subject to being charged twice in this regard.

Your above image motivated me to have a look at providing a resume button for transactions that are logged as 'Pending PayPal Notification', there is a slight risk in providing such a functionality since if the customer has paid but the payment is either PayPal.Pending or the IPN has not yet been received (could be up to 4 days), then in these instances it could be possible for the customer to go through and pay a second time, actually if you sychronized your invoice order numbers with PayPal then it would not be allowed.

 

The following will highlight the changes to be made to trivially provide a resume order checkout feature which will post the customer directly to the PayPal website with the exact same information as they previously had, this is similiar to creating a 'PayPal Money Request', and the changes below are preliminary just for 'Aggregate' Carts, e.g. shipping cost and total cost, how CCGV comes into play has not been identified yet.

 

[1] catalog/includes/classes/order.php (around line 44)

$order_total_query = tep_db_query("select text , value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'");

$order_total = tep_db_fetch_array($order_total_query);

 

[2] catalog/includes/classes/order.php (around line 47)

$shipping_method_query = tep_db_query("select title , value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'");

$shipping_method = tep_db_fetch_array($shipping_method_query);

 

[3] catalog/includes/classes/order.php (around line 60)

'date_purchased' => $order['date_purchased'],

'orders_status_id' => $order['orders_status'],

'shipping_cost' => $shipping_method['value'],

'total_value' => $order_total['value'],

'orders_status' => $order_status['orders_status_name'],

'last_modified' => $order['last_modified'],

 

[4] catalog/includes/modules/payment/paypal.php (around line 159)

function _getPayPalFields($currency = '', $orders_id = '') {

 

[5] catalog/includes/modules/payment/paypal.php (around line 161)

Change:

$my_currency = $this->currency();

To:

$my_currency = (tep_not_null($currency)) ? $currency : $this->currency();

 

[6] catalog/includes/modules/payment/paypal.php (around line 188)

Change:

$paypal_fields .= tep_draw_hidden_field('rm', MODULE_PAYMENT_PAYPAL_RM) .
tep_draw_hidden_field('custom', $paypal_order_id) .

To:

$paypal_fields .= tep_draw_hidden_field('rm', MODULE_PAYMENT_PAYPAL_RM);
$custom = (tep_not_null($orders_id)) ? $orders_id : $paypal_order_id;
$paypal_fields .= tep_draw_hidden_field('custom', $custom) .

 

[7] catalog/account_history_info.php (around line 238)

Change:

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

To:

                <td><div style="float:left"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></div>
<?php if(strtolower($order->info['payment_method']) == 'paypal' && $order->info['orders_status_id'] == MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID ) { ?>
<?php
include_once(DIR_WS_MODULES . 'payment/paypal/database_tables.php');
include_once(DIR_WS_MODULES . 'payment/paypal.php');
$paypal = new paypal();
$paypal_button = $paypal->_getPayPalFields();
?>
<div style="float:right">
<?php
$form_action_url = 'https://www.paypal.com/cgi-bin/webscr';
echo tep_draw_form('checkout', $form_action_url, 'post');
$orders_session_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname from " . TABLE_ORDERS_SESSION_INFO . " osi left join " . TABLE_ADDRESS_BOOK . " ab on osi.billto = ab.address_book_id where osi.orders_id ='" . (int)$HTTP_GET_VARS['order_id'] . "'");
$orders_session_info = tep_db_fetch_array($orders_session_query);
$order->customer['firstname'] = $orders_session_info['firstname'];
$order->customer['lastname'] = $orders_session_info['lastname'];
$order->info['total'] = $order->info['total_value'];
echo $paypal->_getPayPalFields($order->info['currency'],$HTTP_GET_VARS['order_id'])."\n";
echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";
?>
</div>
<?php } ?>
               </td>

Remember that in order for PayPal to be able to prevent the customer from checking out with the same order number, then invoice synchronization must be enabled via osC->admin->modules->payment->paypal. And if you ever end up reseting your osC orders table you will have to reset/update the orders table auto-increment value to be higher than any previous PayPal order.

 

The above has only been quickly implemented, and I haven't tested the whole sites functionality, but pretty confident that it will do the job intended based upon the above changes (hopefully I captured them all), anyway it can be can worked on.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

ok thanx greg.

i have changed CART TEST to on now.

could that have been the reason why no download for customer was there when looking in "my account"/orders.. ?

.

even read that you said

the IPN has not yet been received (could be up to 4 days),
.

Didnt know it could take so long time, i suppose the only way to found out now is to change nothing in admin and just wait 4days to see if download works then?

 

 

and thats why one should put

"Expiry delay (days) " to 5 right ?

 

what about "Maximum number of downloads" ?

why should one set that to something bigger then 1?

 

 

regards

Share this post


Link to post
Share on other sites
i have changed CART TEST to on now.

could that have been the reason why no download for customer was there when looking in "my account"/orders.. ?

No, if aything it would of allowed it, did you receive an official paypal receipt for that transaction payment? Also it is not impossible that when the IPN was sent that PayPal then did not verify it as a valid payment, this could be due to soemthing like a network error or a problem their end. Are you able to find the debug email for that transaction? what about your server logs for around that time?

 

It might now seem that even INVALID IPNs be stored so that they can be revalidated, or maybe the IPN should be automatically retried before immediately disregarding it, the reasoning behind not storing invliad IPNs is because anyone could flood your site with spoof IPNs.

 

and thats why one should put

"Expiry delay (days) " to 5 right ?

Could do, at some stage it would be nice to have a glossary or something for the customer to see in regard to PayPal transactions (maybe even for the store owner too).

 

what about "Maximum number of downloads" ?

why should one set that to something bigger then 1?

It would seem that this setting is in regard to how many times a file can be dowloaded, e.g. you only allow them to come back and download say 5 times, rather than for example 1000.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites
QUOTE 

i have changed CART TEST to on now.

could that have been the reason why no download for customer was there when looking in "my account"/orders.. ?

 

 

No, if aything it would of allowed it, did you receive an official paypal receipt for that transaction payment? Also it is not impossible that when the IPN was sent that PayPal then did not verify it as a valid payment, this could be due to soemthing like a network error or a problem their end. Are you able to find the debug email for that transaction? what about your server logs for around that time?

 

got all 3 emails, and customer got one email.

seems ok.

 

It might now seem that even INVALID IPNs be stored so that they can be revalidated, or maybe the IPN should be automatically retried before immediately disregarding it, the reasoning behind not storing invliad IPNs is because anyone could flood your site with spoof IPNs.

 

 

QUOTE 

and thats why one should put

"Expiry delay (days) " to 5 right ?

 

 

Could do, at some stage it would be nice to have a glossary or something for the customer to see in regard to PayPal transactions (maybe even for the store owner too).

 

yes i must write some instruktions down on homepage for customers and even tell about the download time could take up to 4days!

 

QUOTE 

what about "Maximum number of downloads" ?

why should one set that to something bigger then 1?

 

 

It would seem that this setting is in regard to how many times a file can be dowloaded, e.g. you only allow them to come back and download say 5 times, rather than for example 1000.

 

 

hmm dont understand, give example of when customer needs to download an ebook more then one time.

 

regards

Share this post


Link to post
Share on other sites

ah, little more awake now, if your customer got the order confirmation for that email but you are saying that the download links do not appear then it sounds like that you don't have either the downloads configured correctly or you have not configured that product's download attribute properly, see the kb for more information.

Also, what version of osCommerce are you using and or do you have the Downloads Controller contribution installed?


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Hello all. I'm having an issue setting something up using the Paypal Shopping Cart IPN. It has installed great and seems to work wonderfully. However, I'm trying to add on a feature to it but I can't quite figure out how to do so. What I want to do is use this payment module to send an email to the customer after payment has been confirmed through IPN. I can't figure out which file this should be done through though. I need to have the full order information (ie. product, quantity, etc.) to be able to include in it. Very similar to the order invoice, but it can only be sent after I've received payment through Paypal and confirmed through IPN. I'm a total newbie when it comes to OSCommerce, so I'm not quite sure where to begin for this. Anybody have an idea on how I could do this?

Share this post


Link to post
Share on other sites

Hi Ben, are you sure you're using this contribution, by defualt the customer order confirmation is not sent untill a 'Completed' IPN has been received which occurs in paypal/checkout_update.php.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Yes, I am using this contribution. However, what I want is a seperate email to be sent. Basically, what they are purchasing is an activation code. Once the payment is confirmed, I want to send them the activation code in an email. I have the coding done for the actual email and stuff. I just don't know where to add it so that it is sent at the same time as the invoice. Where I have it now is in the checkout_process.php file. If I ordered through say, Cash on Delivery, it would be sent at the same time as the invoice. However, when I order it through this module, it doesn't get sent.

Share this post


Link to post
Share on other sites

oh ok, what you could do is put that section that deals with the email into a file called email order_confirmation.inc.php and put in the catalog/includes/modules/directory.

Then include it in the relevant sections in both catalog/checkout_process.php and catalog/includes/modules/payment/paypal/checkout_update.php, for the latter it should be familiar to you as it is exactly the same as the script occuring in catalog/checkout_process.php with 2 exceptions, $insert_id == $orders_id and [ii] $order->customer['customer_name'] == ($order->customer['firstname'] . ' ' . $order->customer['lastname'] ), so a little work around for these two cases would be required.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×