0
我有一个外部paiement应用服务谁照顾我的购物应用paiements。两种方式发布形式
我有一个表单方法发布到服务发送数据和服务valide支付交易。
<form method="POST" action="https://paiement.systempay.fr/vads-payment/">
...
<input type="submit" name="payer" value="Payer"/></form>
</form>
我想从我的支付控制器还张贴请求方法来更新我的项目谁支付
这里我控制器的心愿我想运行时的“大户”也是用户点击
public function postCheckoutCreditCard(Request $request)
{
if(!Session::has('Cart')){
return view('shop.panier');
}
$oldCart = Session::get('Cart') ;
$cart = new Cart($oldCart);
$items = $cart->items;
if(Input::get('payer')) {
// on inject le nouveau statut de la licence
foreach ($items as $item) {
$item['item']->statut_licence_id = LicenceStatut::where('id', '4')->firstOrFail()->id;
$item['item']->valid_licence_id = LicenceValid::where('id', '1')->firstOrFail()->id;
$item['item']->save();
}
$order = new Order;
$prefix = 'F';
$date = Carbon::now();
$saison = Saison::where('dt_deb', '<', $date)->where('dt_fin', '>', $date)->value('lb_saison');
$saison_deb = substr($saison, 2, 2);
$saison_fin = substr($saison, -2);
$num_facture_exist = true;
while ($num_facture_exist) {
$num_facture = $prefix . $saison_deb . $saison_fin . substr(uniqid(rand(), true), 4, 4);
if (!Order::where('num_facture', '=', $num_facture)->exists()) {
$order->num_facture = $num_facture;
$num_facture_exist = false;
}
}
$order->structure_id = Structure::where(['id' => Auth::user()->structure->id])->firstOrFail()->id;
$order->cart = serialize($cart);
$order->date_achat = Carbon::now();
$order->payment_method = 'Carte de Crédit';
$order->etat_paiement = 'Facture Réglée';
$order->save();
Auth::user()->notify(new InvoicePaid($order));
$federation = Structure::where('id', '1')->first();
Mail::to($federation->adresse_email_structure)->send(new NouvelleCommande($order));
Session::forget('Cart');
return redirect('home')->with('status', "Votre paiement à été effectué avec sucess , votre numéro de facture : . $order->num_facture est disponible dans la rubrique Mes cotisation ");
}
}
我不知道如何做到这一点。有人可以帮助我吗?在此先感谢
您确定要这么做吗?如果向外部服务付款失败怎么办?通常,这些服务支持在完成处理请求时获取回调URL。 – apokryfos
是的,这正是我要做的!我会问他们。但我确定那 –
有一个服务在外部应用程序中,当payement被接受时重定向到一个url你认为如果我把url访问到方法public function postCheckoutCreditCard(Request $ request)它会工作? –