ink-file-picker filepicker.io confirmation message upon upload - filepicker.io

I am using Ink Filepicker to get uploaded files from visitors to my site.
It us uploading to my Amazon S3 - that's all fine.
Some users aren't sure that their files are being uploaded though ,so they are doing it multiple times and/or emailing in the file anyway.
Is there a simple way to get a confirmation message to display when the file is uploaded (like a popup message box)?
Thanks for any help you can offer
Chris

You can use the onSuccess callback function. This function will fire when the upload has been completed successfully. Here is a very basic example...
filepicker.pickAndStore({
mimetypes: 'image/*',
services: ['computer','url']
},
// onSuccess callback
function(data) {
$('body').append('<div class="modal">UPLOAD COMPLETE!</div>');
}
);

Related

firebase dynamic links in stripe throws err_unknown_url_scheme

I've been developing an app with firebase and stripe payment. I've created a checkout session in stripe and added firebase dynamic links for the success_url and cancel_url. The URLs are working fine. I've tested them outside stripe with a simple html file and it opens the app and takes the user to the correct page. If the page doesn't exist it'll take the user to the assigned website. This is stripe checkout session code:
const session = await stripe.checkout.sessions.create({
line_items: [{
price_data: { currency: 'INR', unit_amount: amount, product_data: { name: 'name' } },
quantity: 1,
}],
mode: 'payment',
success_url: 'https://-------.page.link/payment-success',
cancel_url: 'https://-------.page.link/payment-failed',
payment_intent_data: {
application_fee_amount: fee
},
}, {
stripeAccount: req.query.stripeId,
});
I've changed up the actual link since I don't know how much I'm allowed to share. But I can guarantee the dynamic links works fine. But after payment, the test payment at least, it's suppose to open the app and take the user to a payment success page. AND it was working fine for the first 2 or 3 days. After payment it re-opened the app and took the user to the correct page. But when I tried a few days later, this is what it's taking us to:
Again, I've removed the link since I don't know how much I'm allowed to share. It won't even open the app right now. It just shows this message in the browser. Both success and cancel url are doing the same. Why does the links work outside the function but not in it? Has anyone ever faced any similar issues before? Any help will be greatly appreciated.
It seems like you're trying to open the Checkout Session in a WebView which causing the issue in the redirect. Webviews don't know how to handle an URL Scheme other than http:// or https://. That being said, your problem isn't uncommon and there are multiple ways of solving this.
Your first approach would be to open the Checkout Session in an external browser as described in this answer or try to create your own WebViewClient and override shouldOverrideUrlLoading method like described in this answer. Just note that since the last edit of that answer the signature of the shouldOverrideUrlLoading method has changed but the logic should still be used the same way but instead of dealing with the String url, you will have to deal with a WebResourceRequest.
Had the same issue. I solved it by changing the mode like following:
await launchUrl(
url,
mode: LaunchMode.externalApplication, // Add this line
)
url_launcher version => 6.1.7

Flutter oAuth : how to get started with OAuth and Stripe connect

