My bot sends links to my employees in various types of cards according to the following format:
$card["content"]["items"][] = array(
"type" => "resultItem",
...
"tap" => array(
"type" => "openUrl",
"value" => "https://.../#Path/...",
),
);
The problem is the # in the link. It turns into https://.../%23Path/... when the user taps on the item. Interestingly, it works as expected in the browser and desktop versions of Teams, but not in the mobile version. In other words, from the first two platforms clicking the item will successfully open the page in the browser with the # in the link, but mobile browsers are given %23 by Teams, which does not work.
How do I prevent Teams from replacing the #?
Related
I'm attempting to use Laravel Cashier to retrieve line items of the client's upcoming invoice. I'm having difficulty obtaining the invoice in the first place. Though I've found the undocumented public function "upcomingInvoice," I can't get any of its protected properties out.
Even with it, I'm having trouble understanding how to use the poorly documented "asStripe..." functions, presumably asStripeInovice(), to return the line items.
I've tried a whole host of things and it would muddle things up to write them all out, so I figure it might be better just to ask how to go about it.
Thanks!
Try this one liner code in laravel 7 or 8 with cashier.
$user->upcomingInvoice()
And you're good getting all upcoming invoices details.
As up update, I was able to get this to work just using the Stripe client, like so:
$stripe = new StripeClient(env('STRIPE_SECRET'));
$upcomingLineItems = $stripe->invoices
->upcomingLines(['customer' => $customer['stripe_id']]);
I'll still leave this open in case there's a way to do it with Cashier's methods, but it now doesn't seem necessary.
Similarly, I wanted to be able to display the "amount due today" to a user prior to switching subscription plans (which takes into account proration as well as any credit applied to the customer's account). I was able to do this in Laravel using the following:
$stripe_client = new StripeClient(config('stripe.secret'));
$items = [
[
'id' => $user->subscription()->items()->first()->stripe_id,
'price' => $selected_plan, # Switch to new price
],
];
$invoice = $stripe_client->invoices->upcoming([
'customer' => $user->stripe_id,
'subscription' => $user->subscription()->stripe_id,
'subscription_items' => $items,
'subscription_proration_date' => Carbon::now()->timestamp
]);
$amount_due = $invoice->amount_due; // and there it is
I'm working on a website and I have a layout for at least 20 services which are only different in description and image. I'm trying to find a way to implement one layout and add data for a specific link and I don't want to use a database because the data isn't important to save. Is there another way or I have to use 20 blades that extend one layout?
You can have an array like this that you will pass to a layout
$servicesLayout = [
'service_1' => [
'description' => 'Service 1 description',
'image' => 'www.host.com/assets/img/section_1.jpg'],
'service_2' => [
'description' => 'Service 2 description',
'image' => 'www.host.com/assets/img/section_2.jpg']
];
Now when viewing a section, you pass the section key for example 'section_1' to the layout
To display section description in layout
{{$servicesLayout['service_1']['description']}}
I've created some custom product attributes with REST API, correctly populated them and assigned values to products.
Everything works fine in dev environment whereas I got difficulties in staging environment, even though values and settings are the same, even in the DB.
If, for example, I want to update the value of "is_filterable" option in an existing attribute from the backend, Magento says it saved the attribute correctly, but actually no changes are made.
I've tried to update with a PUT call to REST API with correct values, but I'm able to update only the attribute labels,
This is the json i'm passing to "products/attributes/my_attr"
{"attribute":{"attribute_code":"my_attr","attribute_id":174,"scope":"Global","default_frontend_label":"my_attr","frontend_labels":
[{"store_id":1,"label":"my_attr"}],"frontend_input":"select","is_searchable":true,
"is_visible_in_advanced_search":true,"is_comparable":true,"is_filterable":true}}
And this is the Json response, where you can see it is totally ignoring the values for is_filterable and scope.
{"is_wysiwyg_enabled":false,"is_html_allowed_on_front":false,"used_for_sort_by":
true,"is_filterable":false,"is_filterable_in_search":false,"is_used_in_grid":
true,"is_visible_in_grid":true,"is_filterable_in_grid":true,"position":0,
"apply_to"[], "is_searchable":"0","is_visible_in_advanced_search":"0",
"is_comparable":"0","is_used_for_promo_rules":"0","is_visible_on_front":"0",
"used_in_product_listing":"0","is_visible":true,"scope":"global",
"attribute_id":174,"attribute_code":"taglia","frontend_input":"select",
"entity_type_id":"4","is_required":false,"....
Obviously I've reindexed and cleared caches continuously.
The only way I managed to change those values is directly from the DB.
I'm going to try with an extension but I'm not sure to succeed.
I've seen there was an issue that should have been fixed in older Magento versions and actually other attributes work fine.
Any clue?
EDIT
With a different set of parameters in the call, I managed to change the attribute values, but still no luck from the backend.
This is the updated request (array version)
$data = [
"attribute" => [
"attribute_code" => $my_opt,
"attribute_id" => 173,
"entity_type_id" => 4,
"scope" => "global",
"default_frontend_label" => $my_opt,
"frontend_labels" => [
["store_id" => 1,
"label" => $my_opt ]
],
"frontend_input" => "select",
"is_wysiwyg_enabled" => true,
"is_html_allowed_on_front" => true,
"used_for_sort_by" => true,
"is_filterable" => true,
"is_filterable_in_search" => true,
"is_used_in_grid" => true,
"is_visible_in_grid" => true,
"is_filterable_in_grid" => true,
"position" => 1,
"is_searchable" => true,
"is_visible_in_advanced_search" => true,
"is_comparable" => true,
"is_used_for_promo_rules" => true,
"is_visible_on_front" => true,
"used_in_product_listing" => true,
"is_visible" => true
]
];
EDIT2: Moreover, if I try to update some info from the backend, Magento resets the values of the default view store label to empty and the "use in layered navigation" to "No". Stranger at any try.
EDIT 3
seems like the most possible issue can be caused by duplicated values in these dropdown attributes, but I carefully removed all of them from
eav_attribute_option
eav_attribute_option_value
in the db, but actually removing options only, works from the backend too, whereas the creation of new options is not working
This is not a definitive solution, for which I will create a new question to which someone hopefully will be able to answer, but I wanted to post at least what the true problem is.
Actually, I observed that everything was working until a certain amount of options, and after that, no matter what the values were, it quit working.
Actually I experienced it also in the dev environment, for which the limit was higher, but for an attribute with more than 1300 options, nothing was working as well.
So looking around I found out this is a php memory problem and that you have to increase the value of
max_input_vars=100000
whereas by default is only 1000.
someone suggest also other parameters, but this is actually the most used.
The problem that remains, is that I still have not found the good values to have my attributes with many options, to work.
Assuming I have a music app (like the example) using GetStream.io feeds, where I have user feeds and band feeds (user being able to follow other users, or bands).
I am using the stram-ruby gem.
Now, say I am posting as a user to a band feed, doing something like:
user_feed = #client.feed('user', user_id)
activity_data = {
:actor => "User:#{user_id}",
:verb => 'post',
:object => "Post:#{post.id}",
:target => "Band:#{band_id}",
:foreign_id => "Post:#{post.id}",
:time => post.created_at.as_json,
:comment => 'comment 1',
:to => ["band:#{band_id}"]
}
user_feed.add_activity(activity_data)
This works fine, and retrieving the band feed, I can see that post:
#client.feed('band', band_id).get()
Now, I am attempting to update this entry (using the comment field just to see something changes):
activity_data = {
:actor => "User:#{user_id}",
:verb => 'post',
:object => "Post:#{post.id}",
:target => "Band:#{band_id}",
:foreign_id => "Post:#{post.id}",
:time => post.created_at.as_json,
:comment => 'comment 2',
:to => ["band:#{band_id}"]
}
#client.update_activity(activity_data)
getting the band feed will show correctly the new comment ('comment 2'), but my problem is this:
I am using the created_at field of my post (to ensure my ability to update it as GetStream docs say this is part of the unique key)
I use the same created_at time on the update
When fetching the band feed, I would expect this activity to be the top one - as the feed should be sorted chronologically. But it remains where it was before based on the created_at time.
What to do?
I can try using the updated_at field of the post, but then, if for any reason the post in my DB changes without me updating the GetStream feed, I will no longer be able to update it in GetStream.
Am I missing anything?
There are 2 ways in which you can achieve this.
1.) You could use aggregated feeds. They are sorted based on the last update to the aggregated item. (assuming this fits your use case of course)
2.) You could send a field to Stream called updated_at. Next you enable ranked feeds and simply tell Stream to sort by updated_at instead of the regular chronological sort.
In general, creating a ranking method gives you full control over the ranking of your feed. (paid plans only though)
https://getstream.io/docs/#custom_ranking
I want to do a webshop, where users pay via paypal. Everything works perfectly, if I use the default currencies. However I want to pay with Hungarian Forint, which is not working.
In the merchant library I have found this:
public static $NUMERIC_CURRENCY_CODES = array(
'AUD' => '036',
'CAD' => '124',
'EUR' => '978',
'GBP' => '826',
'NZD' => '554',
'USD' => '840',
);
So I added a new line: 'HUF' => '348', but regardless when I want to pass the HUF parameter to the CI-Merchant, its not working. Matter of fact, I can change anything in this array, the results will be the same
This is how I pass the parameters:
$params = array(
'amount' => $osszeg,
'currency' => 'HUF',
'return_url' => 'something',
'cancel_url' => 'something');
(paypal supports Hungarian forint, so the problem is not there)
Is there any way to make this work? Thank you very much for your answers in advance.
Firstly, don't use CI Merchant, it has been unsupported for nearly a year now. Omnipay is its replacement.
If you must use CI Merchant, then the currency parameter is correct. You don't need to add the numeric currency code, since paypal uses standard 3 letter currency codes. It's passed through to paypal here:
https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant_paypal_base.php#L94
Now since you only say it's 'not working', I don't know what the actual problem is so can't really help diagnose. If there is an error message, what is it? I suspect that the currency is not enabled on your paypal account.