Adyen / adyen-flutter

MIT License
23 stars 7 forks source link

Apple Pay Payment Method appear on Android device #119

Closed Thibault4 closed 8 months ago

Thibault4 commented 8 months ago

Describe the bug I'm encountering an unexpected behavior in my Flutter application where the Apple Pay payment method is appearing on Android devices. Despite the fact that the plugin I'm using is in beta, I wouldn't expect Apple Pay to be available on Android devices. This inconsistency is causing confusion for users and is not the intended behavior.

To Reproduce Steps to reproduce the behavior:

  1. Go to MyPage
  2. Click on Icon.card
  3. See Apple Pay method

Expected behavior ` import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:flutter/material.dart'; import 'package:dio/dio.dart';

class MyPage extends StatelessWidget { final String apiUrl = 'http://192.168.1.35:3000/api'; // Votre URL d'API Adyen

Future<Map<String, dynamic>> getSessionData() async { try { // Effectuez une requête HTTP GET à votre endpoint /sessions pour obtenir les données de session Response response = await Dio().post('$apiUrl/sessions'); print('Return data ' + response.data.toString()); return response.data; } catch (error) { throw Exception('Failed to load session data ' + error.toString()); } }

void startDropIn(BuildContext context) async { try { // Obtenez les données de session Map<String, dynamic> sessionData = await getSessionData();

  // Créez la configuration DropIn
  DropInConfiguration dropInConfiguration = DropInConfiguration(
    environment: Environment
        .test, // Changez pour 'live' lorsque vous êtes prêt à accepter de vrais paiements
    clientKey: '*******',
    countryCode: 'fr',
    shopperLocale: 'fr',
    amount: Amount(value: 1000, currency: 'EUR'),
  );

  final SessionCheckout sessionCheckout =
      await AdyenCheckout.session.create(
    sessionId: sessionData['id'],
    sessionData: sessionData['sessionData'],
    configuration: dropInConfiguration,
  );

  final PaymentResult paymentResult =
      await AdyenCheckout.session.startDropIn(
    dropInConfiguration: dropInConfiguration,
    checkout: sessionCheckout,
  );

  if (paymentResult is PaymentError) {
    print('Error ' + paymentResult.reason!);
  } else {
    print(paymentResult);
  }
} catch (error) {
  // Gérer les erreurs
  print('Error starting Drop-in: $error');
}

}

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Adyen Payment Demo'), ), body: Center( child: IconButton( onPressed: () { startDropIn(context); }, icon: const Icon(Icons.payment), ), ), ); } } `

Screenshots Screenshot_1708161059 Screenshot_1708161107

Smartphone (please complete the following information):

Additional context On iOS I don't have google pay that is ok

Robert-SD commented 8 months ago

Hello @Thibault4,

Thanks for providing the bug description. The expected behavior is correct and Apple Pay is not supported on Android devices.

In order to filter out non supported payment methods, it is necessary to provide the “channel” parameter in the POST /sessions request body in your backend implementation. The value needs to be set to either “iOS” or “Android” depending on the platform where the payment transaction takes place.

Could you add this parameter and test it again? Apple Pay should not appear anymore on the Android device.

Please let me know if you need further assistance.

Robert-SD commented 8 months ago

Hi @Thibault4, just wanted to catch up and ask if you were able to solve the issue by including the channel parameter in your request?

Robert-SD commented 8 months ago

Hello @Thibault4, we closed the issue. Feel free to reach out in case you need any further assistance.