I am trying to implement stripe connect in my flutter app. Here are the steps I need to implement. Can anyone please navigate me on how I could achieve this in Flutter?
I am able to create a button with the endpointUrl but that's all..
Thanks
I found out this myself using firebase cloud functions:
first you create an https function in the firebase cloud function
then you add the link created by the function to your stripe dashboard
then you write the following logic to your function
obtain the the authorisation code
fetch data from stripe
save the response somewhere (in my case in realtime database)
Here is the function
exports.connectStripeStandardAccount = functions.https.onRequest((req, res) => {
let authCode = req.query.code;
return stripe.oauth.token({
grant_type: 'authorization_code',
code: authCode,
}).then(async response => {
await admin.database()
.ref(`/accounts/${authCode}`)
.set(response);
return res.send("Well done, account integration is completed. You can now close the window and go back to the app");
});
});
The answer selected is not completely correct:
If you dont assign the account_id to a user then it's of no use.
The only way to pass the user_id (fUser.uid) is to pass it using the state parameter.
exports.StripePI = functions.https.onRequest(async (req, res) => {
// console.log('accountIdq ' + req.query.error);
// console.log('accountIdq ' + req.query.state);
// return;
// if(!req.query.code)
// return res.send("An Error has occured please try again");
const response = await stripe.oauth.token({
grant_type: 'authorization_code',
code: req.query.code,
}).then(async response => {
var connected_account_id = response.stripe_user_id;
await admin.firestore().collection('Registration').doc(req.query.state)
.update({customer_id : connected_account_id});
return res.send("Well done, account integration is completed. You can now close the window and go back to the app");
});
});
If you want to create an in-app stripe connect account registration with flutter you will need these:
A server or service to complete the OAuth like Firebase Functions or Integromat (I used Integromat)
A link that will redirect to your app (I used Firebase Dynamic Link)
STEPS TO CREATE THE REGISTRATION FLOW
INTEGROMAT/FIREBASE FUNCTIONS SETUP
I decided to use Integromat instead of Firebase Functions because is easier to set up, doesn't need any code, and decreases my server load.
If you want to create it on Firebase Functions you will need to have a Blaze Plan
If you don't know it, Integromat will automate processes that you currently handle manually, via webhooks. It is not only capable of connecting apps (like GoogleCloud, Facebook, AWS...) but can also transfer and transform data.
Create a new scenario and add a Custom Webhook. Click on it and click on add, name it, and save it. It will now create a custom link to your webhook.
Close and click on the semi-sphere next to the webhook, to add the new module.
Select HTTP and Make a Request.
In the URL section insert https://connect.stripe.com/oauth/token.
Method POST.
Body Type Application/x-www-form-urlencoded.
Create now those fields :
Key client_secret - value your stripe client secret You can find it on your stripe dashboard. I advise you to first use the test mode and after that, change the value to the live key.
Key grant_type - value authorization_code
Key code - leave the value blank. We will add it later.
Save and close
For Firebase Functions you can create a new HTTPS function (I didn't test this)
var stripe = require("stripe")(*your stripe client secret*);
exports.connectStripeStandardAccount = functions.https.onRequest((req, res) =>{
let authCode = req.query.code;
return stripe.oauth.token({
grant_type: 'authorization_code',
code: authCode,
});
});
Remember to install stripe package npm install stripe
STRIPE SETUP
If you are in the test mode go to this link
If you are in the live mode go to this link
Go on the bottom and activate oAuth for standard accounts or for Express Account.
Click on Add URI and add the webhook link of Integromat that you created or the link related to your Firebase function.
If you used Firebase add this link https://us-central1-<project-id>.cloudfunctions.net/connectStripeStandardAccount
For Integromat you will need to create the structure. To do this click on Test OAuth, copy the link, and open it in incognito mode. Open your Integromat scenario and click on your webhook. Now click on Re-determine data structure.
Return to your stripe registration page and click on Ignore account form at the top.
Return on Integromat and select the HTTPS request, modify the field code, and insert the variable code (will open a dialog with all queries from the webhook). Confirm and save.
Now click on the play button and reopen the stripe registration link in incognito mode and click on Ignore account form. Return in Integromat and add a JSON module after the HTTPS request. In the JSON string insert the Data variable and save. Create a Webhook Response module after the JSON module.
In the status put 301, then click on Ok.
DEEP LINK SETUP
It's time to set up the redirect link that will return the user to our flutter app or on our website if the user hasn't it installed.
I used Firebase Dynamic Link You can follow this tutorial for set up.
Go to the dashboard and create a new Link prefix and a new dynamic link, remember to select to redirect your users to the right app.
Click on the three dots in your dynamic link row and click on Link Details. Copy the extended link.
Open Integromat and select the last module you created (Webhook Response). Click on Show advanced settings and on the Header add :
Key Location - value the extended dynamic link that you copied.
If you want your app to elaborate data from the stripe OAuth response you can modify the extended dynamic link by adding ? on the link parameter: link=https://test.page.link?stripe_user_id={{14.stripe_user_id}}
And select the variable parsed from the JSON module. Remember to click on the save icon to save your scenario.
On Firebase Functions you can do this when the function stripe.oauth.token finish (I didn't test it):
res.setHeader('Location', your dynamic link);
res.status(301).send();
Remember to deploy it.
FLUTTER APP SETUP
The code here is very simple. To initialize the connect account registration you only need to set up a button that will launch the stripe connect URL. You can use launch(url);
You can find that URL here. Remember to be logged in to your stripe account to get the right stripe client id. You can easily get it in the same section you added the webhook link in your stripe connect settings.
Delete &redirect_uri=https://sub2.example.com on the URL.
Now you can test your app and will see that when you complete your stripe connect registration/login you will be redirected to your app.
If you want to have an in-app web view you can use this package
To handle the response, you need to have installed the package firebase_dynamic_links
Set your Main widget Stateful and on the initState run the method getDynamic() :
void getDynamic() {
FirebaseDynamicLinks.instance.getInitialLink().then((value) {
if (value != null) {
_connect(value);
}
});
FirebaseDynamicLinks.instance.onLink(onSuccess: (value) async {
if (value != null) {
_connect(value);
}
}, onError: (error) async {
debugPrint('DynamicLinks onError $error');
});
}
void _connect(value) {
Uri deepLink = value.link;
print("Link :" + deepLink.path);
print("Query :" + deepLink.queryParameters.toString());
String stripeUserId = deepLink.queryParameters["stripe_user_id"];
}
You need to have both of them to handle dynamic links when your app is running and when it's closed.

how to respond to user using google assistant after the conversation is ended?

I am making a google action.I have one scenario where calculation requires some time in cloud fulfillment but i don't want to keep user waiting for answer.
I want to respond to user whenever my answer is ready even when conversation with user is ended i want to send my answer in notification or something like that.
I just found this on google actions documents.
https://developers.google.com/actions/assistant/updates
Is this possible in google actions and how?
What you mean here is notifications. You can use it but please pay attention to the warning at the top of the link you provided: "Updates and notifications are currently in Developer Preview. You can build apps using the features described in this article, but you can't currently publish them".
As for the steps to crated a daily notification:
Navigate to your actions.intent.CONFIGURE_UPDATES intent.
Under Responses, go to the Google Assistant tab, click Add Message Content, and select Custom Payload.
In the "Custom Payload" box, add the following code to call the AskToRegisterDailyUpdate helper. Swap INTENT_NAME to the intent that you want to be invoked when the user interacts with your notification.
{
"google": {
"system_intent": {
"intent": "actions.intent.REGISTER_UPDATE",
"data": {"#type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
"intent": "INTENT_NAME",
"triggerContext": {
"timeContext": { "frequency": "DAILY" }
}
}
}
}
}
If using a webhook, you can call this API directly via the client library:
appMap.set('setup_update', function(app) {
app.askToRegisterDailyUpdate('INTENT_NAME');
})
})
Add one more intent called "finish_update_setup" and enter actions_intent_REGISTER_UPDATE as its Event.
Set the intent's Action to "finish_update_setup" as well.
In your webhook, open index.js and add the following. Replace Ok, I'll start giving you daily updates and Ok, I won't give you daily updates. with whatever response you want to give the user:
appMap.set('finish_update_setup', function(app)) {
if (app.isUpdateRegistered()) {
app.tell("Ok, I'll start giving you daily updates.");
} else {
app.tell("Ok, I won't give you daily updates.");
}
}
Deploy the webhook to Firebase Functions and enable webhook fulfillment in Dialogflow.
If you want to see how to create a simple notification (not daily one) - please check this doc on push notifications.
If you don't have an immediate reply to send but expect one soon-ish what you do is return a "promise". When you are in a position to reply, "fulfilling" the promise causes your reply to be delivered. I don't know what the actual timeout is but in my case I'm pretty sure at least a few second delay is allowed.
As for the updates or notifications, the API is there but the docs say you can't deploy an Action to production using them. There is a slightly cryptic comment to "contact support" if you need them.
One of these days I might try.

