Here is a sample code to add the button PayPal "buy now" in your development Adobe Flex.
This code can be improved to make a basket to send to paypal in Flex. The method sends the data to paypal with a redirect button "buy now" using flash.net.URL request. The example is basic, and full management of the basket is a long ...
Now the sources:
Typical HTML file for the call to PayPal:
<! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Untitled Document </ title>
</ head><body>
<form method="post"> action="https://www.paypal.com/cgi-bin/webscr"
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="you@youremail.com">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="0.00">
<input type = "image" src = "http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name = "submit" alt = "Make payments with PayPal - it's fast, free and secure! ">
</ form>
</ body>
</ html>
And here is the Flex:
<xml version = "1.0" encoding = "utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx: Image source = "http://www.paypal.com/en_US/i/btn/x-click-but01.gif" horizontalCenter = "0" verticalCenter = "0" click = "makePayment ();"/ >
<mx:Script>
<[CDATA [
import flash.net.URLRequest
public function makePayment (): void (
var url: String = "https: / / www.paypal.com / cgi-bin / webscr";
var request: URLRequest = new URLRequest (url);
var variables: URLVariables = new URLVariables ();
variables.cmd = "_xclick";
variables.currency_code = "EUR";
variables.business = "contact@flex-info.fr";
variables.item_number = "001";
variables.item_name = "Donation for Flex-info.fr";
variables.amount = "1.00";
variables.quantity = 1;
variables.tax ='';
request.data = variables;
request.method = URLRequestMethod.POST;
navigateToURL (request, "_parent");
)
]]>
</ mx: Script>
</ mx: Application>
To embed this button on a list of products:
1) load product data from a xml file and a call with HTTPService
2) Use the "repeater" to create your buttons (and the product display)
... And implement it in your shopping cart to pay with PayPal!
Hoping that this helps some of you ![]()
Note: This procedure applies to implement most of the online payments ![]()
Source: Community Flex
If you come for the first time on Flex-info.fr, you can subscribe to the RSS feed. Thank you for your visit!





















March 19th, 2008 at 8 h 03 min
hi
thank you for this very useful example
March 20th, 2008 at 10 h 48 min
Hi,
Very interesting example of this PayPal! Thank you very much.
March 25th, 2008 at 18 h 51 min
Great!
Thank you for this example.
March 27th, 2008 at 13 h 38 min
So it sure is easy to implement but it can bring other problems where one wants to retrieve the result of the transaction, for example, where delivering a product purchased by a customer .
From the moment you want to retrieve the result of the transaction, you lose the status of implementation because the swf must be reloaded when switching SWF> Paypal or Paypal> SWF. So we must find a way to reload the application in the same condition it was before being redirected to paypal which can become quite difficult to implement depending on the complexity of the application.
March 27th, 2008 at 15 h 38 min
It is true that it seems easy to integrate at first sight, but this article does not explain the most difficult to implement, namely the recovery of the outcome of the request.
When using Paypal, we want généralemet how the transaction took place the customer's paypal page. For example, to update its stock in the future or simply retrieve the delivery address.
To do this, you must specify in the script, a variable 'return' that indicates the URL of return, namely that of the SWF. The SWF is reloaded must at one time or another (either in the transition from application to paypal or to return). The problem is that the status of implementation is lost and must be put in place a system to recover this state at the time of return which can be difficult depending on the complexity of the application. (For example, for an application that contains several tabs, these tabs display as well as their content)
March 27th, 2008 at 15 h 39 min
> Sorry for the comment too. My computer crashed at the time of posting the 1st comment and I thought it was not passed
April 16th, 2008 at 9 h 25 min
Hello Julien,
We have 2 sites on integrated payment without going through the open window or HTML page, which is simpler and more reassuring for the user. We will try to take the time to do a story on http://www.matsiya.fr
+ +
April 16th, 2008 at 14 h 12 min
Ok, let us keep abreast
July 8th, 2008 at 14 h 30 min
hello! this c code can be improved to make a basket to send a paypal flex
precision necessary? n the parenthèsese sometimes say more than Toutle e rest
billlet thank you for this interesting, fun to read vou!
July 18th, 2008 at 10 h 54 min
hi,
Indeed, it would be nice to know how to send a request basket paypal "without opening a new window. Just by sending data at Paypal but remaining on the current page.
Thank you
Mr Nourrain
February 6th, 2009 at 15 h 35 min
Hello,
I just want to give some details on the integration process a payment in a flash / flex.
For now, the only way for the customer not to leave the environment of the site is the communication server (your server and the trusted third party).
API paypal (express) is not possible at this time because the customer is leaving at some point the environment.
Some trusted third party service provides communication between servers but is more expensive than traditional service.
Ex: Direct PayBox Services.
Sincerely yours
Goel
February 25th, 2009 at 17 h 16 min
Ok noted. Goel thank you for the info