use of com.paypal.sdk.profiles.APIProfile in project ofbiz-framework by apache.
the class PayPalServices method sendNVPRequest.
private static NVPDecoder sendNVPRequest(GenericValue payPalConfig, NVPEncoder encoder) throws PayPalException {
NVPCallerServices caller = new NVPCallerServices();
try {
APIProfile profile = ProfileFactory.createSignatureAPIProfile();
profile.setAPIUsername(payPalConfig.getString("apiUserName"));
profile.setAPIPassword(payPalConfig.getString("apiPassword"));
profile.setSignature(payPalConfig.getString("apiSignature"));
profile.setEnvironment(payPalConfig.getString("apiEnvironment"));
caller.setAPIProfile(profile);
} catch (PayPalException e) {
Debug.logError(e.getMessage(), module);
}
String requestMessage = encoder.encode();
String responseMessage = caller.call(requestMessage);
NVPDecoder decoder = new NVPDecoder();
decoder.decode(responseMessage);
if (!"Success".equals(decoder.get("ACK"))) {
Debug.logError("A response other than success was received from PayPal: " + responseMessage, module);
}
return decoder;
}
Aggregations