blueimp / jQuery-File-Upload : Email notification on upload

I'm using blueimp / jQuery-File-Upload, (via this tutorial to create a file uploaded) I would like to receive an email notification when a file has been uploaded, ideally with the file uploaded being emailed too.
From the docs, I understand that I need to use:
done: function (e, data) {
// data.result
// data.textStatus;
// data.jqXHR;
}
but.. I have no idea what to put inside here!
I'm using phpmailer.php so am trying stuff like:
done: function (e, data) {
$.ajax({
type: "POST",
url: "bin/signup_process.php",
data: "CV Uploaded via Rough Hill",
});
}
But I really have no clue how to get the uploaded file data from the script to send to phpmailer, or indeed how to even define the contents of the email.
Can anybody help me understand how I get the uploaded file data from jQuery-File-Upload and stick it in an email along with a message?
Many thanks in advance for any advice.

How to get my own facebook/twitter wall status using CS5.5?

i'm trying to learn how to get my own facebook & twitter wall status into flash so that I can export it out and install it in my iPhone.
After reading the facebook and twitter API documentation, I'm still very confussed on how to use them.
I'm very new to this and hope to get a suitable tutorial/sample code for some reference.
Help is appreciated. Thank you.
For Twitter it is easy. Just write the AS3 code to load the Twitter user RSS as XML. After that you will be able to use it.
var myXmlLoader:Loader = new Loader();
myXmlLoader.load(new URLRequest("http://twitter.com/statuses/user_timeline/#twitterUser.rss"));
// just replace "twitterUser" with your twitter user, leave all the rest as is
myXmlLoader.addEventListener(Event.COMPLETE, xmlLoadCompleted);
function xmlLoadComplete(evt){
var myWallData:XML = new XML(evt.target.data);
trace(myWallData); // you will get an RSS XML with the last 20 tweets from your account
}
To get an RSS from your Facebook wall you can use this:
https://www.facebook.com/feeds/page.php?id=23749877160&format=rss20
where 23749877160 is your Facebook account ID
that will give you an rss with your Facebook just as twitter does,
But you need some trick to load it with flash.
Locally you can load it and it works good using the same code to load the twitter,
but on the web your swf wont be able to load, some crossdomain issue.
To fix this what I did is a simple PHP file to load the rss and save a file with the loaded content.
PHP code:
<?php
set_time_limit(300); // this is to set the time limit to execute a code, is that the facebook wall take too long to load
$fbURL = "https://www.facebook.com/feeds/page.php?id=23749877160&format=rss20";
$fileName = "myFileName.xml"; // the name you want to do to your file, the file you will load with flash
$doc = new DOMDocument();
if($doc->load( $fbURL )){
$doc->save($fileName); // saving file in server folder
}else{
echo "error";
}
?>
This is cool but you need to execute the PHP file before intent to load the generated XML. you can use this code to do the trick
AS3 code:
var myPHPLoader:Loader = new Loader();
myPHPLoader.load(new URLRequest("xmlGenerator.xml"));
myPHPLoader.addEventListener(Event.COMPLETE, phpLoaded);
function phpLoaded(evt){
trace("PHP executed");
// do whatever you want
// after the php is executed you can load the fbXml generated normally
}
This works good, but keep in mind that the twitter rss and Facebook RSS, has a call limit per hour (150 call) for twitter, for Facebook I dont know. so if your app reach that limit before complete the hour it will call the empty xml or an error.
dont worry for Facebook in this example you have an PHP that will save the file just if it loads good, if the PHP dont loads the Facebook wall then it wont save the file, so your app will load the old fbXml.
Use the same php to load the twitter rss and save a file to be loaded from your flash app.
What I did is the follow.
PHP Code:
<?php
function savePlainRss($loadURL, $fileName){
set_time_limit(300);
$doc = new DOMDocument();
if($doc->load( $loadURL)){
$doc->save($fileName);
}
}
savePlainRss("https://www.facebook.com/feeds/page.php?id=23749877160&format=rss20", "myFacebookWall.xml");
savePlainRss("http://twitter.com/statuses/user_timeline/#twitterUser.rss", "myTwitterRSS.xml");
?>
This code will save an XML file for twitter rss and Facebook Wall but just if it can load it, if dont it will keep the old file.
Then from flash load the generated XML files.
For me to be sure my app wont reach the call limit and avoid twitter or facebook tag my app as spam, I did a cronjob on my Server to execute the PHP file
each 15 minutes so the calls to twitter and Facebook per hour is just 4, you can find help in google about how to do a cronjob, some hosting and web server have tools to do it.
you can do de calls each 5 minutes if you want more frequently updates or less, but keep in mind that the facebook load can take a long time, up to 300 seconds (5 minutes) dond use less than that to be sure you will have the complete work done.
Thanks for reading.
I hope it helps :)
had alook at it: http://developers.facebook.com/docs/guides/web/ look here for the API.
i dont want to post there code on here...
Also heres seems to have more info:
http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/index.html
this is successful with actionScript, i learned something new
if i got time i will create a basic user status or something and let you know, for now i hoped i pushed you in the right direction.