Users - PayPal

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Users - PayPal

Hao Jiang-4
Hi, does anyone setup PayPal successfully?

I followed the instruction that worked on
accounting/config/payment.properties, when connect to PayPal I got an
error page

We cannot process this transaction because there is a problem with the
PayPal email address supplied by the seller. Please contact the seller
to resolve the problem. If this payment is for an eBay listing, you can
contact the seller via the "Ask Seller a Question" link on the listing
page. When you have the correct email address, payment can be made at
www.paypal.com.


the URL is:

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=bizdev%">https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=bizdev%
40userful.com&amp;item_name=Order+%23WS10220+from
+Userful&amp;item_number=0&amp;invoice=WS10220&amp;custom=hao&amp;amount=198.00&amp;return=http%3A%2F%2Fstore.userful.com%2Fcontrol%2Forderhistory&amp;cancel_return=http%3A%2F%2Fstore.userful.com%2Fcontrol%2FpayPalCancel%2Fmain&amp;notify_url=http%3A%2F%2Fstore.userful.com%2Fcontrol%2FpayPalNotify&amp;image_url=http%3A%2F%2Fstore.userful.com%2Fimages%2Flogo-color.jpg&amp;no_note=1&amp;no_shipping=1

FYI, my paypal email is [hidden email], and my store address is
http://store.userful.com  (no /ecommerce)

I don't know whether something wrong on my store setting, or on paypal
account.

Can someone help me?

Thanks

HAo


 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
hey, i am too getting the same error. the business email ID is shown bizdev%40userful.com in the paypal URL, which paypal does not accept. someone please help. i am using opentaps-0.9.0.

rohit
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

Hao Jiang-4
Hi, I've fixed it. The problem is not the email address format, which
bizdev%40userful.com is OK, but look at the URL string, it uses "&amp;"
instead of "&", that's not acceptable.

Looking at the class
ofbiz/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java

at line 162,
String encodedParameters = UtilHttp.urlEncodeArgs(parameters);

then look at UtilHttp class, this will eventually call
urlEncodeArgs(parameters, true), then return "&amp;", not "&"

so the easiest way to fix it is modify the line 162 code to
String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false);

Hao



On Mon, 2006-05-15 at 04:52 -0700, rohit2006 wrote:

> hey, i am too getting the same error. the business email ID is shown
> bizdev%40userful.com in the paypal URL, which paypal does not accept.
> someone please help. i am using opentaps-0.9.0.
>
> rohit
> --
> View this message in context: http://www.nabble.com/Users---PayPal-t940082.html#a4390637
> Sent from the OFBiz - User forum at Nabble.com.
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
>


 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

Andrew Zeneski
Done.

On May 15, 2006, at 1:06 PM, Hao Jiang wrote:

> Hi, I've fixed it. The problem is not the email address format, which
> bizdev%40userful.com is OK, but look at the URL string, it uses  
> "&amp;"
> instead of "&", that's not acceptable.
>
> Looking at the class
> ofbiz/applications/accounting/src/org/ofbiz/accounting/thirdparty/
> paypal/PayPalEvents.java
>
> at line 162,
> String encodedParameters = UtilHttp.urlEncodeArgs(parameters);
>
> then look at UtilHttp class, this will eventually call
> urlEncodeArgs(parameters, true), then return "&amp;", not "&"
>
> so the easiest way to fix it is modify the line 162 code to
> String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false);
>
> Hao
>
>
>
> On Mon, 2006-05-15 at 04:52 -0700, rohit2006 wrote:
>> hey, i am too getting the same error. the business email ID is shown
>> bizdev%40userful.com in the paypal URL, which paypal does not accept.
>> someone please help. i am using opentaps-0.9.0.
>>
>> rohit
>> --
>> View this message in context: http://www.nabble.com/Users---PayPal- 
>> t940082.html#a4390637
>> Sent from the OFBiz - User forum at Nabble.com.
>>
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/users
>>
>
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
In reply to this post by Hao Jiang-4
hi,

thanks for the reply. i have just edited the file as mentioned by you and restarted the ofbiz server, but no help. the URL still includes the '&'. i am not sure what to do next, do i have to do a 'ant' command or something else for the changes to take effect. For your reference i am pasting a copy of the file here.

paypalEvets.java

__________________________________________________________________________________

/*
 * $Id: PayPalEvents.java 6642 2006-02-01 02:29:51Z sichen $
 *
 * Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
package org.ofbiz.accounting.thirdparty.paypal;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.transaction.GenericTransactionException;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.order.order.OrderChangeHelper;
import org.ofbiz.product.catalog.CatalogWorker;
import org.ofbiz.product.store.ProductStoreWorker;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelService;
import org.ofbiz.service.LocalDispatcher;

import org.apache.commons.collections.map.LinkedMap;

/**
 * PayPal Events
 *
 * @author     Andy Zeneski
 * @version    $Rev: 6642 $
 * @since      2.0
 */
public class PayPalEvents {
   
    public static final String module = PayPalEvents.class.getName();
   
    /** Initiate PayPal Request */
    public static String callPayPal(HttpServletRequest request, HttpServletResponse response) {
        ServletContext application = ((ServletContext) request.getAttribute("servletContext"));
        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
               
        // get the orderId
        String orderId = (String) request.getAttribute("orderId");
       
        // get the order header
        GenericValue orderHeader = null;
        try {
            orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
        } catch (GenericEntityException e) {
            Debug.logError(e, "Cannot get the order header for order: " + orderId, module);
            request.setAttribute("_ERROR_MESSAGE_", "Problems getting order header.");
            return "error";
        }
       
        // get the order total
        String orderTotal = UtilFormatOut.formatPrice(orderHeader.getDouble("grandTotal"));
           
        // get the webSiteId
        String webSiteId = CatalogWorker.getWebSiteId(request);
       
        // get the product store
        GenericValue productStore = ProductStoreWorker.getProductStore(request);

        if (productStore == null) {
            Debug.logError("ProductStore is null", module);
            request.setAttribute("_ERROR_MESSAGE_", "Problems getting merchant configuration, please contact customer service.");
            return "error";
        }
       
        // get the payment properties file      
        GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_PAYPAL", null, true);
        String configString = null;
        if (paymentConfig != null) {
            configString = paymentConfig.getString("paymentPropertiesPath");    
        }
               
        if (configString == null) {
            configString = "payment.properties";
        }
                       
        // get the company name
        String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), "");
       
        // create the item name
        String itemName = "Order #" + orderId + (company != null ? " from " + company : "");
        String itemNumber = "0";
       
        // get the redirect url
        String redirectUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.redirect");
       
        // get the notify url
        String notifyUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.notify");
       
        // get the return urls
        String returnUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.return");
        String cancelReturnUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.cancelReturn");
       
        // get the image url
        String imageUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.image");        
       
        // get the paypal account
        String payPalAccount = UtilProperties.getPropertyValue(configString, "payment.paypal.business");
               
        // create the redirect string
        Map parameters = new LinkedMap();
        parameters.put("cmd", "_xclick");
        parameters.put("business", payPalAccount);
        parameters.put("item_name", itemName);
        parameters.put("item_number", itemNumber);
        parameters.put("invoice", orderId);
        parameters.put("custom", userLogin.getString("userLoginId"));
        parameters.put("amount", orderTotal);        
        parameters.put("return", returnUrl);
        parameters.put("cancel_return", cancelReturnUrl);
        parameters.put("notify_url", notifyUrl);
        parameters.put("image_url", imageUrl);
        parameters.put("no_note", "1");        // no notes allowed in paypal (not passed back)
        parameters.put("no_shipping", "1");    // no shipping address required (local shipping used)
               
        String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false);
        String redirectString = redirectUrl + "?" + encodedParameters;  
       
        // set the order in the session for cancelled orders
        request.getSession().setAttribute("PAYPAL_ORDER", orderId);
       
        // redirect to paypal
        try {
            response.sendRedirect(redirectString);
        } catch (IOException e) {
            Debug.logError(e, "Problems redirecting to PayPal", module);
            request.setAttribute("_ERROR_MESSAGE_", "Problems connecting with PayPal, please contact customer service.");
            return "error";
        }
       
        return "success";  
    }
   
    /** PayPal Call-Back Event */
    public static String payPalIPN(HttpServletRequest request, HttpServletResponse response) {
        ServletContext application = ((ServletContext) request.getAttribute("servletContext"));
        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");  
       
        // get the webSiteId
        String webSiteId = CatalogWorker.getWebSiteId(request);

        // get the product store
        GenericValue productStore = ProductStoreWorker.getProductStore(request);

        // get the payment properties file
        GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_PAYPAL", null, true);
        String configString = null;
        if (paymentConfig != null) {
            configString = paymentConfig.getString("paymentPropertiesPath");
        }

        if (configString == null) {
            configString = "payment.properties";
        }
               
        // get the confirm URL
        String confirmUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.confirm");
        if (confirmUrl == null) {
            Debug.logError("Payment properties is not configured properly, no confirm URL defined!", module);
            request.setAttribute("_ERROR_MESSAGE_", "PayPal has not been configured, please contact customer service.");
            return "error";
        }
               
        // first verify this is valid from PayPal
        Map parametersMap = UtilHttp.getParameterMap(request);
        parametersMap.put("cmd", "_notify-validate");  
       
        // send off the confirm request    
        String confirmResp = null;

        try {
            String str = UtilHttp.urlEncodeArgs(parametersMap);
            URL u = new URL("http://www.paypal.com/cgi-bin/webscr");
            URLConnection uc = u.openConnection();
            uc.setDoOutput(true);
            uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            PrintWriter pw = new PrintWriter(uc.getOutputStream());
            pw.println(str);
            pw.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
            confirmResp = in.readLine();
            in.close();
            Debug.logError("PayPal Verification Response: " + confirmResp, module);
        } catch (IOException e) {
            Debug.logError(e, "Problems sending verification message", module);
        }

        if (confirmResp.trim().equals("VERIFIED")) {
            // we passed verification
            Debug.logInfo("Got verification from PayPal, processing..", module);
        } else {
            Debug.logError("###### PayPal did not verify this request, need investigation!", module);
            Set keySet = parametersMap.keySet();
            Iterator i = keySet.iterator();
            while (i.hasNext()) {
                String name = (String) i.next();
                String value = request.getParameter(name);
                Debug.logError("### Param: " + name + " => " + value, module);
            }
        }
       
        // get the user
        GenericValue userLogin = null;
        String userLoginId = request.getParameter("custom");
        if (userLoginId == null)
            userLoginId = "admin";
        try {
            userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId));
        } catch (GenericEntityException e) {
            Debug.logError(e, "Cannot get UserLogin for: " + userLoginId + "; cannot continue", module);
            request.setAttribute("_ERROR_MESSAGE_", "Problems getting authentication user.");
            return "error";
        }
                               
        // get the orderId
        String orderId = request.getParameter("invoice");

        // get the order header
        GenericValue orderHeader = null;
        if (UtilValidate.isNotEmpty(orderId)) {
            try {
                orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
            } catch (GenericEntityException e) {
                Debug.logError(e, "Cannot get the order header for order: " + orderId, module);
                request.setAttribute("_ERROR_MESSAGE_", "Problems getting order header.");
                return "error";
            }
        } else {
            Debug.logError("PayPal did not callback with a valid orderId!", module);
            request.setAttribute("_ERROR_MESSAGE_", "No valid orderId returned with PayPal Callback.");
            return "error";
        }

        if (orderHeader == null) {
            Debug.logError("Cannot get the order header for order: " + orderId, module);
            request.setAttribute("_ERROR_MESSAGE_", "Problems getting order header; not a valid orderId.");
            return "error";
        }

        // get payment data
        String paymentCurrency = request.getParameter("mc_currency");
        String paymentAmount = request.getParameter("mc_gross");
        String paymentFee = request.getParameter("mc_fee");
        String transactionId = request.getParameter("txn_id");

        // get the transaction status
        String paymentStatus = request.getParameter("payment_status");

        // attempt to start a transaction
        boolean okay = false;
        boolean beganTransaction = false;
        try {
            beganTransaction = TransactionUtil.begin();

            if (paymentStatus.equals("Completed")) {
                okay = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId);
            } else if (paymentStatus.equals("Failed") || paymentStatus.equals("Denied")) {
                okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
            }

            if (okay) {
                // set the payment preference
                okay = setPaymentPreferences(delegator, dispatcher, userLogin, orderId, request);
            }
        } catch (Exception e) {
            String errMsg = "Error handling PayPal notification";
            Debug.logError(e, errMsg, module);
            try {
                TransactionUtil.rollback(beganTransaction, errMsg, e);
            } catch (GenericTransactionException gte2) {
                Debug.logError(gte2, "Unable to rollback transaction", module);
            }
        } finally {
            if (!okay) {
                try {
                    TransactionUtil.rollback(beganTransaction, "Failure in processing PayPal callback", null);
                } catch (GenericTransactionException gte) {
                    Debug.logError(gte, "Unable to rollback transaction", module);
                }
            } else {
                try {
                    TransactionUtil.commit(beganTransaction);
                } catch (GenericTransactionException gte) {
                    Debug.logError(gte, "Unable to commit transaction", module);
                }
            }
        }


        if (okay) {
            // attempt to release the offline hold on the order (workflow)
            OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId);

            // call the email confirm service
            Map emailContext = UtilMisc.toMap("orderId", orderId);
            try {
                Map emailResult = dispatcher.runSync("sendOrderConfirmation", emailContext);
            } catch (GenericServiceException e) {
                Debug.logError(e, "Problems sending email confirmation", module);
            }
        }

        return "success";
    }
       
    /** Event called when customer cancels a paypal order */
    public static String cancelPayPalOrder(HttpServletRequest request, HttpServletResponse response) {
        ServletContext application = ((ServletContext) request.getAttribute("servletContext"));
        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
       
        // get the stored order id from the session
        String orderId = (String) request.getSession().getAttribute("PAYPAL_ORDER");
               
        // attempt to start a transaction
        boolean beganTransaction = false;
        try {
            beganTransaction = TransactionUtil.begin();
        } catch (GenericTransactionException gte) {
            Debug.logError(gte, "Unable to begin transaction", module);
        }  
             
        // cancel the order
        boolean okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
       
        if (okay) {                
            try {
                TransactionUtil.commit(beganTransaction);
            } catch (GenericTransactionException gte) {
                Debug.logError(gte, "Unable to commit transaction", module);
            }
        } else {
            try {
                TransactionUtil.rollback(beganTransaction, "Failure in processing PayPal cancel callback", null);
            } catch (GenericTransactionException gte) {
                Debug.logError(gte, "Unable to rollback transaction", module);
            }
        }  
       
        // attempt to release the offline hold on the order (workflow)
        if (okay)
            OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId);  
           
        request.setAttribute("_EVENT_MESSAGE_", "Previous PayPal order has been cancelled.");
        return "success";        
    }    
   
    private static boolean setPaymentPreferences(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, String orderId, ServletRequest request) {
        Debug.logVerbose("Setting payment prefrences..", module);
        List paymentPrefs = null;
        try {
            Map paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED");
            paymentPrefs = delegator.findByAnd("OrderPaymentPreference", paymentFields);
        } catch (GenericEntityException e) {
            Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module);
            return false;
        }
        if (paymentPrefs != null && paymentPrefs.size() > 0) {
            Iterator i = paymentPrefs.iterator();
            while (i.hasNext()) {
                GenericValue pref = (GenericValue) i.next();
                boolean okay = setPaymentPreference(dispatcher, userLogin, pref, request);
                if (!okay)
                    return false;
            }
        }
        return true;
    }  
       
    private static boolean setPaymentPreference(LocalDispatcher dispatcher, GenericValue userLogin, GenericValue paymentPreference, ServletRequest request) {
        String paymentDate = request.getParameter("payment_date");  
        String paymentType = request.getParameter("payment_type");      
        String paymentAmount = request.getParameter("mc_gross");    
        String paymentStatus = request.getParameter("payment_status");        
        String transactionId = request.getParameter("txn_id");

        List toStore = new LinkedList();

        // PayPal returns the timestamp in the format 'hh:mm:ss Jan 1, 2000 PST'
        // Parse this into a valid Timestamp Object
        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss MMM d, yyyy z");
        java.sql.Timestamp authDate = null;
        try {        
            authDate = new java.sql.Timestamp(sdf.parse(paymentDate).getTime());
        } catch (ParseException e) {
            Debug.logError(e, "Cannot parse date string: " + paymentDate, module);
            authDate = UtilDateTime.nowTimestamp();
        } catch (NullPointerException e) {
            Debug.logError(e, "Cannot parse date string: " + paymentDate, module);
            authDate = UtilDateTime.nowTimestamp();
        }

        paymentPreference.set("maxAmount", new Double(paymentAmount));
        if (paymentStatus.equals("Completed")) {
            paymentPreference.set("statusId", "PAYMENT_RECEIVED");
        } else {
            paymentPreference.set("statusId", "PAYMENT_CANCELLED");
        }
        toStore.add(paymentPreference);


        GenericDelegator delegator = paymentPreference.getDelegator();

        // create the PaymentGatewayResponse
        String responseId = delegator.getNextSeqId("PaymentGatewayResponse").toString();
        GenericValue response = delegator.makeValue("PaymentGatewayResponse", null);
        response.set("paymentGatewayResponseId", responseId);
        response.set("paymentServiceTypeEnumId", "PRDS_PAY_EXTERNAL");
        response.set("orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId"));
        response.set("paymentMethodTypeId", paymentPreference.get("paymentMethodTypeId"));
        response.set("paymentMethodId", paymentPreference.get("paymentMethodId"));

        // set the auth info
        response.set("amount", new Double(paymentAmount));
        response.set("referenceNum", transactionId);
        response.set("gatewayCode", paymentStatus);
        response.set("gatewayFlag", paymentStatus.substring(0,1));
        response.set("gatewayMessage", paymentType);
        response.set("transactionDate", authDate);
        toStore.add(response);

        // create a payment record too
        Map results = null;
        try {
            results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("userLogin", userLogin,
                    "orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId"), "comments", "Payment receive via PayPal"));
        } catch (GenericServiceException e) {
            Debug.logError(e, "Failed to execute service createPaymentFromPreference", module);
            request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
            return false;
        }

        if ((results == null) || (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR))) {
            Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module);
            request.setAttribute("_ERROR_MESSAGE_", (String) results.get(ModelService.ERROR_MESSAGE));
            return false;
        }

        try {
            delegator.storeAll(toStore);
        } catch (GenericEntityException e) {
            Debug.logError(e, "Cannot set payment preference/payment info", module);
            return false;
        }
        return true;            
    }

}


____________________________________________________________________________

Thanks in advance for your help

rohit
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

Jacopo Cappellato
Yes,

you have to do an "ant build".

Jacopo

rohit2006 wrote:

> hi,
>
> thanks for the reply. i have just edited the file as mentioned by you and
> restarted the ofbiz server, but no help. the URL still includes the '&amp'.
> i am not sure what to do next, do i have to do a 'ant' command or something
> else for the changes to take effect. For your reference i am pasting a copy
> of the file here.
>
> paypalEvets.java
>

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
hi,

thanks for the prompt reply. do i have to a build of the entire code or for a specific file. i had a though time installing the code on my server, hence would really like to recompile everything. i will appreciate if you could show what the entire command should be.

thanks

rohit

Jacopo Cappellato <[hidden email]> wrote:
Yes,

you have to do an "ant build".

Jacopo

rohit2006 wrote:

> hi,
>
> thanks for the reply. i have just edited the file as mentioned by you and
> restarted the ofbiz server, but no help. the URL still includes the '&'.
> i am not sure what to do next, do i have to do a 'ant' command or something
> else for the changes to take effect. For your reference i am pasting a copy
> of the file here.
>
> paypalEvets.java
>


_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

Jacopo Cappellato
Inside the ofbiz folder:

"ant build"

Jacopo


Rohit Sureka wrote:

> hi,
>
> thanks for the prompt reply. do i have to a build of the entire code or
> for a specific file. i had a though time installing the code on my
> server, hence would really like to recompile everything. i will
> appreciate if you could show what the entire command should be.
>
> thanks
>
> rohit
>
> */Jacopo Cappellato <[hidden email]>/* wrote:
>
>     Yes,
>
>     you have to do an "ant build".
>
>     Jacopo
>
>     rohit2006 wrote:
>      > hi,
>      >
>      > thanks for the reply. i have just edited the file as mentioned by
>     you and
>      > restarted the ofbiz server, but no help. the URL still includes
>     the '&'.
>      > i am not sure what to do next, do i have to do a 'ant' command or
>     something
>      > else for the changes to take effect. For your reference i am
>     pasting a copy
>      > of the file here.
>      >
>      > paypalEvets.java
>      >
>
>
>     _______________________________________________
>     Users mailing list
>     [hidden email]
>     http://lists.ofbiz.org/mailman/listinfo/users
>
>
> ------------------------------------------------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC
> <http://us.rd.yahoo.com/mail_us/taglines/postman5/*http://us.rd.yahoo.com/evt=39666/*http://messenger.yahoo.com>
> and save big.
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
i am sorry, i meant i would not like to build the entire code. is it possible to build only the files related to paypal.

rohit
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

Jacopo Cappellato
I don't know...

you can build only one component if you run:

"ant jar" inside the component's folder.

Jacopo

rohit2006 wrote:

> i am sorry, i meant i would not like to build the entire code. is it possible
> to build only the files related to paypal.
>
> rohit
> --
> View this message in context: http://www.nabble.com/Users---PayPal-t940082.html#a4403630
> Sent from the OFBiz - User forum at Nabble.com.
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
>

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
hi, i just did a "ant build' and then restarted the server. The URL is working absolutely fine now.

thanks a lot for the help.

rohit
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

BJ Freeman
In reply to this post by Jacopo Cappellato
the services for paypal are in accounting, the code to access the
services is in eccommerce.
so you need to keep the two in sync.

Jacopo Cappellato sent the following on 5/15/06 10:53 PM:

> I don't know...
>
> you can build only one component if you run:
>
> "ant jar" inside the component's folder.
>
> Jacopo
>
> rohit2006 wrote:
>
>>i am sorry, i meant i would not like to build the entire code. is it possible
>>to build only the files related to paypal.
>>
>>rohit
>>--
>>View this message in context: http://www.nabble.com/Users---PayPal-t940082.html#a4403630
>>Sent from the OFBiz - User forum at Nabble.com.
>>
>>
>>_______________________________________________
>>Users mailing list
>>[hidden email]
>>http://lists.ofbiz.org/mailman/listinfo/users
>>
>
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
>
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - PayPal

rohit
In reply to this post by Andrew Zeneski
Hi,

I suppose this problem is still not completely resolverd. The IPN fails until another line is changes as below

// first verify this is valid from PayPal
        Map parametersMap = UtilHttp.getParameterMap(request);
        parametersMap.put("cmd", "_notify-validate");  
       
        // send off the confirm request    
        String confirmResp = null;

        try {
            String str = UtilHttp.urlEncodeArgs(parametersMap, false); ( 'false' had to be added for the IPN to be properly received, other we get the error mentioned on this link http://www.nabble.com/paypal-IPN-error.-IPN-is-not-received-and-transaction-is-not-recorded-tf2126743.html#a5868092)

            URL u = new URL("http://www.paypal.com/cgi-bin/webscr");
            URLConnection uc = u.openConnection();
            uc.setDoOutput(true);

But the IPN is still not correctly processed, as it gets stuck in the following code:

        // get the orderId
        String orderId = request.getParameter("invoice");

        // get the order header
        GenericValue orderHeader = null;
        if (UtilValidate.isNotEmpty(orderId)) {
            try {
                orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
            } catch (GenericEntityException e) {
                Debug.logError(e, "Cannot get the order header for order: " + orderId, module);
                request.setAttribute("_ERROR_MESSAGE_", "Problems getting order header.");
                return "error";
            }
        } else {
            Debug.logError("PayPal did not callback with a valid orderId!", module);
            request.setAttribute("_ERROR_MESSAGE_", "No valid orderId returned with PayPal Callback.");
            return "error";
        }

and we get this error:  

2006-08-25 12:34:57,090 (http-0.0.0.0-7070-Processor6) [     RequestHandler.java:144:INFO ] This is the first request in this visit.
2006-08-25 12:34:57,716 (http-0.0.0.0-7070-Processor6) [     RequestHandler.java:203:INFO ] [Processing Request]: payPalNotify
2006-08-25 12:34:58,043 (http-0.0.0.0-7070-Processor6) [       PayPalEvents.java:222:ERROR] PayPal Verification Response: VERIFIED
2006-08-25 12:34:58,045 (http-0.0.0.0-7070-Processor6) [       PayPalEvents.java:229:INFO ] Got verification from PayPal, processing..
2006-08-25 12:34:58,056 (http-0.0.0.0-7070-Processor6) [       PayPalEvents.java:268:ERROR] PayPal did not callback with a valid orderId!
2006-08-25 12:34:59,192 (http-0.0.0.0-7070-Processor6) [     RequestHandler.java:274:ERROR] Request payPalNotify caused an error with the following message: No valid orderId returned with PayPal Callback.
2006-08-25 12:34:59,194 (http-0.0.0.0-7070-Processor6) [     RequestHandler.java:386:INFO ] [RequestHandler.doRequest]: Response is a view.


I not sure why the order ID is not retreived.

rohit

A. Zeneski wrote
Done.

On May 15, 2006, at 1:06 PM, Hao Jiang wrote:

> Hi, I've fixed it. The problem is not the email address format, which
> bizdev%40userful.com is OK, but look at the URL string, it uses  
> "&"
> instead of "&", that's not acceptable.
>
> Looking at the class
> ofbiz/applications/accounting/src/org/ofbiz/accounting/thirdparty/
> paypal/PayPalEvents.java
>
> at line 162,
> String encodedParameters = UtilHttp.urlEncodeArgs(parameters);
>
> then look at UtilHttp class, this will eventually call
> urlEncodeArgs(parameters, true), then return "&", not "&"
>
> so the easiest way to fix it is modify the line 162 code to
> String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false);
>
> Hao
>
>
>
> On Mon, 2006-05-15 at 04:52 -0700, rohit2006 wrote:
>> hey, i am too getting the same error. the business email ID is shown
>> bizdev%40userful.com in the paypal URL, which paypal does not accept.
>> someone please help. i am using opentaps-0.9.0.
>>
>> rohit
>> --
>> View this message in context: http://www.nabble.com/Users---PayPal- 
>> t940082.html#a4390637
>> Sent from the OFBiz - User forum at Nabble.com.
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users@lists.ofbiz.org
>> http://lists.ofbiz.org/mailman/listinfo/users
>>
>
>
>
> _______________________________________________
> Users mailing list
> Users@lists.ofbiz.org
> http://lists.ofbiz.org/mailman/listinfo/users

 
_______________________________________________
Users mailing list
Users@lists.ofbiz.org
http://lists.ofbiz.org/mailman/listinfo/users