Start a conversation

Paypal integration

More information about authentication with PayPal - Read Me

First we will create a grid:

Access OnScriptInit event:

In this event add the following code:


[i] = 0;
[total_chked] = array();
[i1] = 0;
[total_chked1] = array();


Note.: Remember to put the global variables for output: Application> Global Variables


Now we will create a button type Run:


And put the following code in "OnRecord" button:

$arr=[i];
$arr1 = [i1];
[total_chked][$arr]={unitprice};
[total_chked1][$arr1]={productname};
[i]++;
[i1]++;


And in "OnFinish" will use the following code (the end to redirect the application control name "pay_by_paypal":


$tot = count([total_chked]);
$tot1 = count([total_chked1]);

$value = "";
$productname = "";

for($x=0;$x<$tot;$x++){
 $value += [total_chked][$x];
}

for($x=0;$x<$tot1;$x++){
     $productname .= [total_chked1][$x];
        if($x == ($tot-1)){
    $productname .= ".";             
   } else {  
    $productname .= ",";
  }
    }


[value] = $value;
[qtd] = $tot;
[description] = $productname;
sc_redir(pay_by_paypal);


Application Runtime:


Now we will create an application of type Control.

We create the fields below:


We access the "onLoad" event:


And insert the following code:


[orderid] = rand();
{CustomField}=[qtd];
{Description}=[description];
{Amount}=[value];
{ordernumber} = [orderid];


Now, we access the "Authentication" option:


Let's go to the "PayPal" option:

Add our information:


Id: Paypal ID to receive the money from the sales. Typically, the e-mail address registered as a business.

Order number: Order number to be stored in paypal. Also used to treat the receipt of the IPN in order to identify and process the order as paid.

Custom field: to be stored in paypal: It is also used to treat the receipt of the IPN in order to identify and process the order as paid, if you want to do some additional tests

Variable with the description: global variable that will contain the description to be sent to paypal.

Variable with total value: global variable that will contain the full amount of sale to be sent to Paypal.

 

Selected the products we want:


When you click "Purchase", we can see the Application Control:


Note.: To enable the “PayPal” button should access the “Toolbar” option and move the “PayPal” button to the right frame.


By clicking “PayPal” will be redirected to the page with the paypal purchase information:

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Ronyan Alves

  2. Posted
  3. Updated

Comments