Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

rfwoolf

Pioneers
  • Posts

    64
  • Joined

  • Last visited

Posts posted by rfwoolf

  1. I'm glad you came right - sorry I have been really busy these past few days.

    I'm glad I was of some help.

     

    What I still want to do is make it so that it sends paypal the 'INVNUM' (or the PAYMENTREQUEST_0_INVNUM in my version) so that the order number appears on the PayPal receipt. But as you know the transaction goes to PayPal during before_process, but the order on OsCommerce is only inserted AFTER that.

    So it would need to be rewritten that the order is inserted BEFORE, but with status 'Pending'.

    Then after_process the order is set to status 'Processing' or whatever.

     

    Good luck.

  2. The finall call to PayPal is in the function before_process in paypal_express.php

    I've got it working with the item names BUT I am using a newer version of the API than you -- I'm on 76 which you can set on this line:

    $this->api_version = '76.0';

    so some of the parameters have a slightly different name:

    So for example

    I use the parameter "PAYMENTREQUEST_0_AMT" but in your version it is probably "AMT"

    I use the parameter "PAYMENTREQUEST_0_CURRENCYCODE" but in your version it is probably "CURRENCYCODE"

    ... PAYMENTREQUEST_0_NOTETEXT ... your version is probably "NOTETEXT"

     

    Here's the API reference but be careful - this is for the latest version (76):

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment

     

    Don't forget to say thanks if this helps you!!!

    :D

     

       function before_process() {
         global $customer_id, $order, $sendto, $ppe_token, $ppe_payerid, $HTTP_POST_VARS, $comments, $response_array;
    
         if (empty($comments)) {
           if (isset($HTTP_POST_VARS['ppecomments']) && tep_not_null($HTTP_POST_VARS['ppecomments'])) {
             $comments = tep_db_prepare_input($HTTP_POST_VARS['ppecomments']);
    
             $order->info['comments'] = $comments;
           }
         }
    
         $params = array('TOKEN' => $ppe_token,
                         'PAYERID' => $ppe_payerid,
                         'PAYMENTREQUEST_0_AMT' => $this->format_raw($order->info['total']),
                         'PAYMENTREQUEST_0_CURRENCYCODE' => $order->info['currency'],
    	'PAYMENTREQUEST_0_NOTETEXT' => $order->info['comments'],
    	'SHIPPINGOPTIONNAME' => $order->info['shipping_method'],
    	'SHIPPINGOPTIONAMOUNT' =>  $this->format_raw($order->info['shipping_cost'])
    	);
    
         $line_item_no = 0;
         $items_total = 0;
         $tax_total = 0;
    
         foreach ($order->products as $product) {	  
           $params['L_PAYMENTREQUEST_0_NAME' . $line_item_no] = $product['name'];
    
    			//DESC
    			$params['L_PAYMENTREQUEST_' . '0' . '_' . 'DESC' . $line_item_no] = '';
    			for ($j=0, $o=sizeof($product['attributes']); $j<$o; $j++) {												
    		          $params['L_PAYMENTREQUEST_' . '0' . '_' . 'DESC' . $line_item_no] .= $product['attributes'][$j]['option'] . ':' . $product['attributes'][$j]['value'] . ', ';							
    
    			}			
    			//take off comma at end
    			$params['L_PAYMENTREQUEST_' . '0' . '_' . 'DESC' . $line_item_no] = substr($params['L_PAYMENTREQUEST_' . '0' . '_' . 'DESC' . $line_item_no],0,-2);
    
    			$params['L_PAYMENTREQUEST_0_AMT' . $line_item_no] = $this->format_raw($product['final_price']);
           $params['L_PAYMENTREQUEST_0_NUMBER' . $line_item_no] = $product['id'];
           $params['L_PAYMENTREQUEST_0_QTY' . $line_item_no] = $product['qty'];
    
           $product_tax = tep_calculate_tax($product['final_price'], $product['tax']);
    
           $params['L_PAYMENTREQUEST_0_TAXAMT' . $line_item_no] = $this->format_raw($product_tax);
           $tax_total += $this->format_raw($product_tax) * $product['qty'];
    
           $items_total += $this->format_raw($product['final_price']) * $product['qty'];
    
           $line_item_no++;
         }
    
         $params['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_raw($order->info['subtotal']);//$items_total;
         $params['PAYMENTREQUEST_0_SHIPPINGAMT'] = $this->format_raw($order->info['shipping_cost']);//$items_total;
    		$params['PAYMENTREQUEST_0_TAXAMT'] = $this->format_raw($order->info['tax']);							
    
         if (is_numeric($sendto) && ($sendto > 0)) {
           $params['PAYMENTREQUEST_0_SHIPTONAME'] = $order->delivery['firstname'] . ' ' . $order->delivery['lastname'];
           $params['PAYMENTREQUEST_0_SHIPTOSTREET'] = $order->delivery['street_address'];
           $params['PAYMENTREQUEST_0_SHIPTOCITY'] = $order->delivery['city'];
           $params['PAYMENTREQUEST_0_SHIPTOSTATE'] = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
           $params['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $order->delivery['country']['iso_code_2'];
           $params['PAYMENTREQUEST_0_SHIPTOZIP'] = $order->delivery['postcode'];
         }
    
    //debug email
    		tep_mail('Your name', '[email protected]', 'calling doExpressCheckoutPayment!', print_r($params, true) . '...' . print_r($order, true), 'from Name', '[email protected]');		
    
    		$response_array = $this->doExpressCheckoutPayment($params);
         if (($response_array['ACK'] != 'Success') && ($response_array['ACK'] != 'SuccessWithWarning')) {
    			tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . stripslashes($response_array['L_LONGMESSAGE0']), 'SSL'));
         }
       }
    

  3. Indeed it doesn't include the items in the final submission ("before_process" in includes/modules/payment/paypal_express.php) to PayPal.

    It includes the final amount and the final shipping address in case it's changed - but no line items.

    I think because the logic is you pass it the first time you talk to PayPal, and then when the user confirms on your site, it contacts PayPal again with just the token of the transaction and says "Do that transaction and this is the final amount and the shipping address".

     

    there is however, absolutely nothing wrong with providing the line items AGAIN and that's what I do.

    The line items will be provided in ext/modules/payment/paypal/express.php with these lines:

     

    foreach ($order->products as $product) {

    $params['L_NAME' . $line_item_no] = $product['name'];

    $params['L_AMT' . $line_item_no] = $paypal_express->format_raw($product['final_price']);

    $params['L_NUMBER' . $line_item_no] = $product['id'];

    $params['L_QTY' . $line_item_no] = $product['qty'];

     

    $product_tax = tep_calculate_tax($product['final_price'], $product['tax']);

     

    $params['L_TAXAMT' . $line_item_no] = $paypal_express->format_raw($product_tax);

    $tax_total += $paypal_express->format_raw($product_tax) * $product['qty'];

     

    $items_total += $paypal_express->format_raw($product['final_price']) * $product['qty'];

     

    $line_item_no++;

    }

     

    $params['ITEMAMT'] = $items_total;

    $params['TAXAMT'] = $tax_total;

     

    Put the above lines in includes/modules/payment/paypal_express.php in the before_process procedure, AFTER these lines:

     

    if (is_numeric($sendto) && ($sendto > 0)) {

    $params['SHIPTONAME'] = $order->delivery['firstname'] . ' ' . $order->delivery['lastname'];

    $params['SHIPTOSTREET'] = $order->delivery['street_address'];

    $params['SHIPTOCITY'] = $order->delivery['city'];

    $params['SHIPTOSTATE'] = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);

    $params['SHIPTOCOUNTRYCODE'] = $order->delivery['country']['iso_code_2'];

    $params['SHIPTOZIP'] = $order->delivery['postcode'];

    }

     

    but please note that this is untested and you should make backups and you may have to do some debugging.

  4. Thanks for the reply - but I don't believe you - just recently I hacked the crap out of paypal_express.php and as soon as PayPal sent back the customer's address I got OsCommerce to insert the order directly into the database, add a customer, generate a random 15-digit password, and add his default delivery address.

    If I enable IPN in my PayPal profile, in theory, after any eBay customer pays me, PayPal will send a POST transaction to my IPN url -- all I have to do is edit my IPN file in OscOmmerce and get it to do the same..

    ..I'm just REALLY surprised that nobody has done this before me?

    But what if you're right? Can you tell me about this 'OscID' requirement?

  5. I can't seem to find any information on this.

    Basically when someone buys one of our products on eBay, I want it to appear as an OsCommerce order in my Admin. That way, we can find all our orders "in one place". Right now we have to check our emails for eBay orders AND our Oscommerce admin.

     

    I'm sure that the PayPal IPN is the way to do this - in theory it should get called every time you get a payment from eBay (as long as it is enabled in the PayPal profile) - so are there any contribs for the IPN file to do this?

     

    Thanks

  6. Okay here's some help.

    Edit your file /ext/modules/payment/paypal/express.php

    Find this code:

        default:       if (MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_SERVER == 'Live') {         $paypal_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout';       } else {         $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout';       }        include(DIR_WS_CLASSES . 'order.php');       $order = new order;        $params = array(

     

    Basically everything in the $params code needs to comply with this API reference:

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout

    Unfortunately the one our version uses is an OLD deprecated version of the API...

    Thus you will probably have to do quite a bit of rewriting, but this should start:

    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

    $params['L_NAME' . $i] = $order->products[$i]['name'];

    $params['L_NUMBER' . $i] = $order->products[$i]['model'];

    //To put a description you use this param:

    // 'L_DESC' . $i' => 'Size: 8.8-oz',

    //But I like to put all my attributes in the description, like this:

    $params['L_DESC' . $i] = '';

    for ($j=0, $o=sizeof($order->products[$i]['attributes']); $j<$o; $j++) {

    $params['L_DESC' . $i] .= $order->products[$i]['attributes'][$j]['option'] . ':' . $order->products[$i]['attributes'][$j]['value'] . ', ';

    }

    $params['L_AMT' . $i] = $paypal_express->format_raw($order->products[$i]['final_price']);

    $params['L_QTY' . $i] = $order->products[$i]['qty'];

    };

     

    Of course you should properly look at that API reference I sent you and do it properly :) You can contact me for some help.

    If you do try and check against the API, note that SetExpressCheckout API is actually called in

    \includes\modules\payment\paypal_express.php

    which provides these paremeters for the SetExpressCheckout call:

    'USER' => MODULE_PAYMENT_PAYPAL_EXPRESS_API_USERNAME

    ,'PWD' => MODULE_PAYMENT_PAYPAL_EXPRESS_API_PASSWORD

    ,'VERSION' => '74.0'

    ,'SIGNATURE' => MODULE_PAYMENT_PAYPAL_EXPRESS_API_SIGNATURE

    ,'METHOD' => 'SetExpressCheckout'

    ,'RETURNURL' => tep_href_link('ext/modules/payment/paypal/express.php', 'osC_Action=retrieve', 'SSL', true, false)

    ,'CANCELURL' => tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL', true, false)

    ,'PAYMENTACTION' => ((MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_METHOD == 'Sale') ? 'Sale' : 'Authorization')

    In other words, don't put the above variables in /ext/modules/payment/paypal/express.php

  7. What is the actual PayPal payment module you are using? As you may know OsCommerce comes with 4 or 5 like PayPal Express, IPN, Payment Standard, then UK and US versions...

    Anyway, what I would do is find out which module is being called.

    Try and find the array that gets sent to PayPal and EMAIL it to yourself. Here's a command that will work on most pages:

     

    tep_mail('Your Name', '[email protected]', 'PayPal submission', print_r($params, true), 'Your website name', '[email protected]');

    Just replace $params with whatever variable it is using -- in my case it was $params but it might be $parameters or something else.

     

    If you get this right, it will email you the stuff it's sending PayPal.

    You might see an obvious error, but if not you'll need to check the API requirements for that particular API call - it may require a particular format.

    For example, in PayPal Express Checkout, it calls SetExpressCheckout and that API is documented here:

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout

     

    Good luck

  8. I was also very confused about this and spent hours researching and testing different modules.

    Part of the trouble is that I'm using OsCommerce 2.2a rc -- so in my mind, just because my 'express' addon isn't working properly doesn't mean that future versions aren't.

     

    But I did a lot of investigation and here's what I discovered...

     

    The PayPal Express module that's installed was based on the PayPal API version 3.x (we are now on version 76!!!) -- that was long ago, probably around 2008 when the PayPal API was pretty basic and useless -- there was probably no way to pass a customer to PayPal with shipping options - so the osCommerce developers probably just didn't make it do it. Instead merchants like ourselves were probably expected to set Shipping Settings inside their PayPal profiles.

    The version of PayPal express I was using was so bad, it didn't even list the shopping cart contents to PayPal -- PayPal only received the total amount!!!

     

    The good news is that we are now on version 76 and there's a lot more options:

    1. You can provide shipping options at the time of checkout -- the customer clicks "[Checkout with PayPal Express]" button and it will forward the cart items and the shipping option(s) to PayPal. If you provide more than 1 shipping option, the customer will get to choose!

    2. There is now a 'callback' / 'instant update' function which does this: After the customer is forwarded to PayPal, after they log in, it will forward their shipping address to YOUR 'callback server', which takes the address, calculates shipping options, SENDS the shipping options BACK to PayPal, which will then show the user the shipping options - that's a lot of work and I haven't written that yet...

     

    Unfortunately there's quite a bit of work to get that old version of PayPal express to do what we want.

    I have made it do option 1.

    You can email / pm me if you want some help. I'm on rfwoolf at

    g

    mail dot com.

     

    You can refer to some references files here:

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout

    and

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment

    1. Basically, when the user clicks on the "PayPal Express Checkout" button on your website,

    the website submits a 'SetExpressCheckout' command to PayPal which

    (in my standard version) just submitted the total amount to PayPal,

    but in my rewritten version, using the API link above, I have gotten it to submit all the shopping cart items and shipping options.

    2. The user signs in to PayPal and if I provided more than 1 shipping option they will get to choose it,

    3. they then return to the OsCommerce website to the 'Confirmation' page.

    If they confirm the payment, that's when...

    4. the website submits a 'DoExpressCheckoutPayment' command to PayPal for the 'final' amount.

     

    So, if you read this very carefully, you could hypothetically just provide shipping options when the user returns to your website (step 3). In other words in step 1 you pass the total amount EXCLUDING shipping - exactly like it is now!!! the customer will 'approve' this amount and return to your website for confirmation (step 3) -- that's when you're allowed to INCREASE the amount to include shipping.

    That can work perfectly for many people.

    OR

    In Step 1 you can pass through some shipping option(s). But this can be a problem if the customer has a special address in PayPal. What if you thought they were going to ship to say, London, but they log in and their PayPal address is China (for example)? That's why the first option is better -- or a 'callback' option.

     

    I hope some of this helps

  9. I'm a developer...

    Here's what I'm trying to do...

     

    1. The user has added $50 products to their cart.

    2. In the shopping cart I will have my PayPal Express Checkout button. User clicks...

    3. User logs into PayPal and confirms their Shipping Address

    4. User returns to my website (it currently takes them to the confirmation page).

    Could I then, in theory get them to choose their shipping method, EXAMPLE:

    Regular Shipping: $5

    Express Shipping: $10

    Now the order amount is $60!!

    Will PayPal process the transaction for $60, but the first time it was $50?

     

    Thanks :)

  10. Yes this would be possible by modding the files.

    There is an API call called GetExpressCheckoutDetails which is called after the customer has visited PayPal - it fetches all their details. Find out where that is being called in their code and modify it to NOT over-ride the details.

    I should warn you that some coding experience would be necessary - you'd also need to think about different scenarios:

    Scenario 1: Customer doesn't create an OsCommerce account, then uses PayPal Express, your site will need their details!

    Scenario 2: Customer has an Oscommerce account, uses PayPal Express, now you don't want their details?

  11. You don't mention what particular paypal payment module you are using.

    If it's Express then it is entirely possible, by modding the code and using the PayPal API, to pass the cart details to the order -- I tested this much and then something else troubled me.

    If it's PayPal IPN then it's supposed to pass on the cart details -- or at least I got it working.

  12. I think I'm using an earlier version than you because I don't get a "Test API Credientials" button - but by the looks of it you have no DEFINE set for HTTPS_SERVER -- I'm not exactly sure where it gets set, but you could look around because HTTP_SERVER would be set somewhere.

    Actually it looks a bit more broken than that -- yours has a whole section '/shop/admin/' preceeding the full URL -- that's just wrong.

    Must be some bad coding somewhere - did you install the module yourself - perhaps you made a typo.

    If there's a way for you to have all the website's current files on your computer somewhere, you could do a search through all the code (using a utility) for "shop/admin/ext/modules/payment/paypal/paypal_express.php" from that you'd have to find the file that generated that poor code and then you'd have to look at the code (or paste it here) and fix it.

     

    Good luck

  13. That's not exactly a correct answer, Chris. I can appreciate why everyone gets so frustrated - I'm now an experience developer and I am still frustrated by so many things...

    First of all, PayPal Express will do what Lovelock wants - and WPP should also do what you want if you manage to adapt the instructions to work with your osCommerce setup. In the WPP instructions you have to modify one of the shopping_cart.php where you add a 'PayPal Checkout' button after the normal 'checkout' button. Simply comment out the normal checkout button. The user will click to check out with PayPal:

    1. If they have a PayPal account they will sign in and confirm their shipping address or

    2. If they don't have a PayPal account they can create one or enter in their details

    THEN

    they get forwarded BACK to your website's payment confirmation page, which has now fetched all their PayPal shipping details.

    They press 'confirm' and the transaction is done!

     

    Some problems...

    The cart details might not get passed to the PayPal transaction.

    I managed to find a way to pass the cart contents by referring to the PayPal API. When they wrote the OsCommerce PayPal Express module they used PayPal API version 3.5 -- we are now on 70+!! So there is now so much more you can do than before.

    But what I can't figure out is how to do is this (step 4):

    1. Customer adds products to the shopping cart and click the "Checkout with PayPal" or "PayPal Express" button

    2. Customer logs in to their PayPal account and confirms their shipping address

    3. Customer is returned to website and OsCommerce has fetched their shipping address from PayPal

    4. Customer chooses a shipping method based on their postcode from PayPal

     

    One final comment...

    PayPal also has their own 'shopping cart' which works like this:

    You create 'buy' buttons or 'add to cart' buttons that work on any webpage.

    each 'button' is an HTML form kinda like this (example only):

    <html>

    ...

    <form action="https://www.paypal.com/blahblah">

    <input type="hidden" name="product-name" value="My Widget">

    <input type="hidden" name="product-price" value="99">

    <input type="hidden" name="product-qty" value="1">

    <input type="submit" value="http://www.paypal.com/buybutton.gif">

    </form>

    ...

    </html>

     

    You could use these 'forms' and hack your OsCommerce website so that instead of adding to the OsCommerce website, they add to your PayPal cart -- but please note there would be absolutely no other functionality like reducing your stock levels, creating customers in your database, emailing them from your website, marking orders as dispatched etc etc.. but it's an option if you just want to build your website in OsCommerce and use it to add products.

    </form>

  14. "The basic idea of the PayPal express module is to take the customers money and add it to your PayPal account"

    --That's not entirely true. I just ended up researching the PayPal API and you can do a whole host of stuff - you can pass through the cart details, shipping, tax, discount, insurance, etc etc

    But I could also use some help with this issue - I've spent another several hours playing with PayPal modules (this is in addition to the SEVERAL DAYS I spent previously and I'm still not happy :(

     

    People have their Shipping Address stored in PayPal.

    I want to use PayPal Express to retrieve the shipping address

    THEN

    the customer chooses shipping method based on postcode

    THEN

    the customer makes payment.

     

    But PayPal Express just passes the whole order amount to PayPal. They then get forwarded back to your website to complete payment -- but now you can't change the order details :(

  15. Avery>

    I had the same problem about the transaction 'not balancing' and what this means is that somewhere in this part:

    TRNS INVOICE 10/18/2001 Accounts Receivable Toni J (4) 21 N N T

    is the total amount of the transaction (I think it's 21)

    and that does not correspond to this part:

    SPL INVOICE 10/18/2001 Sales:Merchandise -21 Flag N -12 1.7500 24850 N

    SPL INVOICE 10/18/2001 Shipping Charge -4.5000 N -1 Shipping N

    SPL INVOICE 10/18/2001 Sales Tax Payable 0 N N AUTOSTAX

    As you can see 21 + 4.5 = 26.50

     

    In my case I was using the wrong tax Code. In Quickbooks I have 'GST' and in OsCommerce my sales tax is called 'GST', and then in my EZ Quickbooks settings (on Oscommerce) I set the tax setting to 'GST' and now all my orders are balancing.

     

     

    My problem: It's not creating invoices - it seems to be doing sales receipts or something :(

  16. I am posting a solution to a problem with the pins on the map - my map had no pins :S

    First make sure you have uploaded visitors_georss.php to your catalog directory.

    Then in admin/whos_online.php find the line:

    geoXml = new GGeoXml("<?php echo HTTP_CATALOG_SERVER . "/visitors_georss.php";?>");

    or

    geoXml = new GGeoXml("<?php echo HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "visitors_georss.php";?>");

     

    Basically the problem was with this line.

    I had both these lines but the first one was commented out -- but that was the correct line for me!

     

    You can take the php part in the line, e.g.

    <?php echo HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "visitors_georss.php";?>

    and paste it somewhere on your website to see the URL it generates, for example it may say:

    www.yoursite.com//visitors_georss.php

    or something else

  17. Have spent about an hour trying to research this...

     

    After a customer has paid using PayPal, they get an email from PayPal about their payment.

    But they don't receive an email from the store unless they return to the site.

    The problem is, customers are only returned to your website automatically if they have a PayPal account,

    so if you make PayPal Accounts optional in your PayPal profile, the customer will *not* automatically return to your website and will *not* receive an email from your store.

     

    The solution to this is PayPal's IPN (Instant Payment Notification), but the current IPN file, standard_ipn.php does not send an email :(

     

    Any solution for this?

     

    PS> I am using 2.2rc2

×
×
  • Create New...