简体   繁体   中英

PayPal-Java-SDK & Google App Engine - Subscription Reflection Error

I am trying to create a PayPal Subscription on Google App Engine using the PayPal-Java-SDK. I have a slight variation of the code in this link implemented, but I am getting the exception below when calling the Plan.update after creating the PATCH object.

java.lang.SecurityException: java.lang.IllegalAccessException: Reflection is not allowed on protected java.lang.String java.net.HttpURLConnection.method

After updating the code to use "context.usingGoogleAppEngine(true);", I get a new message:

Invalid HTTP method: PATCH

So I am assuimg the usingGoogleAppEngine disables the use of Reflection, but still doesn't allow the PATCH operation to occur... which is necessary to change the state of the Payment Plan in PayPal.

Here is the code block:

public Plan update(APIContext context, Plan plan) throws PayPalRESTException, IOException 
{
    List<Patch> patchRequestList = new ArrayList<Patch>();
    Map<String, String> value = new HashMap<String, String>();
    value.put("state", "ACTIVE");

    Patch patch = new Patch();

    patch.setPath("/");
    patch.setValue(value);
    patch.setOp("replace");
    patchRequestList.add(patch);

    try{
        plan.update(context, patchRequestList);
    }
    catch (PayPalRESTException e) {
        log.warning("PayPalRESTException!: " + e.getMessage());
    }
    System.out.println("updated. now returning.");

    return plan;
}

Lastly, I created an issue in the log with the SDK here

最终于2017年1月31日修复: https//github.com/paypal/PayPal-Java-SDK/issues/262

I don't see import statement for Patch in your git hub file. Can you please try to import patch from PayPal package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM