#I8VQM7 paypal webhook回调验签问题

This commit is contained in:
egan
2024-01-13 19:45:08 +08:00
parent 7c76dd206a
commit 2b47bf95cb
3 changed files with 22 additions and 6 deletions

View File

@@ -16,6 +16,12 @@ public class PayPalConfigStorage extends BasePayConfigStorage {
private String clientId;
/**
* 回调验签使用
*/
private String webHookId;
@Override
@Deprecated
public String getAppid() {
@@ -86,7 +92,6 @@ public class PayPalConfigStorage extends BasePayConfigStorage {
* 获取取消页面的url
* <pre>
* 注意:这里不是异步回调的通知
* IPN 地址设置的路径https://developer.paypal.com/developer/ipnSimulator/
* </pre>
*
* @return 取消页面的url
@@ -98,4 +103,12 @@ public class PayPalConfigStorage extends BasePayConfigStorage {
public PayPalConfigStorage() {
setAccessTokenLock(new ReentrantLock());
}
public String getWebHookId() {
return webHookId;
}
public void setWebHookId(String webHookId) {
this.webHookId = webHookId;
}
}

View File

@@ -62,7 +62,7 @@ import com.egzosn.pay.paypal.v2.utils.PayPalUtil;
* 贝宝支付配置存储
*
* @author egan
*
* <p>
* email egzosn@gmail.com
* date 2021-1-16 22:15:09
*/
@@ -177,6 +177,7 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> implem
/**
* 保留IPN的校验方式
*
* @param noticeParams 参数
* @return 结果
*/
@@ -191,6 +192,7 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> implem
return "VERIFIED".equals(resp);
}
@Override
public boolean verify(NoticeParams noticeParams) {
@@ -208,8 +210,7 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> implem
}
InputStream inputStream = clientCertificateResponseEntity.getBody();
Collection<X509Certificate> clientCerts = PayPalUtil.getCertificateFromStream(inputStream);
Map<String, Object> body = noticeParams.getBody();
String webHookId = (String) body.get(Constants.ID);
String webHookId = payConfigStorage.getWebHookId();
String actualSignatureEncoded = noticeParams.getHeader(Constants.PAYPAL_HEADER_TRANSMISSION_SIG);
String authAlgo = noticeParams.getHeader(Constants.PAYPAL_HEADER_AUTH_ALGO);
String transmissionId = noticeParams.getHeader(Constants.PAYPAL_HEADER_TRANSMISSION_ID);
@@ -466,7 +467,7 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> implem
@Override
public Map<String, Object> ordersCapture(String tradeNo) {
final HttpHeader header = authHeader();
header.addHeader(new BasicHeader("Content-Type","application/json"));
header.addHeader(new BasicHeader("Content-Type", "application/json"));
JSONObject ordersCaptureInfo = getHttpRequestTemplate().postForObject(getReqUrl(PayPalTransactionType.ORDERS_CAPTURE), header, JSONObject.class, tradeNo);
// String captureId = ordersCaptureInfo.getJSONArray("purchaseUnits").getJSONObject(0).getJSONObject("payments").getJSONArray("captures").getJSONObject(0).getString("id");
return ordersCaptureInfo;