How to get setup result from stripe in a Fragment? - java

How do i get the response from stripe with the new Activity Result Api? I create a new card and i want to attach it to a stripe account. To do that i have to use the confirm setup intent and wait for the answer from stripe. But how do i register this one with the new Api? This is my code and but the onActivityResult has been deprecated now. I know how to use it for picking images or making phone calls and other that can use the launch function of the register activity. I don't want to do this on the server side because if the card needs 3D secure webview stripe handles that automatically.
ConfirmSetupIntentParams confirmParams = ConfirmSetupIntentParams
.create(paymentMethodParams, clientSecret);
stripe.confirmSetupIntent(this, confirmParams);
#Override
public void onActivityResult(int requestCode, int resultCode, #org.jetbrains.annotations.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
stripe.onSetupResult(requestCode, data, new ApiResultCallback<SetupIntentResult>() {

Related

How to open only Google Drive with SAF or without SAF?

I have following code to open the storage access framework:
private void startDialog()
{
Intent intent= new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("text/plain");
startActivityForResult(intent, 1);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData)
{
super.onActivityResult(requestCode, resultCode, resultData);
}
But in in the SAF, I can select all places on my device. How can I open directly only my Google Drive Account? One way maybe is of the SAF and another way is over the google drive rest api v3. I can authenticate me with them, but i don't know how to open files with the api. With api v2 i could open file via: Drive.DriveApi but the DriveApi is deprecated.

UPI integration in android: How to use onActivityResult?

UPI (Unified Payment Interface) is a payment interface for Indian banks.
In UPI transactions are links. Just like bitcoin transactions are messages
Those links are passed to UPI payment apps and the payer has to login to the app and click the pay button.
Our app has to start an intent and pass link to the UPI payment app and after payer clicks the pay button we need to call onActivityResult.
I dont know anything about android development in java.
I use python kivy for android development. I want to know what should my onActivityResult should do.
Sample code :
UPI App Deep linking using Intent - inconsistent and buggy behavior
I can use java code in python using pyjnius.
Some reference link:
https://blog.deazzle.in/enable-upi-payments-in-your-app-without-the-need-to-integrate-with-a-bank-c911019f3b2d
you have not any need to do it manually. I have developed a library for it.
Just have to do a simple process.
final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()
.with(this)
.setPayeeVpa("EXAMPLE#VPA")
.setPayeeName("PAYEE_NAME")
.setTransactionId("UNIQUE_TRANSACTION_ID")
.setTransactionRefId("UNIQUE_TRANSACTION_REF_ID")
.setDescription("DESCRIPTION_OR_SMALL_NOT")
.setAmount("AMOUNT_IN_DECIMAL_XX.XX")
.build();
easyUpiPayment.startPayment();
For more info, you can visit below site.
https://github.com/PatilShreyas/EasyUpiPayment-Android
Activity A:
Intent start = new Intent(MainActivity.this, PurchaseActivity.class);
startActivityForResult(start, 1);
And add this result listener:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
//payment was successful
}else if (resultCode == RESULT_CANCELED) {
//payment was canceled
}
}
}
And Activity B:
If payment was successful:
setResult(RESULT_OK, new Intent());
finish();
or if it was canceled:
setResult(RESULT_CANCELED, new Intent());
finish();

Twitter Android-FirebaseUI auth: How to post on user's behalf once I have the access Token and the access secret on Android App??are those enough?

I logged in successfully and got the twitter access token and the twitter access secret using firebase-ui-auth [https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md][1]:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN && resultCode == RESULT_OK) {
IdpResponse response = IdpResponse.fromResultIntent(data);
//twitter access token
response.getIdpToken();
//twitter access token secret
response.getIdpSecret();
}
}
I want to post on user's behalf(to their accounts, not to mine) using these two tokens that I will save on shared preferences.
1) Are these two tokens enough to post to user's account?
2) How do I do to post something using these two tokens?. I can't seem to find the proper docs for my particular case, the twitter api handling for android is really poor.
I already solved it myself by using fabric and its TweetComposer class.....
first you need to initialize fabric on the bootstrap Class of your app
Fabric.with(this, new Twitter(authConfig));
then on the class you want to make the tweet you get the firebase instance to get the logged in user and then you set the twitter consumer key and secret that you got when you log in to firebase UI https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md, for future reference to get the two tokens needed to tweet on user's behalf you can do it like the link specifies:
To retrieve the ID token that the IDP returned, you can extract an IdpResponse from the result Intent.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
startActivity(new Intent(this, WelcomeBackActivity.class)
.putExtra("my_token", idpResponse.getIdpToken()));
}
}
Twitter also returns an AuthToken Secret which can be accessed with idpResponse.getIdpSecret().
and now you have everything you need:
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
// already signed in
twitter_consumer_key= preferences.getString("TWITTER_CONSUMER_KEY","");
twitter_consumer_secret= preferences.getString("TWITTER_CONSUMER_SECRET","");
TwitterAuthConfig authConfig = new TwitterAuthConfig(twitter_consumer_key, twitter_consumer_secret);
//setting up fabric
Fabric.with(this, new TwitterCore(authConfig), new TweetComposer());
}
and then let's say I want to tweet from a custom button onClick:
ImageButton tweetButton= (ImageButton) findViewById(R.id.tweet_button);
tweetButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
TweetComposer.Builder builder = new TweetComposer.Builder(mContext)
.text("just setting up my Fabric.");
builder.show();
}
});
the app will redirect you to the twitter app with the preseted message "just setting up my Fabric.". You can add pictures and videos too!
Hope that this helps someone in the future cause there is little info about fabric....

How to browse folder in android and get the path of folder selected

When I click a button,show a file browser,I can choose a folder and return it's path.I get this path to copy file to that path.
But I have no idea of How I could implement this.
I have yet looking for this question in Stackoverflow but I haven't find a clear answer to my question.
I saw some libary of filebrowserview like "https://github.com/psaravan/FileBrowserView",but not work.
Use intent for that!
First start start activity for result like this:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_REQUEST_CODE);
Override this method in your activity, it will get called when activity you just started returns. You can handle result codes such as canceled or successful.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String Fpath = data.getDataString();
//TODO handle your request here
super.onActivityResult(requestCode, resultCode, data);
}
Another approach is to use library such as NoNonsense-FilePicker.

Android Studio Facebook: onActivityResult in normal class

In order to listen to a facebook login event I must override in my activity the function onActityResult and make a call to facebook's callbackmanager.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
So far everything's working.
I'd like to create a static class for facebook that handles facebook callbacks, such as login, etc.
Is there substitute for onActivityResult in that case?
You mean you want another class to handle the activity returning? Then you have to have onActivityResult of the activity that calls startActivityForResult call into your facebook class. There's no way to reroute it automatically.

Categories

Resources