public static function main() { // Instantiate a new payment request $directPaymentRequest = new PagSeguroDirectPaymentRequest(); // Set the Payment Mode for this payment request $directPaymentRequest->setPaymentMode('DEFAULT'); // Set the Payment Method for this payment request $directPaymentRequest->setPaymentMethod('EFT'); /** * @todo Change the receiver Email */ $directPaymentRequest->setReceiverEmail('*****@*****.**'); // Set the currency $directPaymentRequest->setCurrency("BRL"); // Add an item for this payment request $directPaymentRequest->addItem('0001', 'Descricao do item a ser vendido', 2, 10.0); // Add an item for this payment request $directPaymentRequest->addItem('0002', 'Descricao do item a ser vendido', 2, 5.0); // Set a reference code for this payment request. It is useful to identify this payment // in future notifications. $directPaymentRequest->setReference("REF123"); // Set your customer information. // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br $directPaymentRequest->setSender('João Comprador', '*****@*****.**', '11', '56273440', 'CPF', '156.009.442-76', true); $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); // Set shipping information for this payment request $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); $directPaymentRequest->setShippingType($sedexCode); $directPaymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA'); // Set bank for this payment request $directPaymentRequest->setOnlineDebit(array("bankName" => 'ITAU')); try { /** * #### Credentials ##### * Replace the parameters below with your credentials * You can also get your credentials from a config file. See an example: * $credentials = PagSeguroConfig::getAccountCredentials(); */ // seller authentication $credentials = new PagSeguroAccountCredentials("*****@*****.**", "E231B2C9BCC8474DA2E260B6C8CF60D3"); // application authentication //$credentials = PagSeguroConfig::getApplicationCredentials(); //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. $return = $directPaymentRequest->register($credentials); self::printTransactionReturn($return); } catch (PagSeguroServiceException $e) { die($e->getMessage()); } }