Search in sources :

Example 1 with NVPCallerServices

use of com.paypal.sdk.services.NVPCallerServices 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;
}
Also used : NVPCallerServices(com.paypal.sdk.services.NVPCallerServices) NVPDecoder(com.paypal.sdk.core.nvp.NVPDecoder) APIProfile(com.paypal.sdk.profiles.APIProfile) PayPalException(com.paypal.sdk.exceptions.PayPalException)

Aggregations

NVPDecoder (com.paypal.sdk.core.nvp.NVPDecoder)1 PayPalException (com.paypal.sdk.exceptions.PayPalException)1 APIProfile (com.paypal.sdk.profiles.APIProfile)1 NVPCallerServices (com.paypal.sdk.services.NVPCallerServices)1