Trying to create an Integration With SalesForce...

rjpalomborjpalombo Member
in Help edited January 2011
I'm finding some good examples using the API with other languages, but none in Java/APEX for SalesForce. And none that get into what I need to.

I can probably wing it though I'm having difficulty starting it off and it's taking too much time.

For now I've created an APEX/VisualForce page that simply generates an HTML form based off the Account, Contact, Opportunity, and Products created in SalesForce. This sends a simple POST after clicking the submit button that's sent to mydomain.foxycart.com/cart

This at least pre-populates the email, shipping info, products, etc.. However I'd also like to send the password, which I can't seem to do, but that's not the real question.

What I'd like to do is when the order is processed I want to send some data plus the transaction ID back to SalesForce. Maybe not all data, just the transaction is great and then somehow at an interval like every 5 minutes or once a day I want to pull a FULL feed and synchronize FoxyCart with SalesForce. I want to do this because SalesForce will sometimes have down times and I'd rather have a way to be certain we have all the orders and customer info captured.

I'm not even sure where to start. I have one issue in that our website uses the cart as well. I'd have to somehow pass data to FoxyCart to tell it where the order is coming from (SalesForce/Website). After the order is processed FoxyCart would send this parameter to my page and the page could determine what to do with it.

I've read all the API docs I could find and can't get the start I need. Please Help!

You don't need to know Java or APEX to help me. Just in direction of what I need to do will suffice.

I promise to post my work for all other SalesForce developers if you can get me on the right track!

Thanks in advance!

-RJ
Comments
  • brettbrett FoxyCart Team
    Hi RJ.
    So it sounds like there are 2 things here. Or maybe 3.

    1) Get an add-to-cart form from Salesforce -> FoxyCart.
    2) Prepopulate or synchronize Salesforce contacts with FoxyCart customers.
    3) Get data back into Salesforce.

    For #1 is sounds like you have it handled, though you mentioned the password issue with gets into #2. Also, if you need to differentiate between Salesforce and website sales you could add a h:transaction_source=salesforce parameter or something that'd be present in the XML datafeed (#3).

    For #2 it sounds like you're prepopulating, which will work for some things but not for passwords. The recommended approach would be to synchronize Salesforce contacts to FoxyCart users:
    http://wiki.foxycart.com/static/redirect/api
    We're rolling out some new functionality in v0.7.1 very soon also that will give more flexibility with password hashing:
    http://wiki.foxycart.com/v/0.7.0/customers#synchronizing_users_and_passwords
    How do you have the passwords stored and available in Salesforce? Can you handle creating users via the FC API from Salesforce?

    For #3, that'd be the XML datafeed:
    http://wiki.foxycart.com/static/redirect/xml_datafeed
    And this might be at least somewhat useful:
    http://wiki.foxycart.com/integration/salesforce

    Does any of that help? Perhaps we should break it down a little more if anything's unclear so we can focus on one piece at a time.
  • lukeluke FoxyCart Team
    One starting point you may want to focus on is having a publicly accessible "end point" url that you can point your XML Datafeed to that will process the data and update your databases as needed. Do you have something like that? What view tier are you using for Java/APEX and will it allow you to create a public url that can process and decrypt the POST values?
  • rjpalomborjpalombo Member
    edited February 2011
    Thanks brett and Luke!

    Luke, not for Java/APEX.

    I was hoping I could create a transaction sync rather than just a datafeed. Sounds Like may not be able to do that though it does say I can do this via the API. If there is more on this can you send a link?

    If not here are my steps:

    My Website is PHP and this would be the Publicly Accessible End Point. This site would host a page that would receive the transaction (with parameter as to where the transaction came from) and pass to SalesForce. The PHP would do a number of things. It would first look in Contacts for a Matching contact on Email. If one found the transaction would be created as a Closed/Won Opportunity with all the related products added to it. If no contact was found it would search leads. If a lead was found then it would convert the lead to an Account, Contact and Opportunity and add the products from the feed.

    Next is the Sync contacts. I would probably do this via SalesForce in APEX/Java. I would have a Scheduled Class that ran to update either record depending on what record was modified last.

    I'll wait for the Password project until all of this is finished, but again I had my hopes on synchronizing transactions as well. Please give me some good news :)
  • I should probably clarify in that I don't want to really "sync" transactions, rather pull transactions from FoxyCart and reconcile them with SFDC.
  • lukeluke FoxyCart Team
    Hey RJ. Most of what you're described should be pretty straightforward using the links Brett mentioned above and our XML Datafeed. Basically you'll need a PHP page (see the many examples on our wiki's integration page) that checks the $_POST values, decrypts the data, parses the XML and either saves it to your own local database for later use or updates your SalesForce system right then. All of the information you need should be sent to you through the XML Datafeed after every transaction.

    If you're just wanting historical data for transactions that already took place (and not a real time sync with the datafeed) you can use the API and the transaction_list api call.

    Does that help?
  • Everything helps :) Thanks.

    I've got an interesting method coming. Once I complete I'll post :)
  • brettbrett FoxyCart Team
    Definitely interested in seeing what you come up with. Let us know if you need any other help.
  • Hey there guys, getting back to this project. I'm hoping to complete by the end of this weekend. I keep hitting a wall using the tutorial with rc4crypt.

    There is always a Division by zero error. Error below:

    DataFeed Failed: (3152824) 2011-03-01 22:48:35 Datafeed Returned: ispwdHex = 0) { return rc4crypt::encrypt($pwd, $data, $ispwdHex); } } ?> <br /> <b>Warning</b>: Division by zero in <b>/html/sfdc/FOXYCART/7/class.rc4crypt.php</b> on line <b>51</b><br /> <br /> <b>Warning</b>: Division by zero in <b>/html/sfdc/FOXYCART/7/class.rc4crypt.php</b> on line <b>51</b><br /> <br /> <b>Warning</b>: Division by zero in <b>/html/sfdc/FOXYCART/7/class.rc4crypt.php</b> on line <b>51</b>
  • I'm kinda stuck here :'(

    Any help? Everytime I google: "rc4crypt Division by zero error" I get hundreds of sites WITH that very error lol... It's mind blowing. You'd think I'd find something tangible. Is there anything out there besides rc4crypt i should try maybe?
  • lukeluke FoxyCart Team
    Hey rjpalombo. Sorry you're having trouble, we'll help however we can.

    The error message is from line 51:
    $key[$i] = ord($pwd[$i % $pwd_length]);
    

    $pwd_length comes from
    $pwd_length = strlen($pwd);
    

    my hunch... is that you're not passing in a password?
  • Well i will Try and post the Solution
Sign In or Register to comment.