I have the following code to create a billing plan
string iClientID = "xxxxxx";
string iSecret = "yyyyyy";
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
string accessToken = new OAuthTokenCredential(iClientID, iSecret, sdkConfig).GetAccessToken();
APIContext apiContext = new APIContext(accessToken);
apiContext.Config = sdkConfig;
Plan xPlan = new Plan();
xPlan.name = "Billing Plan OneA";
xPlan.description = "Our first billing plan for testing";
xPlan.type = "INFINITE";
PaymentDefinition xPDef = new PaymentDefinition();
xPDef.name = "Payment Def One";
xPDef.type = "REGULAR";
xPDef.frequency_interval = "1";
xPDef.frequency = "MONTH";
xPDef.cycles = "0";
MerchantPreferences xPrefs = new MerchantPreferences();
xPrefs.cancel_url = "http://learnoogle.com";
xPrefs.return_url = "http://learnoogle.com?success";
Currency xPCUrr = new Currency();
xPCUrr.currency = "USD";
xPCUrr.value = "25.00";
xPDef.amount = xPCUrr;
List<PaymentDefinition> xDeffs = new List<PaymentDefinition>();
xDeffs.Add(xPDef);
xPlan.payment_definitions = xDeffs;
xPlan.merchant_preferences = xPrefs;
Plan cPLan = xPlan.Create(apiContext);
And I attempt to set the plan active with the following code
Patch xPatch = new Patch();
xPatch.op = "replace";
xPatch.path = "state";
xPatch.value = "ACTIVE";
PatchRequest yPatch = new PatchRequest();
yPatch.Add(xPatch);
cPLan.Update(apiContext, yPatch);
However this gives me a (400) Bad Request. {"name":"BUSINESS_VALIDATION_ERROR","details":[{"field":"validation_error","issue":"Invalid Path provided."}],"message":"Validation Error.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_VALIDATION_ERROR","debug_id":"01f0eb9aaaea0"}
Can anyone educate me on what I am doing wrong on this/
When updating a plan, you'll need to set the
Patch.value
property to a newPlan
object containing the fields you'd like to replace (setting thestate
toACTIVE
in this case). Also, you'll need to set thePatch.path
property to just"/"
.In your code, do the following: