lundi 29 octobre 2018

How to configure Payu's RESPONSE and CONFIRMATION routes to update a database with PHP - LARAVEL?

I am integrating the payment gateway PAYU webcheckout.

I can now send the purchase data to the payu platform through the form provided by payu webcheckout in the documentation. It's the next ...

<form method="post" action="https://sandbox.checkout.payulatam.com/ppp-web-gateway-payu/">
    <input name="merchantId"    type="hidden"  value="">
    <input name="accountId"     type="hidden"  value="" >
    <input name="description"   type="hidden"  value="">
    <input name="referenceCode" type="hidden"  value="" >
    <input name="amount"        type="hidden"  value=""   >
    <input name="tax"           type="hidden"  value=""  >
    <input name="taxReturnBase" type="hidden"  value="" >
    <input name="currency"      type="hidden"  value="" >
    <input name="signature"     type="hidden"  value=""  >
    <input name="test"          type="hidden"  value="" >
    <input name="buyerFullName" type="hidden"  value="" >
    <input name="buyerEmail"    type="hidden"  value="" >
    <input name="telephone"    type="hidden"  value="" >
    <input name="shippingAddress" type="hidden"  value="" >
    <input name="shippingCity"  type="hidden"  value="" >
    <input name="shippingCountry" type="hidden"  value="" >
    <input name="responseUrl"   type="hidden"  value="" >
    <input name="confirmationUrl" type="hidden"  value="" >

    <section class="payment_proceso_tarjeta tarjeta_form_btn_payu">
        <button type="submit" class="btn_datos_envio">
            Pagar con 
            <img class="logo_payu" src="">
        </button>
    </section>

These are my routes in Laravel.

Route::get('/response', 'ConfirmationController@response');

Route::post('/confirmation', 'ConfirmationController@confirmation');

Once the payu platform makes the payment verification, it sends me the data of the reply to the RESPONSE and CONFIRMATION routes, the user will be able to return to my store from a button that facilitates PAYU. The data that is sent to CONFIRMATION is sent with the POST method, with this data I can update my database. I get these data in the following way ...

public function confirmation(Request $request) {

    $reference_sale = $request['reference_sale'];
    $reference_pol = $request['reference_pol'];
    $transaction_id = $request['transaction_id'];
    $state_pol = $request['state_pol'];


    if($state_pol == 4) {
        App\Pedido::create([ 
          'id_user' => Auth::user()->id,
          'comprador' => $nickname_buyer,
          'ref_venta' => $reference_sale,
          'direccion_envio' => $shipping_city,
          'modo_pago' => $payment_method_name,
          'codigo_descuento' => session('codigos_usados'),
          'modo_envio' => session('entrega_pedido'),
          'estado_pedido' => $state_pol,
          'fecha_pedido' => date('Y-n-j H:i:s')
        ]);

    }
}

It is supposed that with that I should update the database, it also tells me that this URL must be PUBLIC, I have the store in Heroku. Then I do not know why it does not work.




Aucun commentaire:

Enregistrer un commentaire