Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
01de6697
Commit
01de6697
authored
May 17, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notificaciones de pagos
parent
a0774dcc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
167 additions
and
0 deletions
+167
-0
CartController.php
src/controllers/CartController.php
+20
-0
PaymentClient.php
src/notifications/PaymentClient.php
+72
-0
PaymentClientCard.php
src/notifications/PaymentClientCard.php
+75
-0
No files found.
src/controllers/CartController.php
View file @
01de6697
...
@@ -15,6 +15,9 @@ use Onestartup\Shop\Model\SaleShop as Sale;
...
@@ -15,6 +15,9 @@ use Onestartup\Shop\Model\SaleShop as Sale;
use
Onestartup\Shop\Model\DetailShop
as
Item
;
use
Onestartup\Shop\Model\DetailShop
as
Item
;
use
Onestartup\Shop\Payment\MP
;
use
Onestartup\Shop\Payment\MP
;
use
Onestartup\Shop\Notifications\PaymentClient
;
use
Onestartup\Shop\Notifications\PaymentClientCard
;
class
CartController
extends
Controller
class
CartController
extends
Controller
{
{
public
function
__construct
()
public
function
__construct
()
...
@@ -234,6 +237,8 @@ class CartController extends Controller
...
@@ -234,6 +237,8 @@ class CartController extends Controller
$items
=
$sale
->
items
;
$items
=
$sale
->
items
;
$addres
=
$client
->
shipping
;
$addres
=
$client
->
shipping
;
$detail
=
''
;
$detail
=
''
;
$status
=
''
;
$user
=
\App\User
::
first
();
foreach
(
$sale
->
items
as
$item
)
{
foreach
(
$sale
->
items
as
$item
)
{
...
@@ -262,11 +267,14 @@ class CartController extends Controller
...
@@ -262,11 +267,14 @@ class CartController extends Controller
$sale
->
status
=
2
;
$sale
->
status
=
2
;
$sale
->
transaction_id
=
$payment
[
'response'
][
'id'
];
$sale
->
transaction_id
=
$payment
[
'response'
][
'id'
];
$sale
->
save
();
$sale
->
save
();
$status
=
'Aprobado'
;
\Session
::
forget
(
'client'
);
\Session
::
forget
(
'client'
);
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'sale'
);
\Session
::
forget
(
'sale'
);
$user
->
notify
(
new
PaymentClientCard
(
$client
,
$request
->
paymentMethodId
,
$status
));
return
redirect
()
return
redirect
()
->
route
(
'main.shop'
)
->
route
(
'main.shop'
)
->
with
(
'payment_approved'
,
'payment_approved'
);
->
with
(
'payment_approved'
,
'payment_approved'
);
...
@@ -276,17 +284,23 @@ class CartController extends Controller
...
@@ -276,17 +284,23 @@ class CartController extends Controller
$sale
->
status
=
3
;
$sale
->
status
=
3
;
$sale
->
transaction_id
=
$payment
[
'response'
][
'id'
];
$sale
->
transaction_id
=
$payment
[
'response'
][
'id'
];
$sale
->
save
();
$sale
->
save
();
$status
=
'En proceso'
;
\Session
::
forget
(
'client'
);
\Session
::
forget
(
'client'
);
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'sale'
);
\Session
::
forget
(
'sale'
);
$user
->
notify
(
new
PaymentClientCard
(
$client
,
$request
->
paymentMethodId
,
$status
));
return
redirect
()
return
redirect
()
->
route
(
'main.shop'
)
->
route
(
'main.shop'
)
->
with
(
'payment_pending'
,
'payment_pending'
);
->
with
(
'payment_pending'
,
'payment_pending'
);
}
else
{
}
else
{
$status
=
'Rechazado'
;
$user
->
notify
(
new
PaymentClientCard
(
$client
,
$request
->
paymentMethodId
,
$status
));
return
redirect
()
return
redirect
()
->
back
()
->
back
()
->
with
(
'payment_reject'
,
'payment_reject'
);
->
with
(
'payment_reject'
,
'payment_reject'
);
...
@@ -294,6 +308,9 @@ class CartController extends Controller
...
@@ -294,6 +308,9 @@ class CartController extends Controller
}
}
//dd($payment);
//dd($payment);
...
@@ -351,6 +368,9 @@ class CartController extends Controller
...
@@ -351,6 +368,9 @@ class CartController extends Controller
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'sale'
);
\Session
::
forget
(
'sale'
);
$user
=
\App\User
::
first
();
$user
->
notify
(
new
PaymentClient
(
$request
->
payment_id
,
$client
));
return
redirect
()
return
redirect
()
->
route
(
'main.shop'
)
->
route
(
'main.shop'
)
...
...
src/notifications/PaymentClient.php
0 → 100644
View file @
01de6697
<?php
namespace
Onestartup\Shop\Notifications
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Notifications\Notification
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Notifications\Messages\MailMessage
;
use
Onestartup\Shop\Model\ClientShop
as
Client
;
class
PaymentClient
extends
Notification
{
use
Queueable
;
protected
$tipo
;
protected
$client
;
/**
* Create a new notification instance.
*
* @return void
*/
public
function
__construct
(
$tipo
,
Client
$client
)
{
$this
->
tipo
=
$tipo
;
$this
->
client
=
$client
;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public
function
via
(
$notifiable
)
{
return
[
'mail'
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public
function
toMail
(
$notifiable
)
{
return
(
new
MailMessage
)
->
greeting
(
'¡Hola!'
)
->
subject
(
'Ficha pago en efectivo en '
.
env
(
'APP_NAME'
))
//->replyTo($this->interested->email, $this->interested->name)
->
line
(
'Se ha generado una ficha de deposito en efectivo'
)
->
line
(
'Tipo de ficha: '
.
$this
->
tipo
)
->
line
(
'Datos del cliente:'
)
->
line
(
'Nombre: '
.
$this
->
client
->
name
.
' '
.
$this
->
client
->
lastname
)
->
line
(
'Telefono: '
.
$this
->
client
->
phone
)
->
line
(
'Correo: '
.
$this
->
client
->
email
);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public
function
toArray
(
$notifiable
)
{
return
[
//
];
}
}
src/notifications/PaymentClientCard.php
0 → 100644
View file @
01de6697
<?php
namespace
Onestartup\Shop\Notifications
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Notifications\Notification
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Notifications\Messages\MailMessage
;
use
Onestartup\Shop\Model\ClientShop
as
Client
;
class
PaymentClientCard
extends
Notification
{
use
Queueable
;
protected
$tipo
;
protected
$client
;
protected
$status
;
/**
* Create a new notification instance.
*
* @return void
*/
public
function
__construct
(
Client
$client
,
$tipo
,
$status
)
{
$this
->
tipo
=
$tipo
;
$this
->
client
=
$client
;
$this
->
status
=
$status
;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public
function
via
(
$notifiable
)
{
return
[
'mail'
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public
function
toMail
(
$notifiable
)
{
return
(
new
MailMessage
)
->
greeting
(
'¡Hola!'
)
->
subject
(
'Pago con tarjeta en '
.
env
(
'APP_NAME'
))
//->replyTo($this->interested->email, $this->interested->name)
->
line
(
'Se ha generado un pago con tarjeta'
)
->
line
(
'Tipo de tarjeta: '
.
$this
->
tipo
)
->
line
(
'Estatus de la transacción: '
.
$this
->
status
)
->
line
(
'Datos del cliente:'
)
->
line
(
'Nombre: '
.
$this
->
client
->
name
.
' '
.
$this
->
client
->
lastname
)
->
line
(
'Telefono: '
.
$this
->
client
->
phone
)
->
line
(
'Correo: '
.
$this
->
client
->
email
);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public
function
toArray
(
$notifiable
)
{
return
[
//
];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment