Closed preteambuy closed 2 years ago
Are you compiling for web? If so, you should provide the return url in the method call each time
@ezet - am not compiling for web. Am testing it on my mobile devices as well as the simulators and even "kIsWeb" returns false.
I will investigate and fix this asap.
thanks @ezet
When i downgrade it works for both Android and IOS. This new versions fails for both Android and IOS. Just an information
I am unable to test this myself at the moment. Can you please check if https://pub.dev/packages/stripe_sdk/versions/4.0.1-rc.1 works for you?
@ezet it works on the RC branch.
Great, I'll release it then, thanks 👍
im compling for the web and im getting the same problem, what do 'you should provide the return url in the method call each time' as i done it and still getting errors
@jaffakakes are you providing the right return URL for the callback? Whats the return URL your providing?
@preteambuy im using http://3ds.stripesdk.io
@preteambuy ive also used my own url
@jaffakakes can u pls the url ur using?
@preteambuy const _returnUrl = 'stripesdk://3ds.stripesdk.io'; also 'stripesdk://localhost:53418/#/ const _returnUrlWeb = 'http://3ds.stripesdk.io'; also http://localhost:53418/#/
String getScaReturnUrl() { return kIsWeb ? _returnUrlWeb : _returnUrl; } void main() { Stripe.init(_stripePublishableKey, returnUrlForSca: getScaReturnUrl() ); runApp(MyApp()); }
and also called it every time I was about to run a function
Future<Map<String, dynamic>> confirmPayment3DSecure(String clientSecret,paymentMethodId) async{ Map<String, dynamic> paymentIntentRes_3dSecure;
try{
Stripe.init(pkstring, returnUrlForSca: getScaReturnUrl() );
await Stripe(pkstring, stripeAccount: widget.StripeID, returnUrlForSca: 'http://3ds.stripesdk.io').confirmPayment(clientSecret, paymentMethodId: paymentMethodId);
paymentIntentRes_3dSecure = await Stripe(pkstring, stripeAccount: widget.StripeID, returnUrlForSca: 'http://3ds.stripesdk.io').api.retrievePaymentIntent(clientSecret);
}catch(e){
print("ERROR_ConfirmPayment3DSecure: $e");
showAlertDialog(context, "Error", "Something went wrong.");
}
return paymentIntentRes_3dSecure;
}
const _returnUrlWeb = 'http://3ds.stripesdk.io'; also http://localhost:53418/#/
For the above on when you release your change "http://3ds.stripesdk.io" wont work unless you own the domain "stripesdk.io". Also for testing I doubt localhost would work. Try with a public IP and see if that helps
You need to provide the returnUrl as a parameter to the 3ds-enabled method. e.g. confirmPayment(clientSecret, paymentMethodId, webReturnUrl)
. It has been implemented like this because unlike the app-implementation, you likely want to re-direct to a different page based on the method used. Usually back to the same page the user came from.
Also, like @preteambuy says, you want to use your own domain for this, or else you will be redirected to a page you don't control. This redirect works the same way as any other redirect, including the redirect/return URL that Stripe JS uses, and there is no "magic" here. Localhost will work fine for debugging/development purposes.
@preteambuy here is my code I've also tried using a public domain and i am still getting the same results so I went back using a local as it less hassle. this is my code and what its output: paymentIntentXs = await confirmPayment3DSecure(clientSecret,paymentMethodId,Stripe.instance.getReturnUrlForSca(webReturnPath: '3ds/success' )); print(paymentIntentXs);
Future<Map<String, dynamic>> confirmPayment3DSecure(String clientSecret,paymentMethodId, webReturnUrl) async{ Map<String, dynamic> paymentIntentRes_3dSecure;
try{
print('1');
//Stripe.init(pkstring, returnUrlForSca: ModalRoute.of(context).settings.name);
// print(ModalRoute.of(context).settings.name);
await Stripe(pkstring, stripeAccount: widget.StripeID, returnUrlForSca: webReturnUrl).confirmPayment(clientSecret, paymentMethodId: paymentMethodId,);
print('2');
paymentIntentRes_3dSecure = await Stripe(pkstring, stripeAccount: widget.StripeID, returnUrlForSca: webReturnUrl).api.retrievePaymentIntent(clientSecret);
print('3');
}catch(e){
print("ERROR_ConfirmPayment3DSecure: $e");
showAlertDialog(context, "Error", "Something went wrong.");
}
return paymentIntentRes_3dSecure;
}
I also tried to add it to the Confirmpayment method. like @ezet said but it wasn't part of the parameters
@ezet from what im getting my paymentintent and all is going thru its just not showing on the frontend
@jaffakakes u can you try by providing a complete webReturnPath - something like http://urdomain/
I upgraded the version to 4.0.0 and now when i try to confirm the payment for the 3ds, the webview isn't opening. Am getting the below error.
'package:stripe_sdk/src/stripe.dart': Failed assertion: line 78 pos 12: 'kIsWeb == webReturnPath?.isNotEmpty ?? false': is not true.
Sample code for confirmPayment:
`
Stripe.init('key', returnUrlForSca: "stripesdk://3ds.stripesdk.io");
`
Any Idea why the sdk is complaining about the returnUrl missing?