Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde, sou programador iniciante e gostaria de integrar uma loja virtual com o pag seguro e estou tendo o seguinte problema
tenho um formulário
que o submit dele vai para
o código do pagseguro de exemplo logo abaixo
como posso receber os dados do formulario e trocar por exemplo
'comprador@s2it.com.br', pela variavel $email
ja tentei receber via POST e trocar 'comprador@s2it.com.br', pela variavel $email que recebe o campo email do formulario
Como posso resolver isso?
require_once "PagSeguroLibrary/PagSeguroLibrary.php";
/**
* Class with a main method to illustrate the usage of the domain class PagSeguroPaymentRequest
*/
class CreatePaymentRequestLightbox
{
public static function main()
{
// Instantiate a new payment request
$paymentRequest = new PagSeguroPaymentRequest();
// Sets the currency
$paymentRequest->setCurrency("BRL");
// Add an item for this payment request
$paymentRequest->addItem('0001', 'Notebook prata', 2, 430.00);
// Add another item for this payment request
$paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.00);
// Sets a reference code for this payment request, it is useful to identify this payment
// in future notifications.
$paymentRequest->setReference("REF123");
// Sets shipping information for this payment request
$sedexCode = PagSeguroShippingType::getCodeByType('SEDEX');
$paymentRequest->setShippingType($sedexCode);
$paymentRequest->setShippingAddress(
'01452002',
'Av. Brig. Faria Lima',
'1384',
'apto. 114',
'Jardim Paulistano',
'São Paulo',
'SP',
'BRA'
);
// Sets your customer information.
$paymentRequest->setSender(
"nome",
'comprador@s2it.com.br',
'11',
'56273440',
'CPF',
'156.009.442-76'
);
// Sets the url used by PagSeguro for redirect user after ends checkout process
$paymentRequest->setRedirectUrl("[http://www.lojamodelo.com.br](http://www.lojamodelo.com.br/)");
// Add checkout metadata information
$paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1);
$paymentRequest->addMetadata('GAME_NAME', 'DOTA');
$paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1);
// Another way to set checkout parameters
$paymentRequest->addParameter('notificationURL', '[http://www.lojamodelo.com.br/nas](http://www.lojamodelo.com.br/nas)');
$paymentRequest->addParameter('senderBornDate', '07/05/1981');
$paymentRequest->addIndexedParameter('itemId', '0003', 3);
$paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3);
$paymentRequest->addIndexedParameter('itemQuantity', '1', 3);
$paymentRequest->addIndexedParameter('itemAmount', '200.00', 3);
try {
/*
* #### Credentials #####
* Substitute the parameters below with your credentials (e-mail and token)
* You can also get your credentials from a config file. See an example:
* $credentials = PagSeguroConfig::getAccountCredentials();
*/
$credentials = new PagSeguroAccountCredentials("meuemail@yahoo.com",
"3A1B4DA7956746F0B5232329FA36C82E9B6");
// Register this payment request in PagSeguro, to obtain the checkout code
$onlyCheckoutCode = true;
$code = $paymentRequest->register($credentials, $onlyCheckoutCode);
self::printPaymentUrl($code);
} catch (PagSeguroServiceException $e) {
die($e->getMessage());
}
}
public static function printPaymentUrl($code)
{
if ($code) {
echo "<h2>Criando requisição de pagamento</h2>";
echo "<p>Code: <strong>$code</strong></p>";
echo "<script>
PagSeguroLightbox('".$code."');
</script>";
}
}
}
CreatePaymentRequestLightbox::main();Carregando comentários...