Sie sind auf Seite 1von 7

Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 1 of 7

(//www.scriptcase.net/)

Utilizando la API de Paypal y Pagseguro

Home (//www.scriptcase.net/tutorials/esp/)
/  Programación (https://www.scriptcase.net/tutorials/category/programming-es/)

1- Creamos una aplicación del tipo grid

2- Editamos los sgtes campos y creamos un nuevo campo llamado


“info”

• Campo Customerid

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 2 of 7

(//www.scriptcase.net/)

3- Creamos en el evento onRecord

4- Creamos dos métodos PHP, call_pagseguro() y call_paypal()

• Funcion call_pagseguro

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 3 of 7

$arr_settings = [    ‘gateway’    => ‘pagseguro’,    ‘environment’ => ‘sandbox’,    ‘auth_email’ =>


(//www.scriptcase.net/)
‘vitorjamil@gmail.com’,    ‘auth_token’ => ’72AE21503DDA4840BE1DC7945F6D1CE1′
             ];
sc_call_api(”,$arr_settings);
$payment = new \PagSeguro\Domains\Requests\Payment();
sc_lookup(ds_cust, “SELECT contactname FROM customers WHERE customerid =
‘{customerid}’ “);$senderName = {ds_cust[0][0]};$senderEmail =
“c05075609506900394802@sandbox.pagseguro.com.br”;$resp_apl = str_replace
(“grid_orders_paywith”,”control_paywith_return”,$_SERVER[“PHP_SELF”]);$redirectUrl =
“http://” . $_SERVER[“HTTP_HOST”]  . $resp_apl ;$notificationUrl = “http://” . $_SERVER
[“HTTP_HOST”]  . $resp_apl . “?pagseguro=notification”;
if (\PagSeguro\Configuration\Configure::getEnvironment()->getEnvironment() == “sandbox”)
{        $url_type = “https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout
(https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout)”;} else
{        $url_type = “https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout
(https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout)”;    }

$payment->setSender()->setName($senderName);
$payment->setSender()->setEmail($senderEmail);
$payment->setSender()->setPhone()->withParameters(             11,             56273440         );
$payment->setSender()->setDocument()->withParameters(             ‘CPF’,            
‘94505764249’         );
$sItems = “SELECT products.productname, order_details.quantity,
order_details.unitpriceFROM order_details INNER JOIN products ON
order_details.productid = products.productidWHERE orderid = “.{orderid};sc_select
(dsitems, $sItems);    $pos_item = 1;if ({dsitems} === false){    echo {dsitems_erro};}else
{    while (!{dsitems}->EOF){       $payment->addItems()->withParameters(    str_pad
($pos_item, 4, “0”, STR_PAD_LEFT),    {dsitems}->fields[0],    {dsitems}->fields[1],    {dsitems}
->fields[2]    );    $pos_item++;    {dsitems}->MoveNext();    }    {dsitems}->Close();}
$payment->setCurrency(“BRL”);
$payment->setExtraAmount(0.00);
$payment->setReference({orderid});
$payment->setRedirectUrl($redirectUrl);
$payment->setNotificationUrl($notificationUrl);

$payment->addPaymentMethod()->withParameters
( PagSeguro\Enum\PaymentMethod\Group::CREDIT_CARD,
PagSeguro\Enum\PaymentMethod\Config\Keys::MAX_INSTALLMENTS_NO_INTEREST, 2);
$payment->addPaymentMethod()->withParameters
( PagSeguro\Enum\PaymentMethod\Group::CREDIT_CARD,
PagSeguro\Enum\PaymentMethod\Config\Keys::MAX_INSTALLMENTS_LIMIT, 6);
$payment->acceptPaymentMethod()->groups
( \PagSeguro\Enum\PaymentMethod\Group::CREDIT_CARD,
\PagSeguro\Enum\PaymentMethod\Group::BALANCE);
$payment->acceptPaymentMethod()->name
(\PagSeguro\Enum\PaymentMethod\Name::DEBITO_ITAU);
$payment->excludePaymentMethod()->group
(\PagSeguro\Enum\PaymentMethod\Group::BOLETO);
try { $response = $payment->register(       

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 4 of 7

\PagSeguro\Configuration\Configure::getAccountCredentials() );    $transcode = substr


(//www.scriptcase.net/)
($response, strpos($response, “code=”) + 5);
   } catch (Exception $e) { die($e->getMessage());}

echo'<script type=”text/javascript” src=”‘.$url_type.’/pagseguro.lightbox.js”> </script>’;


echo ‘<script>var transactionCode = “‘.$transcode.'”;PagSeguroLightbox(    { code:
“‘.$transcode.'”},    {    success : function(transactionCode) {       window.location.href =
“‘.$redirectUrl.’?pagseguro=return&orderid=’.{orderid}.’&transcode=”+transactionCode;    },
   abort : function(transactionCode) {       window.location.href = “‘.$redirectUrl.’?
pagseguro=aborted&orderid=’.{orderid}.’&transcode=”+transactionCode;    }    });</script>’;

• Funcion call_Paypal

$arr_settings = [    ‘gateway’    => ‘paypal_express’,    ‘username’    => ‘vitorjamil-


facilitator_api1.hotmail.com’,    ‘password’    => ‘PATZ87JJP4TTA8M5’,    ‘signature’    =>
‘AFcWxV21C7fd0v3bYYYRCpSSRl31AiumnueMX6k4djKiUvF8HeI2RUZ1’,    ‘testMode’    =>
‘TRUE’              ];
$gateway = sc_call_api(”,$arr_settings);
$resp_apl = str_replace(“grid_orders_paywith”,”control_paywith_return”,$_SERVER
[“PHP_SELF”]);
$response = $gateway->purchase(array( ‘cancelUrl’=> ‘http://’ . $_SERVER[“HTTP_HOST”] .
$resp_apl . ‘?paypal=aborted&orderid=’.{orderid}, ‘returnUrl’=> ‘http://’ . $_SERVER
[“HTTP_HOST”] . $resp_apl . ‘?paypal=return&orderid=’.{orderid}, ‘amount’ =>  {priceorder},
‘currency’ => ‘USD’, ‘Description’ => {lang_orders_fild_orderid}.’ ‘.{priceorder} )
)->send();if ($response->isRedirect()) {   // redirect to offsite payment gateway
  $response->redirect();}else {   // payment failed: display message to customer   echo
$response->getMessage();}

5- Procedemos a crear una aplicación de control.

6- Creamos los sgtes campos del tipo etiqueta dentro de la aplicación


de control.

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 5 of 7

(//www.scriptcase.net/)

7- Ejecutamos la aplicación

• PagSeguro

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 6 of 7

Compartir este tutorial


(//www.scriptcase.net/)

(https://www.facebook.com/sharer/sharer.php? Facebook

(https://twitter.com/intent/tweet?text=Utilizando la API de Paypal y Pagseguro. % Twitter

(https://plus.google.com/share? Google+

(https://www.linkedin.com/shareArticle? Linkedin

Tutoriales en la misma categoria

CONFIRMACIÓN POR CORREO ELECTRÓNICO


(HTTPS://WWW.SCRIPTCASE.NET/TUTORIALS/CONFIRMACION-
POR-CORREO-ELECTRONICO/)
En este tutorial veremos cómo crear un formulario de confirmación de registro para programar
curs...

ENVIAR MÚLTIPLES SMS CON LA MACRO SC_SEND_SMS


(HTTPS://WWW.SCRIPTCASE.NET/TUTORIALS/ENVIAR-
MULTIPLES-SMS-CON-LA-MACRO-SC_SEND_SMS/)
En este ejemplo estaremos viendo cómo podemos crear una aplicación que nos ayude  a enviar
m...

ENVIAR SMS CON LA MACRO SC_SEND_SMS


(HTTPS://WWW.SCRIPTCASE.NET/TUTORIALS/ENVIAR-SMS-
CON-LA-MACRO-SC_SEND_SMS/)
Creando una aplicación de Control Creamos una aplicación del tipo Control. 2. Una vez c...

USO DE LA API DE MANDRILL CON MACRO SC_CALL_API


(HTTPS://WWW.SCRIPTCASE.NET/TUTORIALS/USO-DE-LA-API-
DE-MANDRILL-CON-MACRO-SC_CALL_API/)
En este tutorial vamos a estar mostrando como utilizar la macro sc_call_api con la API de
Mandrill....

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019
Tutorial: Utilizando la API de Paypal y Pagseguro | Tutoriais Scriptcase Page 7 of 7

(//www.scriptcase.net/) ©2019 Scripcase. Todos los derechos reservados.

https://www.scriptcase.net/tutorials/utilizando-la-api-de-paypal-y-pagseguro/ 15-04-2019

Das könnte Ihnen auch gefallen