Description
Using flutter_stripe package, version ^1.2.0, to perform payment on the front end, Google pay button wasn't displayed on the paymentSheet despite setting the flag googlePay: true in SetupPaymentSheetParameters while initializing the payment sheet using Stripe.instance.initPaymentSheet().
The examples project of the package doesn't provide information about configuring google pay in payment sheet other than setting the flag to true, so i followed these instructions form stripe's documentations to integrate google pay but the button still not displayed on the sheet.
My Code
stripe initialization
Stripe.publishableKey = dotenv.env['STRIPE_PUB_KEY'];
Stripe.instance.applySettings();
payment sheet methods
Future<void> initializePaymentSheet(
PaymentCredentials credentials,
) async {
Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
applePay: Stripe.instance.isApplePaySupported.value,
googlePay: true,
style: ThemeMode.dark,
testEnv: true,
merchantCountryCode: 'USA',
merchantDisplayName: 'Our App. Inc.',
customerId: credentials.clientId,
paymentIntentClientSecret: credentials.paymentIntent,
customerEphemeralKeySecret: credentials.eKey,
customFlow: false,
),
);
}
Future<void> presentPaymentSheet(String paymentIntent) async =>
Stripe.instance.presentPaymentSheet(
parameters: PresentPaymentSheetParameters(
clientSecret: paymentIntent,
confirmPayment: true,
),
);
What is missing to display this button on the sheet?
as #Romeo said in the comments above, Google pay button was displayed when gPay app is installed and there is at least one card available on it.
I was using separate google pay button on my app using pay plugin and it was displayed along with google pay sheet so i figured it should be shown on stripe's payment sheet as well.
Related
I create a payment through sofort, ideal, pass the specified parameters and every time I get an error-
Error from Stripe: Invalid Payment Intent client secret: src_client_secret_**********************
final paymentIntent = await Stripe.instance.confirmPayment(
paymentIntentClientSecret: clientSecret,
data: PaymentMethodParams.sofort(
paymentMethodData: PaymentMethodDataSofort(country: 'de'),
),
);
clientSecret-the key is generated without any problems
payment by card is fine
What am I doing wrong?
I am using the latest versions of the libraries: flutter_stripe: ^7.0.0
I looked through all the information in the library and couldn't find anything
I'm using flutter dependancies:
firebase_messaging: ^7.0.3
flutter_local_notifications: ^3.0.1+6
I send firebase cloud message like this:
{
"to": "/topics/demo_ios"
"notification" : {
"body" : "Hi there now now",
"title" : "Wow!",
"sound": "default"
},
"priority": "high"
"data": {
"title": "Hi there yes",
"body": "Wow",
}
}
In ios the notification shows when the app is in the foreground, however when in the background it doesn't show at all. I tried reading and fixing many things, but is still doesn't work. I set background fetch, remote notificaitons, and background processing from xcode, and it still doesn't work.
I set FirebaseAppDelegateProxyEnabled to false in the plist file, but it didn't help.
I request permission:
_messaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true, provisional: false)
);
_messaging.onIosSettingsRegistered.listen((event) {print('2124: ios Setting registered');});
first I recommend you to update the plugin to firebase_messaging: ^8.0.0-dev.8, because iOS background handling is enabled there. See here this change:
iOS background handler support.
Next, how to integrate all of that to your flutter project, please follow official documentation FlutterFire (this is documentation just after 8.x.x-dev versions of the plugin.
Finally, please read more about APN, because Apple is handling differently those messages and you need to have the APNSConfig property inside your script for sending notifications.
If you are sending notifications via FirebaseAdmin, then please read this.
Do not forget, that in that case, you need to set content_available=True which is contained inside the APNSConfig property, so basically if you are using FirebaseAdmin you should include also property similar to this one:
apns=messaging.APNSConfig(
payload=messaging.APNSPayload(
aps=messaging.Aps(
alert='alert text',
sound='s',
content_available=True,
mutable_content=True,
category='c',
thread_id='t',
custom_data={
'id': 'xxx',
'type': 'xxx',
'title': 'Robb',
'content': 'Axxxx',
'image': 'xxx',
'deepLink': 'xxxx',
},
),
)
),
I was also having the same problem ,try to upload IPA file on testflight then it work hope so.
Well, the solution was quite simple, and a mistake on my behalf.
As the documnents pub.dev state:
Generate the certificates required by Apple for receiving push notifications following this guide in the Firebase docs. You can skip the section titled "Create the Provisioning Profile".
Here is the link:
https://firebase.google.com/docs/cloud-messaging/ios/certs
I forgot to do these steps. After doing this, it worked
I want to perform negative testing with a PayPal checkout button
There is one method given in document for REST API. I tried to add header in my paypal render code as per documentation, but doesn't work.
paypal.Button.render({
env: 'sandbox',
client: {
production: 'XXXXX',
sandbox: 'XXXXX'
},
locale: 'en_US',
style: {
size: 'large',
color: 'blue',
shape: 'pill',
tagline: false,
label: 'paypal'
},
headers: {
"PayPal-Mock-Response" : {"mock_application_codes": "INSTRUMENT_DECLINED"}
},
commit: true,
payment: this.paypalPayment,
onAuthorize: this.paypalAuthCallback
}, '#paypal-button');
General REST API negative testing can only be done with a server-side integration, where your server communicates with the PayPal API directly, per https://developer.paypal.com/docs/checkout/reference/server-integration/ , and your front-end UI calls corresponding routes on your server per https://developer.paypal.com/demo/checkout/#/pattern/server
For some generated Card #s (not all Card #s), you can trigger an INSTRUMENT_DECLINED by setting the shipping address to CCREJECT-REFUSED https://developer.paypal.com/docs/archive/express-checkout/ht-ec-fundingfailure10486/#test-your-integration
Whatever you do, update from the old checkout.js (in your code example) to the latest sdk.js ; the client-side demo is here: https://developer.paypal.com/demo/checkout/#/pattern/client
I'm trying to integrate PayPal subscriptions using Smart Buttons in JavaScript with sandbox app & account.
paypal.Buttons(
{
style: {
layout: 'horizontal',
size: 'small',
color: 'gold',
label: 'paypal',
height: 35,
tagline: 'true'
},
createSubscription: function (data, actions) {
return actions.subscription.create({
'plan_id': 'P-xxxxxxxxxxxxxxxxxxxxxxxx'
});
},
onApprove: function (data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}
).render('#paypal-button-container');
After new window opens up I login with my sandbox bussiness account. The spinner appears and after a while I get a message "Something went wrong". I checked webhook and subscription is successfully created, but when PayPal navigates to checkout to approve it, the above happens.
I tried to use Subscriptions API and I made a call using Postman to create subscription. Then in response I recieved url to approve subscription. I opened it, logged in, this time I had to choose PayPal or Credit/Debit Card and again, spinner, some time passes and message appears saying "Something went wrong."
I checked wether encryption settings are disabled, cause I found it might cause issues, but it was disabled by deafult.
I also tried passing the whole subscription object from docs, not just "plan_id", but it changed nothing.
Don't have any other ideas what might went wrong. I hope someone stumbled upon this issue, found the solution and is willing to share it :D
I was trying to test sign-in to my home screen for my flutter app. I am using the google-signin ( https://pub.dev/packages/google_sign_in) package from Flutter to perform login and authentication. So once the login button is pressed, a popup appears asking the user to select the user account. At that point, I am unable to control the tap as this dialog screen is generated by the plugin. How do I implement selection of the user account in this case ?
test('Test Login', () async {
final Timeline timeline = await driver.traceAction(() async {
await driver.tap(find.byValueKey('GoogleLogin'));
await driver.tap(find.text('myemail#gmail.com')); // This will not work !!!
});
TimelineSummary.summarize(timeline)
..writeSummaryToFile('home_scroll_perf', pretty: true)
..writeTimelineToFile('home_scroll_perf', pretty: true);
});
In my opinion, this could be a problem when testing with any third party plugin. Please help.
It seems that the issue is still existing. There is no available workaround yet. Keep an eye on this GitHub post as this is closely monitored by the Flutter team.
Try Patrol, it lets you very easily interact with native UIs such as the Google sign-in dialog.
Below is a rough example of how I'd approach this. I'm going to assume that you're already signed in to a Google account, so the only thing you have to do is to select an email from the dialog.
// integration_test/sign_in_test.dart
void main() {
patrolTest(
'signs in with Google',
nativeAutomation: true,
(PatrolTester $) async {
await $.pumpWidgeAndSettle(YourAppWidget());
await $('Sign in with Google').tap();
await $.native.tap(Selector(text: 'your.email#gmail.com'));
await $.pumpAndSettle();
// should be signed in now
},
);
}
Remember: that integration tests has to be run with patrol drive, not flutter test integration_test.