-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cambiando permisos en linux. Se agrego el sdk de paypal y se realizo …
…el cobro del producto del carrito de compra. Creando el modelo PayPal en el cual se genera el cobro de los productos y retornando la informacion en el controlador PaymentsController
- Loading branch information
Showing
139 changed files
with
1,080 additions
and
129 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\PayPal; | ||
use App\ShoppingCart; | ||
|
||
class PaymentsController extends Controller | ||
{ | ||
public function store(Request $request) | ||
{ | ||
$shopping_cart_id = \Session::get('shopping_cart_id'); | ||
|
||
$shopping_cart = ShoppingCart::findOrCreateBySessionID($shopping_cart_id ); | ||
|
||
$paypal = new PayPal($shopping_cart); | ||
|
||
dd($paypal->execute($request->paymentId, $request->PayerID)); | ||
|
||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
namespace App; | ||
|
||
/** | ||
* | ||
*/ | ||
class PayPal | ||
{ | ||
private $_apiContext; | ||
private $shopping_cart; | ||
private $_ClienteId = 'AVcxxcMEiJnLeivSW8LKdM9y8K09kR6OwJPP2kn-GZL0GDASiW2N3LXDnQc6ftboInfQydcZeLkLF9QL'; | ||
private $_ClienteSecret = 'EL6tZsslqnpp9Q-MtIwp55ixIRrRKVnMV7BoUpEPJA0bqOf6lMouZJDJ8c-JGBg4tA2dfuYeR8IBVhIm'; | ||
|
||
public function __construct($shopping_cart) | ||
{ | ||
$this->_apiContext = \Paypalpayment::apiContext($this->_ClienteId, $this->_ClienteSecret); | ||
$config = config("paypal_payment"); | ||
$flatConfig = array_dot($config); | ||
$this->_apiContext->setConfig($flatConfig); | ||
$this->shopping_cart = $shopping_cart; | ||
} | ||
|
||
public function generate() | ||
{ | ||
$payment = \Paypalpayment::payment()->setIntent('sale') | ||
->setPayer($this->payer()) | ||
->setTransactions([$this->transaction()]) | ||
->setRedirectUrls($this->redirectURLs()); | ||
|
||
try { | ||
$payment->create($this->_apiContext); | ||
} catch (\Exception $e) { | ||
dd($e); | ||
exit(1); | ||
} | ||
return $payment; | ||
|
||
} | ||
|
||
public function payer() | ||
{ | ||
//return payment Information | ||
return \Paypalpayment::payer()->setPaymentMethod('paypal'); | ||
} | ||
public function redirectURLs() | ||
{ | ||
$baseURL = url('/'); | ||
return \Paypalpayment::redirectUrls() | ||
->setReturnUrl("$baseURL/payments/store") | ||
->setCancelUrl("$baseURL/carrito"); | ||
|
||
|
||
} | ||
public function transaction() | ||
{ | ||
return \Paypalpayment::transaction()->setAmount($this->amount()) | ||
->setItemList($this->items()) | ||
->setDescription("Tu compra en programacion jje") | ||
->setInvoiceNumber(uniqid()); | ||
} | ||
public function items() | ||
{ | ||
$items = []; | ||
$products = $this->shopping_cart->productos()->get(); | ||
foreach ($products as $product) { | ||
array_push($items, $product->paypalItem()); | ||
} | ||
return \Paypalpayment::itemList()->setItems($items); | ||
} | ||
public function amount() | ||
{ | ||
return \Paypalpayment::amount()->setCurrency('USD') | ||
->setTotal($this->shopping_cart->totalUSD()); | ||
} | ||
|
||
public function execute($paymentId, $payerId) | ||
{ | ||
$payment = \Paypalpayment::getById($paymentId, $this->_apiContext); | ||
|
||
$execution = \Paypalpayment::PaymentExecution()->setPayerId($payerId); | ||
|
||
return $payment->execute($execution, $this->_apiContext); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.