I am using the .NET API for Recurly, and I am trying to add an addon to a subscription. Here is my code that I used to create the addon:
var addOnReq = new AddOnCreate()
{
Code = "myCode",
Name = "myName",
DefaultQuantity = 1,
Currencies = new List<AddOnPricing>() {
new AddOnPricing() {
Currency = "USD",
UnitAmount = 100,
UnitAmountDecimal = "100.00"
}
}
};
AddOn addOn = RecurlyClient.CreatePlanAddOn("myPlanId", addOnReq);
And here is the code I am trying to execute when adding the addon to a subscription of the plan in which the addon was added:
var changeReq = new SubscriptionChangeCreate()
{
Timeframe = RecurlyConstants.ChangeTimeframe.Now,
AddOns = new List<SubscriptionAddOnUpdate>() {
new SubscriptionAddOnUpdate() {
Code = "myCode"
}
}
};
foreach (var addOnn in changeReq.AddOns)
{
addOnn.UnitAmount = 100;
}
SubscriptionChange change = RecurlyClient.CreateSubscriptionChange("mySubscriptionId", changeReq);
This is the error I get back in an exception:
Add-ons add on is invalid
What am I doing wrong? Any support is appreciated.
This is a fixed based add on. The recurly documentation is not proving to be helpful, I think.
Related
How do i create payment link to custom account via stripe.net library?
I have tried with these codes but its created product and payment link to my stripe connected account instead of custom account as i want.
// create payment link
var plinkOpt = new PaymentLinkCreateOptions
{
LineItems = new List<PaymentLinkLineItemOptions>
{
new PaymentLinkLineItemOptions
{
Price = new PriceService().Create(
new PriceCreateOptions
{
Currency = "usd",
Product = new ProductService().Create(new ProductCreateOptions { Name = "myproductname", }).Id,
CustomUnitAmount = new PriceCustomUnitAmountOptions { Enabled = true },
}).Id,
Quantity = 1,
},
},
};
var plinkSer = new PaymentLinkService();
plinkSer.Create(plinkOpt);
I hope to have codes to solve my problem or a solution to do it. Thank you
You need to set the StripeAccount in RequestOptions (API ref):
var options = new RequestOptions
{
StripeAccount = "acct_123"
};
plinkSer.Create(plinkOpt, options);
Edit: However, this should only be used with Standard accounts, not custom accounts.
I tried to update a list . I tried the code in debug mode , and the code was executed without any errors. But the value was not updated. Why would this be? I have shared the code below.
foreach (var r in respondents)
{
foreach(var v in completesMap.VendorView)
{
if(v.Value.Contains(r.Status))
{
r.Status=v.Key;
break;
}
}
}
completesMap.VendorView is a key-value pair which I hard-coded in appsettings.json file , respondents is a Dto
I have created an example using your code and it works.
You can see how it works at this link. You can also copy and paste that code to your IDE and debug it & see if it works at your machine also.
Working Code
List<Respondent> respondents = new List<Respondent>()
{
new Respondent { Status = "Active"},
new Respondent { Status = "Active"},
new Respondent { Status = "InActive"},
};
var completesMap = new Map
{
VendorView = new List<VendorView>()
{
new VendorView{ Value = "This is Active" , Key = "Key1" },
new VendorView{ Value = "this is not active", Key = "Key2" }
}
};
foreach (var r in respondents)
{
foreach (var v in completesMap.VendorView)
{
if (v.Value.Contains(r.Status))
{
r.Status = v.Key;
break;
}
}
}
var x = respondents[1].Status;
Debugger Output
I am pulling my hair out on this one. I am attempting to filter a saved search with a custom field of type SearchColumnSelectCustomField (see XML of record below).
How do I convert this type properly, or what am I doing wrong here?
I'm not sure what I'm missing, but the error I always eventually hit is:
"Cannot implicitly convert type
'NetSuite.com.netsuite.na1.webservices.SearchColumnSelectCustomField'
to 'NetSuite.com.netsuite.na1.webservices.SearchCustomField'
"
TransactionSearchAdvanced transSearchAdv = new TransactionSearchAdvanced
{
savedSearchScriptId = "customsearch_mycustomsearch"
};
SearchColumnSelectCustomField cwoNumField = new SearchColumnSelectCustomField();
cwoNumField.internalId = "custbody_consolidatedworkorder";
transSearchAdv.criteria = new TransactionSearch
{
basic = new TransactionSearchBasic
{
//Error Here, on cwoNumField
customFieldList = new SearchCustomField[]{ cwoNumField }
}
};
XML of search results, without filter criteria added:
<tranSales:basic xmlns:platformCommon="urn:common_2014_1.platform.webservices.netsuite.com">
<platformCommon:appliedToTransaction>
<platformCore:searchValue internalId="442671"/>
<platformCore:customLabel>SO #</platformCore:customLabel>
</platformCommon:appliedToTransaction>
<platformCommon:item>
<platformCore:searchValue internalId="315838"/>
</platformCommon:item>
<platformCommon:quantity>
<platformCore:searchValue>11.0</platformCore:searchValue>
</platformCommon:quantity>
<platformCommon:status>
<platformCore:searchValue>pendingBuild</platformCore:searchValue>
</platformCommon:status>
<platformCommon:transactionNumber>
<platformCore:searchValue>204</platformCore:searchValue>
<platformCore:customLabel>WO #</platformCore:customLabel>
</platformCommon:transactionNumber>
<platformCommon:customFieldList>
<platformCore:customField xsi:type="platformCore:SearchColumnBooleanCustomField" scriptId="custbody_buildcomplete" internalId="501">
<platformCore:searchValue>false</platformCore:searchValue>
</platformCore:customField>
/*********** field in question here *************/
<platformCore:customField xsi:type="platformCore:SearchColumnSelectCustomField" scriptId="custbody_consolidatedworkorder" internalId="500">
<platformCore:searchValue typeId="85" internalId="24"/>
<platformCore:customLabel>CWO #</platformCore:customLabel>
</platformCore:customField>
</platformCommon:customFieldList>
</tranSales:basic>
I'm not sure WHY, but this is the answer. Can someone explain why a SearchColumnSelectCustomField field is searched via SearchMultiSelectCustomField ?
TransactionSearchAdvanced transSearchAdv = new TransactionSearchAdvanced
{
savedSearchScriptId = "customsearch_woconsolidationsublist"
};
SearchMultiSelectCustomField cwoNumField = new SearchMultiSelectCustomField();
cwoNumField.scriptId = "custbody_consolidatedworkorder";
cwoNumField.#operator = SearchMultiSelectFieldOperator.anyOf;
cwoNumField.operatorSpecified = true;
cwoNumField.searchValue = new ListOrRecordRef[] { new ListOrRecordRef {internalId = "36"} };
transSearchAdv.criteria = new TransactionSearch
{
basic = new customFieldList = new SearchCustomField[] { cwoNumField }
}
};
I am using ebay .Net SDK. Everything is working fine except following requirements:
Using of OutputSelector to boost performance
Unable to use SortingOrder, while showing records.
Total income/amount sold for specified time range i.e. Total amount across all calls of the pagination without looping through pages and aggregating it manually.
Here is the code which I am using:
var apicall = new GetOrdersCall(context);
//apicall.ApiRequest.OutputSelector = new StringCollection(new String[] { "Order.OrderID", "Order.Total" });
apicall.ApiRequest.Pagination = new PaginationType
{
EntriesPerPage = Util.RecordsPerPage(),
PageNumber = int.Parse(Request.Form["pageNumber"])
};
var fltr = new TimeFilter(Convert.ToDateTime(Request.Form["dateFrom"] + "T00:00:00.000Z"), Convert.ToDateTime(Request.Form["dateTo"] + "T23:59:59.999Z"));
var statusCodeType = (OrderStatusCodeType)Enum.Parse(typeof(OrderStatusCodeType), Request.Form["statusCode"]);
var orders = apicall.GetOrders(fltr, TradingRoleCodeType.Seller, statusCodeType);
Please assist me how to use these 3 functionality as well.
After much efforts I got the way for it:
var request = new GetOrdersRequestType
{
//OutputSelector = new StringCollection {"OrderID","Total"},
CreateTimeFrom = Convert.ToDateTime(Request.Form["dateFrom"] + "T00:00:00.000Z"),
CreateTimeTo = Convert.ToDateTime(Request.Form["dateTo"] + "T23:59:59.999Z"),
OrderStatus = (OrderStatusCodeType)Enum.Parse(typeof(OrderStatusCodeType), Request.Form["statusCode"]),
OrderRole = TradingRoleCodeType.Seller,
Pagination = new PaginationType
{
EntriesPerPage = Util.RecordsPerPage(),
PageNumber = int.Parse(Request.Form["pageNumber"])
}
};
var apicall = new GetOrdersCall(context)
{
ApiRequest = request,
OutputSelector =
new string[]
{
"OrderID", "Total", "PaidTime", "eBayPaymentStatus",
"PaymentMethod", "Title", "PageNumber", "PaginationResult.TotalNumberOfPages"
}
};
apicall.Execute();
var orders = apicall.ApiResponse.OrderArray;
Let's say I have a workflow created progrmatically like this
ActivityBuilder<int> ab = new ActivityBuilder<int>();
ab.Name = "Add";
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand1", Type = typeof (InArgument<int>)});
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand2", Type = typeof (InArgument<int>)});
ab.Implementation = new Sequence
{
Activities =
{
new WriteLine
{
Text =
new VisualBasicValue<string>(
"Operand1.ToString() + \" + \" + Operand2.ToString()")
}
}
};
One way I know to execute it is to first serialize the ActivityBuilder object into XAML. Next, load the serialized XAML using ActivityXamlServices. Create a dictionary for parameters. Execute it using WorkflowInvoker or WorkflowApplication
Is there any way to execute this workflow without the need to convert/serialize activity builder to XAML?
WorkflowApplication and WorkflowInvoker takes an Activity as input for execution. Can I somehow use activityBuilder.Implementation directly with WorkflowApplication or WorkflowInvoker?
Why I want this? Because we have a workflow designer which user uses to create and execute workflow. User also creates workflow progrmatically. Workflow can be up to 80MB in size. This is hurting application's memory due to serialization and de-serialization of 80MB files to and from XAML. I want to somehow skip this step and directly execute activity.
Does it makes sense?
No need to use an ActivityBuilder, just create the activities you want and execute them.
var wf = new Sequence()
{
Variables =
{
new Variable<int>("Operand1", 7),
new Variable<int>("Operand2", 42)
},
Activities =
{
new WriteLine
{
Text =
new VisualBasicValue<string>(
"Operand1 & \" + \" & Operand2")
}
}
};
WorkflowInvoker.Invoke(wf);
An example using DynamicActivityProperty:
var wf = new DynamicActivity<int>
{
Properties =
{
new DynamicActivityProperty { Name = "Operand1", Type = typeof(InArgument<int>) },
new DynamicActivityProperty { Name = "Operand2", Type = typeof(InArgument<int>) }
},
Implementation = () => new Sequence()
{
Activities =
{
new WriteLine
{
Text =
new VisualBasicValue<string>(
"Operand1 & \" + \" & Operand2")
},
new Assign<int>
{
To = new ArgumentReference<int> { ArgumentName = "Result" },
Value = new VisualBasicValue<int>("Operand1 + Operand2")
}
}
}
};
var inputs = new Dictionary<string, object>();
inputs["Operand1"] = 7;
inputs["Operand2"] = 42;
var output = WorkflowInvoker.Invoke(wf, inputs);
Console.WriteLine(output);