PHP code example of resultsystems / laravel-paypal
1. Go to this page and download the library: Download resultsystems/laravel-paypal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
resultsystems / laravel-paypal example snippets
/**
* Faz nova requisição
* informando o número da fatura 15
* usuario, senha e assinatura serão pegos das configurações
*/
$paypal = new \ResultSystems\Paypal\Services\PaypalRequestService(15);
/*($quantity, $name, $description, $amount, $item_amount = null)*/
$paypal->addItem(new \ResultSystems\Paypal\PaypalItem('1.0', 'teste', 'xxx asdkflj daljkdfaslçkfj asdçlkfjsdalçfsd', '150'))
->setItem('1', 'teste 2', 'xxx 2', '39');
/**
* Executa a closure
* após o processo de verificar os items
* cabendo a closure redirecionar e fazer as demais coisas
*/
return $paypal->checkout(function ($response) {
dd($response);
});
return $paypal->getCheckoutUrl(function ($response) {
dd($response);
});
/**
* Faz nova requisição
* informando o número da fatura 15
* usuario, senha e assinatura serão pegos das configurações
*/
$paypal = new \ResultSystems\Paypal\Services\PaypalRequestService(15);
/*($quantity, $name, $description, $amount, $item_amount = null)*/
$paypal->setSandbox()->addItem(new \ResultSystems\Paypal\PaypalItem('1.0', 'teste', 'xxx asdkflj daljkdfaslçkfj asdçlkfjsdalçfsd', '150'))
->addItem(new \ResultSystems\Paypal\PaypalItem('1', 'teste 2', 'xxx 2', '39'));
/*Vai para o checkout direto*/
return $paypal->checkout();
$paypal = new \ResultSystems\Paypal\Services\PaypalRequestService;
$transactionId=$_POST["transactionId"];
$note="Motivo de devolução do valor opcional aqui";
try
{
$id=$paypal->refundFull($transactionId, $note);
echo 'transação estornada com sucesso!, id estorno: '.$id;
} catch(\ResultSystems\Paypal\Exceptions\PaypalRequestException $e){
echo 'transação não foi estornada, houve uma falha: '.$e->getMessage();
}
$paypal = new \ResultSystems\Paypal\Services\PaypalRequestService;
$transactionId=$_POST["transactionId"];
$amount=$_POST['amount'];
$note="Motivo de devolução do valor opcional aqui";
try
{
$id=$paypal->refundPartial($transactionId, $note, $amount);
echo 'transação estornada com sucesso!, id estorno: '.$id;
} catch(\ResultSystems\Paypal\Exceptions\PaypalRequestException $e){
echo 'transação não foi estornada, houve uma falha: '.$e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.