Jump to content

payment handler Pagseguro


Tomie Nagamatsu

Recommended Posts

hi, any way to make payment handler with pagseguro?

pagseguro is like "paypal" here on brazil, they have bibliotecs in php,  this is a code for createPaymentRequest, is too hard to implement on jreviews?

 

**
* Class with a main method to illustrate the usage of the domain class PagSeguroPaymentRequest
*/
class createPaymentRequest {

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("REF1234");

	// Sets shipping information for this payment request
	$CODIGO_SEDEX = PagSeguroShippingType::getCodeByType('SEDEX');
	$paymentRequest->setShippingType($CODIGO_SEDEX);
	$paymentRequest->setShippingAddress('01452002',  'Av. Brig. Faria Lima',  '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA');

	// Sets your customer information.
	$paymentRequest->setSender('João Comprador', '[email protected]', '11', '56273440');

	$paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br");

	try {

		/*
		* #### Crendencials ##### 
		* Substitute the parameters below with your credentials (e-mail and token)
		* You can also get your credentails from a config file. See an example:
		* $credentials = PagSeguroConfig::getAccountCredentials();
		*/			
		$credentials = new PagSeguroAccountCredentials("[email protected]", "your_token_here");


		// Register this payment request in PagSeguro, to obtain the payment URL for redirect your customer.
		$url = $paymentRequest->register($credentials);

		self::printPaymentUrl($url);

	} catch (PagSeguroServiceException $e) {
		die($e->getMessage());
	}

}

public static function printPaymentUrl($url) {
	if ($url) {
		echo "<h2>Criando requisição de pagamento</h2>";
		echo "<p>URL do pagamento: <strong>$url</strong></p>";
		echo "<p><a title=\"URL do pagamento\" href=\"$url\">Ir para URL do pagamento.</a></p>";
	}
}

}

createPaymentRequest::main();

?>

 

i tried to copy this on paypal handler, but  dont worked. any 1 already did it? wanna share? or sell?

thanks

Link to comment
×
×
  • Create New...