mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-11 05:19:14 +00:00
arreglado problema pago bizum
A
This commit is contained in:
@ -195,6 +195,9 @@ public class RedsysService {
|
||||
public final long amountCents;
|
||||
public final String currency;
|
||||
public final Long cartId;
|
||||
public final String processedPayMethod; // Ds_ProcessedPayMethod
|
||||
public final String bizumIdOper; // Ds_Bizum_IdOper
|
||||
public final String authorisationCode; // Ds_AuthorisationCode
|
||||
|
||||
public RedsysNotification(Map<String, Object> raw) {
|
||||
this.raw = raw;
|
||||
@ -203,6 +206,9 @@ public class RedsysService {
|
||||
this.currency = str(raw.get("Ds_Currency"));
|
||||
this.amountCents = parseLongSafe(raw.get("Ds_Amount"));
|
||||
this.cartId = extractCartId(raw.get("Ds_MerchantData"));
|
||||
this.processedPayMethod = str(raw.get("Ds_ProcessedPayMethod"));
|
||||
this.bizumIdOper = str(raw.get("Ds_Bizum_IdOper"));
|
||||
this.authorisationCode = str(raw.get("Ds_AuthorisationCode"));
|
||||
}
|
||||
|
||||
private static Long extractCartId(Object merchantDataObj) {
|
||||
@ -231,6 +237,11 @@ public class RedsysService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBizum() {
|
||||
// Redsys suele usar 68 para Bizum; ajustable si tu banco usa otro código.
|
||||
return "68".equals(processedPayMethod);
|
||||
}
|
||||
|
||||
private static String str(Object o) {
|
||||
return o == null ? null : String.valueOf(o);
|
||||
}
|
||||
@ -245,7 +256,7 @@ public class RedsysService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicita a Redsys una devolución (TransactionType = 3)
|
||||
* Solicita a Redsys una devolución (TransactionType = 3)
|
||||
*
|
||||
* @param order El mismo Ds_Merchant_Order que se usó en el cobro.
|
||||
* @param amountCents Importe en céntimos a devolver.
|
||||
@ -308,7 +319,7 @@ public class RedsysService {
|
||||
|
||||
// Decodificar MerchantParameters de la respuesta
|
||||
Map<String, Object> decoded = decodeMerchantParametersToMap(dsMerchantParametersResp);
|
||||
|
||||
|
||||
String dsResponse = String.valueOf(decoded.get("Ds_Response"));
|
||||
if (!"0900".equals(dsResponse)) {
|
||||
throw new IllegalStateException("Devolución rechazada, Ds_Response=" + dsResponse);
|
||||
@ -317,5 +328,4 @@ public class RedsysService {
|
||||
return String.valueOf(decoded.getOrDefault("Ds_AuthorisationCode", order));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user