Digital Motion dot net

Digital Media Production

Creating a paypal button for Flex 2

I may post my source of this eventually, but for now I’m just wondering if there is a better way to do this. I spent a long time searching, but had zero luck. The existing mechanisms to integrate a paypal button into a flash site require the URLLoader class which doesn’t exist in AS3.

After spending a bunch of time searching the flex and paypal sites, I was getting really discouraged.

Finally, I came up with this hack:

I use the ExternalInterface to “shell out” to javascript where I create the form that paypal needs dynamically in Javascript and then submit it (also dynamically). It works, but it really seems like a hack to me.

Is there a better way to do this?

2 comments

2 Comments so far

  1. Joe Shell February 10th, 2008 3:43 pm

    Hi there,

    Any chance of getting the source on that?

    Cheers,

    Joe

  2. levi May 26th, 2008 4:36 am

    whats up?
    well if you use the URLRequest, and URLVariables functions you can send the data to paypal.
    then using the externalinterface call, you can accept the data from paypal on the customers return, getting all of the data back such as name, location, paypal_id, ect..

    then send the data into flex using the externalInterface.addcallback function to call a flex function to recieve the data.

    just a little javascript to recognise when paypal is attempting to send the data, pass the data onto flex and you have yourself a working io with paypal.

    this is nice so you dont have to use any backend interfaces to call flex (like amfphp or something) this will allow you to notify your app that the user is finished, you can even include some code to keep sessions so they dont loose all their data in the interim.

    i will be posting the full code to my site once its finished.

Leave a reply