In stripe, we have the option to expand some of the child object when the property has the expandable option. And the expandable property is not shown by default. For example in customer object, we have the sources list which is not shown by default. But we need to expand it when retrieving the customer by adding the expand parameter - "sources" as below.
var customer = this.stripeService.getCustomer(stripeCustomerId(), List.of("sources", "default_source.card"));
Now since sources is a list it by defaults shows only 10 cards. But I wanted to limit that to more number say 20. How can we do this on the expandable property?
I Still did not find a way to set the limit but we can fetch all the items without the default limit of 10 using the following code. The key is autoPagingIterable that brings all the data without paging
var customer = this.stripeService.getCustomer(stripeCustomerId(), List.of("sources", "default_source.card"));
if(customer.getSources().getHasMore()){
List<PaymentSource> paymentSources = new ArrayList<>();
customer.getSources().autoPagingIterable().forEach(paymentSource -> {
paymentSources.add(paymentSource);
});
customer.getSources().setData(paymentSources);
customer.getSources().setHasMore(false);
customer.getSources().setUrl(null);
}
Reference -> https://stackoverflow.com/a/64173387/12752873
The autoPagingIterable is the right approach but it's best to be used on the correct API endpoint.
From Stripe's docs:
The sources property on Customers is no longer included by default. You can expand the list but for performance reasons we recommended against doing so unless needed.
If you want to get a customer’s sources you should call the separate endpoint.
Related
I would like to change the price of a product based on the customer's selection. For example, I'm trying to build a small PDP widget to make customers able to choose the number of candles on a cake or write text on cakes and update the price accordingly. The docs only cover how to change the price by overwriting the cart's collector/processor but I don't want to use this method because of other plugins potentially overwriting the same service. So, is there are any other methods of changing the price of the products by subscribing to an event?
There are a few things you will need to consider in this one.
Firstly, you will need to save the user input data somewhere (amount of candles, text).
Possibly a separate database table that has a OneToMany relationship on cart line items. See this article. Und ya, this is also the part where you will hook into the onLineItemAdd event & save your user input to that table. You may as well also subscribe to the onLineItemUpdate for the same saving logic. You could do the same when removing the item from the cart, although that may not be necessary if you use database's "CASCADE on delete" when implementing your DB table. Meaning once the line item gets removed by the customer (deleted in the DB), your database entry gets deleted as well.
Afterwards, you can then use the extensions or otherwise called associations to pull this data on the cart page & the order pages. You can be a little more fancy here, if you look at all the frontend router calls, you will notice that Shopware sometimes passes "Criteria" class you can hook into.
public static function getSubscribedEvents(): array
{
return [
OrderRouteRequestEvent::class => 'alterCriteria',
DocumentOrderCriteriaEvent::class => 'alterCriteria',
];
}
public function alterCriteria(Event $event): void
{
if (method_exists($event, 'getCriteria')) {
$event->getCriteria()->addAssociation('lineItems.myExtension'); // check syntax, could be lineItem.
}
}
Now you can extend the twig templates to show your candles or text in the order page, cart page, document (invoice) pages.
Secondly, you will have to handle the price. This part will be easier now that you have data saved & being automatically pulled via criteria subscribers. If it's not possible to hook into those events all the time, you will still have an option to manually load your data.
I do not recommend modifying the price itself, but maybe you could look into adding a surcharge instead. Maybe this article will be helpful to understand the price flow. You could also see if there are any other plugins out there that implement surcharge logic to see it in action.
I'm working with a client on obtaining Bills and Adjustments values through the Contract based web services. I understand that certain fields aren't available in the Default Endpoint, and have to be obtained through an extension.
I'm trying to add fields from the Bills and Adjustments' Applications tab, but I'm running into a warning that I don't understand. If I extend the Default endpoint for 'Bills' (call it 'BillExt'), and I try to add the Reference Number field from the 'Applications' tab/grid (or any other field from that grid) - I get the following warning (see screenshot below)...
Can someone explain what the issue is, and how I go about adding these fields from the 'Applictaions' tab/grid? I've added fields from the 'Approval Details' grid without this warning without a problem. Is this a warning I can disregard?
You are trying to add a field from another table/view that can return multiple rows for a single Bill.
The correct way to do this is by adding a separate collection on the object and map the view on that collection. e.g: Applications or Details collections here.
That collection will have the information for all records related to the header once you retrieve them using the ?$expand=Details on the query string request.
I'm passing a parameter to a PowerApp through the calling URL called ID, i.e.
https://web.powerapps.com/apps/powerappid?ID=32
When the app launches I want it to jump from BrowseScreen1 which lists all the Business Cases and go straight to the Business Case with the matching ID (a field from a SharePoint list).
I'm brand new to PowerApps but pretty sure what I need to do is called Deep Linking and I found this tutorial https://powerapps.microsoft.com/en-us/blog/powerapps-deep-linking/ and having read the comments to the article I'm trying to apply it to the OnStart property of BrowseScreen1. I don't really understand how the navigation link in the tutorial is constructed so I'm sure I'm using the wrong Navigation parameters as it always launches the first record in the list ignoring anything to do with the ID. I'm using:
If(Not(IsBlank(Param("ID"))),Navigate(DetailScreen1,
None,{ID:LookUp('Full Business Case For Review'.ID, ID =
Value(Param("ID")))}))
'Full Business Case For Review' is the name of the Sharepoint list and ID is a unique field that gets assigned to each list item.
The tutorial doesn't mention having to change anything on the detail screen but I've also wondered if I need to perhaps change the item properties there as they are currently:
BrowseGallery1.Selected
I'm feeling out of my depth and would really appreciate some help on this!
Thanks,
John
Yes, you need to change the Item property in the detail screen. This is because there is currently no way to select an item in a gallery programmatically in PowerApps.
I normally get around this by using a global variable to store the current item, so you can set BrowseSreen1.OnStart to this
If(Not(IsBlank(Param("ID"))),
Set(CurrentItem, LookUp('Full Business Case For Review'.ID, ID = Value(Param("ID"))));
Navigate(DetailScreen1, None)
)
This will store the item with ID equal to your parameter as a record type variable.
You also need to change the OnSelect property of your BrowseGallery1's template or whichever control is used to navigate to the detail screen. It will need to be something like this
Set(CurrentItem, ThisItem); Navigate(DetailScreen1, None)
Finally set the Item property in the detail screen simply to this
CurrentItem
I have a new Windows Application that I am adding Application Insights to. Adding a new chart gives the ability to Group on specific custom properties using a drop down. This drop down has 65 properties that AI must have added at some point. There were not specifically added.
We have a main AppInsights that takes all events. We've also created a AppInsight for development. The list of custom properties in the drop down is different between these two, even though the source code is the same.
It makes me suspect that there is some process that creates the drop down contents based on the incoming data.
The problem here is that the code has changed, and some properties are no longer available. We want to eliminate these values from the drop down, and add the new ones.
I am perfectly happy just deleting the entire list. Is there a way to do this?
The items that are available in the group by are properties that have ever been received by the back end in data you've sent, and aren't editable.
for custom properties/metrics, there's a limit on how many properties the backend will allow before it stops collecting new named custom properties. Conceptually, think of it as the backend storing an array of 200 elements for each telemetry item you sent, and mapping each custom property name to an index, and that mapping lasts forever. (i believe at the current time that limit is 200 each, but we're working on expanding that)
so if developers did things in your dev portal, even sent one item with custom property "foo", then that property will be there forever, and takes up one of those 200 slots. They can't be deleted or cleared at the moment.
Also, the contents of the group by box is also limited to events that have sent less than some threshold of distinct values, too. (I'm not sure on that exact value, but i believe it < 100 distinct values.) So fields like Id fields, or guids, etc, will eventually stop showing up as group by options, because the group by would create N distinct buckets of 1 item.
It seems like this would be something already mentioned in the App Insights UserVoice site, or documented in the azure documentation for group by but i'm not seeing it.
The only real workaround at this time is to create a new application insights resource in azure, and start submitting data to that new resource instead of your old one. And then you have to be proactive about never submitting custom properties that you're never going to use, or mixing case, as "Property1" and "property1" will be distinct properties...
If this is a big issue for you, i'd suggest submitting it to microsoft connect as a bug, or entering a uservoice suggestion above. I'll pass this on as something that really needs to be documented in the group by thing in the azure docs, too.
Is it possible to limit the number of channel entries a member can create?
I would like to set a max number per member group.
Thanks
Yes, but it would require writing an extension. The logic would be something like this (assuming you're talking about limiting on the back-end ... from the front-end, if you're using a Safecracker entry form for example, you'd need to take a different approach):
use the sessions_end hook
check to make sure you're in the control panel ($this->EE->input->get('D') == 'cp')
check to make sure you're on the publish screen ($this->EE->input->get('C') ==
'content_publish')
query the database to see how many entries in exp_channel_titles with the channel_id of $this->EE->input->get('channel_id') belong to $this->EE->session->userdata('member_id')
if the result is greater than your allowed maximum, show them an error
That should get you started.