I´m traying integrate Redsys API in my app. All Api it´s integrated but my question it´s that in my project i need open form redsys in modal with iframe. In my controller i have all my code to create a petition to servers and return a form:
<form action="https://sis.redsys.es/sis/realizarPago" method="post" id="redsys_form" name="redsys_form" >
<input type="hidden" name="Ds_MerchantParameters" value="eyJEU19NRVJDSEFOVF9BTU9VTlQiOjEzOTkwMCwiRFNfTUVSQ0hBTlRfT1JERVIiOiIyMjAyMDIyMDAwMzciLCJEU19NRVJDSEFOVF9NRVJDSEFOVENPREUiOiI2NjgyODc5OSIsIkRTX01FUkNIQU5UX0NVUlJFTkNZIjoiOTc4IiwiRFNfTUVSQ0hBTlRfVFJBTlNBQ1RJT05UWVBFIjoiMCIsIkRTX01FUkNIQU5UX1RFUk1JTkFMIjoiMSIsIkRTX01FUkNIQU5UX1BBWU1FVEhPRFMiOiJUIiwiRFNfTUVSQ0hBTlRfTUVSQ0hBTlRVUkwiOiJodHRwczpcL1wvaW50cmFuZXQuZ3J1cG9kZWx1eGUuY29tXC9yZWRpcmVjY2lvbmVzXC9ub3RpZmljYXRpb24/aWRlbj1kMWYyN2Q0YWVlMGFjN2E3JmRhdGU9TWpBeU1pMHdNeTB4TmlBeE5qb3lNVG8xTlElM0QlM0QiLCJEU19NRVJDSEFOVF9VUkxPSyI6Imh0dHBzOlwvXC9pbnRyYW5ldC5ncnVwb2RlbHV4ZS5jb21cL2FkbWluXC9yZWRyZWRzeXNcL3VybG9rP2lkZW49ZDFmMjdkNGFlZTBhYzdhNyZkYXRlPU1qQXlNaTB3TXkweE5pQXhOam95TVRvMU5RJTNEJTNEIiwiRFNfTUVSQ0hBTlRfVVJMS08iOiJodHRwczpcL1wvaW50cmFuZXQuZ3J1cG9kZWx1eGUuY29tXC9hZG1pblwvcmVkcmVkc3lzXC91cmxrbz9pZGVuPWQxZjI3ZDRhZWUwYWM3YTcmZGF0ZT1NakF5TWkwd015MHhOaUF4TmpveU1UbzFOUSUzRCUzRCIsIkRTX01FUkNIQU5UX01FUkNIQU5UTkFNRSI6IkVESUNJT05FUyBHUlVQTyBERUxVWEUiLCJEU19NRVJDSEFOVF9USVRVTEFSIjoiTUFSVElORVogSklNRU5FWiBNQVJJQSBMVUlTQSIsIkRTX01FUkNIQU5UX1BST0RVQ1RERVNDUklQVElPTiI6IlBhZ28gY29tcGxldG8ifQ=="/>
<input type="hidden" name="Ds_Signature" value="jWWSm5xrRjxo0LoD4joa6mrBgw4rMg1t8/2nTWAjgjs="/>
<input type="hidden" name="Ds_SignatureVersion" value="HMAC_SHA256_V1"/>
<input type="submit" name="btn_submit" id="btn_submit" value="Send" >
</form>
<script>document.forms["redsys_form"].submit();</script>
this code i need open in my iframe by POST
method, but src it´s invalid... In my controller i have this:
public function store(Request $request)
{
$importe = $request->get('importe');
$nomape = $request->get('nomape');
$desc = 'Pago completo';
$importe = str_replace(',', '.', $importe);
$pago = PagoTarjeta::create([
'iden' => bin2hex(random_bytes(8)),
'nomape' => $nomape,
'importe'=> $importe,
'desc' => $desc,
'id_empleado' => auth()->user()->id,
'id_estado' => 1,
'id_precontrato' => $request->has('_id_precontrato') ? $request->_id_precontrato : null
]);
/*if(!$pago) {
return redirect()->route('admin.pago_tarjeta.index')->withErrors('pago_tarjeta', 'No se ha podido crear la transacción correctamente..');
}*/
$pago->update(['norder' => config('redsys.serie.PT').str_pad($pago->id, 10, 0, STR_PAD_LEFT)]);
try {
$key = config('redsys.key');
Redsys::setAmount($importe);
Redsys::setOrder($pago->norder);
Redsys::setMerchantcode(config('redsys.merchantcode')); //Reemplazar por el código que proporciona el banco
Redsys::setCurrency(config('redsys.currency'));
Redsys::setTransactiontype('0');
Redsys::setTerminal('1');
Redsys::setMethod('T'); //Solo pago con tarjeta, no mostramos iupay
$esto = Redsys::setNotification(route('redirecciones.notification', [
'iden' => $pago->iden,
'date' => base64_encode($pago->created_at)
])); //Url de notificacion
Redsys::setUrlOk(route('admin.redredsys.urlok', [
'iden' => $pago->iden,
'date' => base64_encode($pago->created_at)
])); //Url OK
Redsys::setUrlKo(route('admin.redredsys.urlko', [
'iden' => $pago->iden,
'date' => base64_encode($pago->created_at)
])); //Url KO
Redsys::setVersion(config('redsys.version'));
Redsys::setTradeName(config('redsys.tradename'));
Redsys::setTitular($nomape);
Redsys::setProductDescription($desc);
Redsys::setEnviroment('live'); //Entorno test
$signature = Redsys::generateMerchantSignature($key);
$merchantSignature = Redsys::setMerchantSignature($signature);
$form = Redsys::executeRedirection();
}
catch(Exception $e){
echo $e->getMessage();
}
return $form;
}
i need open this web in my modal:
This img it´s sending my form with POST and PHP not javascript.
Thanks to read me, and sorry for my bad english
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire