嗨我有点困惑。我正在使用沙盒凭据进行贝宝 api 调用。返回 ACK 是:成功。当我转到付款人或企业沙盒帐户时,没有处理任何交易。我进行了调试,看起来我正在填充所有字段,而且我认为如果某些字段丢失,则会引发错误。这是我正在使用的代码。
......
APIProfile apiProfile = ProfileFactory.createSignatureAPIProfile();
apiProfile.setAPIUsername(paypalAccount.getApiLogin());
apiProfile.setAPIPassword(paypalAccount.getApiPassword());
apiProfile.setSignature(paypalAccount.getApiSignature());
apiProfile.setEnvironment(paypalAccount.getApiEnvironment());
// caller
NVPCallerServices callerServices = new NVPCallerServices();
callerServices.setAPIProfile(apiProfile);
// encoder
NVPEncoder encoder = new NVPEncoder();
encoder.add(METHOD, METHOD_VALUE);
encoder.add(RETURNURL, paypalAccount.getReturnUrl());
encoder.add(CANCELURL, paypalAccount.getCancelUrl());
encoder.add(CURRENCYCODE, CURRENCYCODE_VALUE);
encoder.add(PAYMENTACTION, PAYMENTACTION_VALUE);
encoder.add(AMT, payment.getPaymentOrder().getPrice().toString());
encoder.add(L_NAME0, L_NAME0_VALUE);
encoder.add(L_AMT0, payment.getPaymentOrder().getPrice().toString());
// call
String NVPRequest = encoder.encode();
String NVPResponse = callerServices.call(NVPRequest);
NVPDecoder decoder = new NVPDecoder();
decoder.decode(NVPResponse);
String ack = decoder.get(ACK);
payment.setPaymentTransaction(decoder.get(TOKEN));
……
任何帮助都是极好的!