├── ios ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterPayPlugin.h │ ├── FlutterPayPlugin.m │ ├── MerchantCapabilitiesHelper.swift │ ├── PaymentNetworkHelper.swift │ └── SwiftFlutterPayPlugin.swift ├── .gitignore └── flutter_pay.podspec ├── android ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── kotlin │ │ └── com │ │ └── xamelon │ │ └── flutter_pay │ │ ├── AllowedAuthMethods.kt │ │ ├── PaymentNetworkHelper.kt │ │ └── FlutterPayPlugin.kt └── build.gradle ├── analysis_options.yaml ├── example ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── Runner.entitlements │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ ├── Podfile.lock │ ├── .gitignore │ └── Podfile ├── android │ ├── gradle.properties │ ├── .gitignore │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── xamelon │ │ │ │ │ │ └── flutter_pay_example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ └── build.gradle ├── .metadata ├── test │ └── widget_test.dart ├── README.md ├── .gitignore ├── pubspec.yaml ├── lib │ └── main.dart └── pubspec.lock ├── res └── flutter_pay.png ├── lib ├── src │ ├── payment_environment.dart │ ├── payment_item.dart │ ├── flutter_pay_error.dart │ ├── apple_parameters.dart │ ├── card_auth_methods.dart │ ├── merchant_capability.dart │ ├── google_parameters.dart │ ├── payment_network.dart │ └── flutter_pay.dart └── flutter_pay.dart ├── CHANGELOG.md ├── .metadata ├── test └── flutter_pay_test.dart ├── pubspec.yaml ├── LICENSE ├── .gitignore ├── README.md └── pubspec.lock /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_pay' 2 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:effective_dart/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /res/flutter_pay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/res/flutter_pay.png -------------------------------------------------------------------------------- /lib/src/payment_environment.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | enum PaymentEnvironment { Test, Production } 4 | -------------------------------------------------------------------------------- /ios/Classes/FlutterPayPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterPayPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamelon/flutter_pay/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip 6 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 4 | - Migrate to Null Safety 5 | - Fix AmericanExpress on Android 6 | 7 | ## 0.10.0 8 | 9 | - Add Google/Apple Pay options 10 | - Code clean-up 11 | - Bug fixes 12 | 13 | ## 0.9.1 14 | 15 | - Fixed pana errors 16 | 17 | ## 0.9.0 18 | 19 | - Initial release 20 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /lib/src/payment_item.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class PaymentItem { 4 | final String name; 5 | final double price; 6 | 7 | PaymentItem({required this.name, required this.price}); 8 | 9 | Map toJson() => { 10 | "name": name, 11 | "price": price.toStringAsFixed(2), 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /lib/src/flutter_pay_error.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class FlutterPayError extends Error { 4 | final String? description; 5 | final String? code; 6 | 7 | FlutterPayError({this.code, this.description}); 8 | 9 | @override 10 | String toString() { 11 | return '''\n 12 | Error: $code. 13 | Description: $description'''; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.in-app-payments 6 | 7 | merchant.flutterpay.example 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/xamelon/flutter_pay/AllowedAuthMethods.kt: -------------------------------------------------------------------------------- 1 | package com.xamelon.flutter_pay 2 | 3 | fun decodeAuthMethods(name: String): String? { 4 | return when (name) { 5 | "PAN_ONLY" -> "PAN_ONLY" 6 | "CRYPTOGRAM_3DS" -> "CRYPTOGRAM_3DS" 7 | else -> null 8 | } 9 | } 10 | 11 | var availableAuthMethods: List = listOf("PAN_ONLY", "CRYPTOGRAM_3DS") 12 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/flutter_pay.dart: -------------------------------------------------------------------------------- 1 | library flutter_pay; 2 | 3 | import 'dart:io'; 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:flutter/services.dart'; 6 | 7 | part 'src/flutter_pay.dart'; 8 | part 'src/flutter_pay_error.dart'; 9 | part 'src/payment_environment.dart'; 10 | part 'src/payment_item.dart'; 11 | part 'src/payment_network.dart'; 12 | part 'src/apple_parameters.dart'; 13 | part 'src/google_parameters.dart'; 14 | part 'src/card_auth_methods.dart'; 15 | part 'src/merchant_capability.dart'; 16 | -------------------------------------------------------------------------------- /test/flutter_pay_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | 4 | void main() { 5 | const MethodChannel channel = MethodChannel('flutter_pay'); 6 | 7 | TestWidgetsFlutterBinding.ensureInitialized(); 8 | 9 | setUp(() { 10 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 11 | return '42'; 12 | }); 13 | }); 14 | 15 | tearDown(() { 16 | channel.setMockMethodCallHandler(null); 17 | }); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/xamelon/flutter_pay/PaymentNetworkHelper.kt: -------------------------------------------------------------------------------- 1 | package com.xamelon.flutter_pay 2 | 3 | fun decodePaymentNetwork(name: String): String? { 4 | return when (name) { 5 | "VISA" -> "VISA" 6 | "MASTERCARD" -> "MASTERCARD" 7 | "DISCOVER" -> "DISCOVER" 8 | "JCB" -> "JCB" 9 | "AMERICANEXPRESS" -> "AMEX" 10 | else -> null 11 | } 12 | } 13 | 14 | var availablePaymentNetworks: List = listOf("VISA", "MASTERCARD", "DISCOVER", "JCB", "AMEX") 15 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/xamelon/flutter_pay_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.xamelon.flutter_pay_example 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/src/apple_parameters.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class AppleParameters { 4 | final String merchantIdentifier; 5 | final List? merchantCapabilities; 6 | 7 | AppleParameters({ 8 | required this.merchantIdentifier, 9 | this.merchantCapabilities, 10 | }); 11 | 12 | Map toMap() { 13 | return { 14 | 'merchantIdentifier': merchantIdentifier, 15 | 'merchantCapabilities': 16 | merchantCapabilities?.map((e) => e.getName).toList() ?? [], 17 | }; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /lib/src/card_auth_methods.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class CardAuthMethods { 4 | final String _name; 5 | 6 | CardAuthMethods._(this._name); 7 | 8 | ///Cards on file on Google.com linked to user account 9 | static CardAuthMethods get panOnly => CardAuthMethods._("PAN_ONLY"); 10 | 11 | ///Device token on an Android device authenticated 12 | ///with a 3-D Secure cryptogram 13 | static CardAuthMethods get cryptogram3ds => 14 | CardAuthMethods._("CRYPTOGRAM_3DS"); 15 | 16 | /// Get payment networks name 17 | String get getName => _name.toUpperCase(); 18 | } 19 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_pay (0.0.1): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `Flutter`) 8 | - flutter_pay (from `.symlinks/plugins/flutter_pay/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: Flutter 13 | flutter_pay: 14 | :path: ".symlinks/plugins/flutter_pay/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c 18 | flutter_pay: b9fda1c5be6ddc7af769f26553e9c648fc551263 19 | 20 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 21 | 22 | COCOAPODS: 1.10.0 23 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | 12 | void main() { 13 | testWidgets('Verify Platform version', (WidgetTester tester) async { 14 | 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_pay_example 2 | 3 | Demonstrates how to use the flutter_pay plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /ios/Classes/FlutterPayPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterPayPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_pay-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterPayPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterPayPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_pay 2 | description: Flutter plugin that help you make payments through Apple and Google Pay 3 | version: 1.0.1 4 | homepage: https://github.com/xamelon/flutter_pay 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=1.10.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | effective_dart: ^1.2.3 16 | flutter_test: 17 | sdk: flutter 18 | 19 | flutter: 20 | plugin: 21 | platforms: 22 | android: 23 | package: com.xamelon.flutter_pay 24 | pluginClass: FlutterPayPlugin 25 | ios: 26 | pluginClass: FlutterPayPlugin 27 | 28 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | var = "1.8" 3 | } 4 | buildscript { 5 | ext.kotlin_version = '1.6.10' 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:7.2.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | } 23 | 24 | rootProject.buildDir = '../build' 25 | subprojects { 26 | project.buildDir = "${rootProject.buildDir}/${project.name}" 27 | } 28 | subprojects { 29 | project.evaluationDependsOn(':app') 30 | } 31 | 32 | task clean(type: Delete) { 33 | delete rootProject.buildDir 34 | } 35 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/flutter_pay.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_pay.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_pay' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '8.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /ios/Classes/MerchantCapabilitiesHelper.swift: -------------------------------------------------------------------------------- 1 | import PassKit 2 | 3 | class MerchantCapabilitiesHelper { 4 | static func decodeCapabilities(_ capabilities: [String]?) -> PKMerchantCapability { 5 | if(capabilities == nil){ 6 | return .capability3DS; 7 | } 8 | 9 | var decodeCapabilities: PKMerchantCapability = []; 10 | 11 | if(capabilities!.contains(".CAPABILITY3DS") ){ 12 | decodeCapabilities = decodeCapabilities.union(.capability3DS) 13 | } 14 | if(capabilities!.contains(".CAPABILITYEMV")){ 15 | decodeCapabilities = decodeCapabilities.union(.capabilityEMV) 16 | } 17 | if(capabilities!.contains(".CAPABILITYCREDIT")){ 18 | decodeCapabilities = decodeCapabilities.union(.capabilityCredit) 19 | } 20 | if(capabilities!.contains(".CAPABILITYDEBIT")){ 21 | decodeCapabilities = decodeCapabilities.union(.capabilityDebit) 22 | } 23 | if(!capabilities!.contains(".CAPABILITY3DS") && !capabilities!.contains(".CAPABILITYEMV")){ 24 | decodeCapabilities = decodeCapabilities.union(.capability3DS) 25 | } 26 | 27 | return decodeCapabilities; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.xamelon.flutter_pay' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.6.10' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:7.2.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | compileOptions { 41 | sourceCompatibility = "1.8" 42 | targetCompatibility = 1.8 43 | } 44 | buildToolsVersion = '28.0.3' 45 | } 46 | 47 | dependencies { 48 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 49 | implementation 'com.google.android.gms:play-services-wallet:19.1.0' 50 | } 51 | -------------------------------------------------------------------------------- /lib/src/merchant_capability.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | ///The capability3DS and capabilityEMV values of PKMerchantCapability specify 4 | ///the supported cryptographic payment protocols. At least one of these two 5 | ///values is required. 6 | ///Check with your payment processors about the cryptographic payment protocols 7 | ///they support. As a general rule, if you want to support China UnionPay 8 | ///cards, you use capabilityEMV. To support cards from other networks—like 9 | ///American Express, Visa, or Mastercard—use capability3DS. 10 | ///To filter the types of cards to make available for the transaction, pass the 11 | ///capabilityCredit and capabilityDebit values. If neither is passed, all card 12 | ///types will be available. 13 | class MerchantCapability { 14 | final String _name; 15 | 16 | MerchantCapability._(this._name); 17 | 18 | ///Support for debit cards. 19 | static MerchantCapability get debit => 20 | MerchantCapability._(".capabilityDebit"); 21 | 22 | ///Support for credit cards. 23 | static MerchantCapability get credit => 24 | MerchantCapability._(".capabilityCredit"); 25 | 26 | ///Support for the 3-D Secure protocol. 27 | static MerchantCapability get threeDS => 28 | MerchantCapability._(".capability3DS"); 29 | 30 | ///Support for the 3-D Secure protocol. 31 | static MerchantCapability get emv => MerchantCapability._(".capabilityEMV"); 32 | 33 | /// Get merchant capabilties name 34 | String get getName => _name.toUpperCase(); 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/google_parameters.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | // https://developers.google.com/pay/api/web/reference/request-objects#gateway 4 | class GoogleParameters { 5 | final String gatewayName; 6 | final String? gatewayMerchantId; 7 | final Map? gatewayArgs; 8 | final String? merchantId; 9 | final String? merchantName; 10 | final List allowedCardAuthMethods; 11 | 12 | GoogleParameters( 13 | {required this.gatewayName, 14 | this.gatewayMerchantId, 15 | this.gatewayArgs, 16 | this.merchantId, 17 | this.merchantName, 18 | this.allowedCardAuthMethods = const []}) 19 | : assert( 20 | ((gatewayMerchantId != null) ^ (gatewayArgs != null)), 21 | "You can not use gatewayMerchantId and gatewayArgs at the same time", 22 | ); 23 | 24 | Map toMap() { 25 | Map map = { 26 | 'gatewayName': gatewayName, 27 | }; 28 | 29 | if (merchantId != null) { 30 | map["merchantId"] = merchantId!; 31 | } 32 | 33 | if (merchantName != null) { 34 | map["merchantName"] = merchantName!; 35 | } 36 | 37 | map["allowedAuthMethods"] = 38 | allowedCardAuthMethods.map((method) => method.getName).toList(); 39 | 40 | if (gatewayMerchantId != null) { 41 | map.addAll({'gatewayMerchantId': gatewayMerchantId!}); 42 | } 43 | if (gatewayArgs != null) { 44 | map.addAll(gatewayArgs!); 45 | } 46 | 47 | return map; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_pay_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | fvm 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | .vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | .dart_tool/ 27 | .flutter-plugins 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Generated.xcconfig 62 | **/ios/Flutter/app.flx 63 | **/ios/Flutter/app.zip 64 | **/ios/Flutter/flutter_assets/ 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_pay_example 2 | description: Demonstrates how to use the flutter_pay plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.1.0 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | # The following adds the Cupertino Icons font to your application. 13 | # Use with the CupertinoIcons class for iOS style icons. 14 | cupertino_icons: ^0.1.2 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | 20 | flutter_pay: 21 | path: ../ 22 | 23 | # For information on the generic Dart part of this file, see the 24 | # following page: https://dart.dev/tools/pub/pubspec 25 | 26 | # The following section is specific to Flutter. 27 | flutter: 28 | 29 | # The following line ensures that the Material Icons font is 30 | # included with your application, so that you can use the icons in 31 | # the material Icons class. 32 | uses-material-design: true 33 | 34 | # To add assets to your application, add an assets section, like this: 35 | # assets: 36 | # - images/a_dot_burr.jpeg 37 | # - images/a_dot_ham.jpeg 38 | 39 | # An image asset can refer to one or more resolution-specific "variants", see 40 | # https://flutter.dev/assets-and-images/#resolution-aware. 41 | 42 | # For details regarding adding assets from package dependencies, see 43 | # https://flutter.dev/assets-and-images/#from-packages 44 | 45 | # To add custom fonts to your application, add a fonts section here, 46 | # in this "flutter" section. Each entry in this list should have a 47 | # "family" key with the font family name, and a "fonts" key with a 48 | # list giving the asset and other descriptors for the font. For 49 | # example: 50 | # fonts: 51 | # - family: Schyler 52 | # fonts: 53 | # - asset: fonts/Schyler-Regular.ttf 54 | # - asset: fonts/Schyler-Italic.ttf 55 | # style: italic 56 | # - family: Trajan Pro 57 | # fonts: 58 | # - asset: fonts/TrajanPro.ttf 59 | # - asset: fonts/TrajanPro_Bold.ttf 60 | # weight: 700 61 | # 62 | # For details regarding fonts from package dependencies, 63 | # see https://flutter.dev/custom-fonts/#from-packages 64 | -------------------------------------------------------------------------------- /lib/src/payment_network.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class PaymentNetwork { 4 | final String _name; 5 | 6 | PaymentNetwork._(this._name); 7 | 8 | /// Available on iOS and Android 9 | static PaymentNetwork get visa => PaymentNetwork._("VISA"); 10 | 11 | /// Available on iOS and Android 12 | static PaymentNetwork get masterCard => PaymentNetwork._("MasterCard"); 13 | 14 | /// Available on iOS and Android 15 | static PaymentNetwork get amex => PaymentNetwork._("AmericanExpress"); 16 | 17 | /// Available on iOS and Android 18 | static PaymentNetwork get interac => PaymentNetwork._("Interac"); 19 | 20 | /// Available on iOS and Android 21 | static PaymentNetwork get discover => PaymentNetwork._("Discover"); 22 | 23 | /// Available on iOS and Android 24 | static PaymentNetwork get jcb => PaymentNetwork._("JCB"); 25 | 26 | /// Available only on iOS 27 | static PaymentNetwork get maestro => PaymentNetwork._("Maestro"); 28 | 29 | /// Available only on iOS 30 | static PaymentNetwork get electron => PaymentNetwork._("Electron"); 31 | 32 | /// Available only on iOS 33 | static PaymentNetwork get cartesBancarries => 34 | PaymentNetwork._("CartesBancarries"); 35 | 36 | /// Available only on iOS 37 | static PaymentNetwork get unionPay => PaymentNetwork._("UnionPay"); 38 | 39 | /// Available only on iOS 40 | static PaymentNetwork get eftPos => PaymentNetwork._("EftPos"); 41 | 42 | /// Available only on iOS 43 | static PaymentNetwork get elo => PaymentNetwork._("Elo"); 44 | 45 | /// Available only on iOS 46 | static PaymentNetwork get idCredit => PaymentNetwork._("IDCredit"); 47 | 48 | /// Available only on iOS 49 | static PaymentNetwork get mada => PaymentNetwork._("Mada"); 50 | 51 | /// Available only on iOS 52 | static PaymentNetwork get privateLabel => PaymentNetwork._("PrivateLabel"); 53 | 54 | /// Available only on iOS 55 | static PaymentNetwork get quicPay => PaymentNetwork._("QuicPay"); 56 | 57 | /// Available only on iOS 58 | static PaymentNetwork get suica => PaymentNetwork._("Suica"); 59 | 60 | /// Available only on iOS 61 | static PaymentNetwork get vPay => PaymentNetwork._("VPay"); 62 | 63 | /// Get payment networks name 64 | String get getName => _name.toUpperCase(); 65 | } 66 | -------------------------------------------------------------------------------- /ios/Classes/PaymentNetworkHelper.swift: -------------------------------------------------------------------------------- 1 | import PassKit 2 | 3 | class PaymentNetworkHelper { 4 | 5 | static func decodePaymentNetwork(_ paymentNetwork: String) -> PKPaymentNetwork? { 6 | switch(paymentNetwork) { 7 | case "VISA": 8 | return .visa 9 | case "MASTERCARD": 10 | return .masterCard 11 | case "AMERICANEXPRESS": 12 | return .amex 13 | case "INTERAC": 14 | if #available(iOS 9.2, *) { return .interac } 15 | return nil 16 | case "DISCOVER": 17 | if #available(iOS 9.0, *) { return .discover } 18 | return nil 19 | case "JCB": 20 | if #available(iOS 10.1, *) { return .JCB } 21 | return nil 22 | case "MAESTRO": 23 | if #available(iOS 12.0, *) { return .maestro } 24 | return nil 25 | case "ELECTRON": 26 | if #available(iOS 12.0, *) { return .electron } 27 | return nil 28 | case "CARTESBANCARRIES": 29 | if #available(iOS 10.3, *) { return .carteBancaire } 30 | else if #available(iOS 11.0, *) { return .carteBancaires } 31 | else if #available(iOS 11.2, *) { return .cartesBancaires } 32 | return nil 33 | case "UNIONPAY": 34 | if #available(iOS 9.2, *) { return .chinaUnionPay } 35 | return nil 36 | case "EFTPOS": 37 | if #available(iOS 12.0, *) { return .eftpos} 38 | return nil 39 | case "ELO": 40 | if #available(iOS 12.1.1, *) { return .elo } 41 | return nil 42 | case "IDCREDIT": 43 | if #available(iOS 10.3, *) { return .idCredit } 44 | return nil 45 | case "MADA": 46 | if #available(iOS 12.1.1, *) { return .mada } 47 | return nil 48 | case "PRIVATELABEL": 49 | if #available(iOS 9.0, *) { return .privateLabel } 50 | return nil 51 | case "QUICPAY": 52 | if #available(iOS 10.3, *) { return .quicPay } 53 | return nil 54 | case "SUICA": 55 | if #available(iOS 10.1, *) { return .suica } 56 | return nil 57 | case "VPAY": 58 | if #available(iOS 12.0, *) { return .vPay } 59 | return nil 60 | default: 61 | return nil 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 32 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.xamelon.flutter_pay_example" 42 | minSdkVersion 19 43 | targetSdkVersion 32 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | compileOptions { 57 | sourceCompatibility = "1.8" 58 | targetCompatibility = "1.8" 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | testImplementation 'junit:junit:4.13.2' 69 | androidTestImplementation 'androidx.test:runner:1.4.0' 70 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 71 | } 72 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | flutter_pay 2 | 3 | ## Google Pay Preparing 4 | 5 | #### TODO 6 | 7 | See Android [documentation](https://developers.google.com/pay/api/android/overview) 8 | 9 | ## Apple Pay Preparing 10 | 11 | #### TODO 12 | 13 | See Apple [documentation](https://developer.apple.com/documentation/passkit/apple_pay/setting_up_apple_pay_requirements) 14 | 15 | ## Usage 16 | 17 | Firstly, you need to make sure, that Pay api is available on device: 18 | ```dart 19 | import 'package:flutter_pay/flutter_pay.dart'; 20 | //.. 21 | 22 | FlutterPay flutterPay = FlutterPay(); 23 | 24 | bool isAvailable = await flutterPay.canMakePayments(); 25 | /.. 26 | ``` 27 | 28 | If you need to check if user has at least one active card: 29 | ```dart 30 | import 'package:flutter_pay/flutter_pay.dart'; 31 | //.. 32 | 33 | FlutterPay flutterPay = FlutterPay(); 34 | 35 | bool isAvailable = await flutterPay.canMakePaymentsWithActiveCard(); 36 | 37 | //Also you can state allowed payment card networks: 38 | bool isAvailable = await flutterPay.canMakePaymentsWithActiveCard( 39 | allowedPaymentNetworks: [ 40 | PaymentNetwork.visa, 41 | PaymentNetwork.masterCard, 42 | ], 43 | ); 44 | ``` 45 | 46 | To make payment is ```requestPayment``` method. This function will return to you token that you need to send to your gateway to complete payment. 47 | Example: 48 | ```dart 49 | import 'package:flutter_pay/flutter_pay.dart'; 50 | 51 | PaymentItem item = PaymentItem(name: "T-Shirt", price: 2.98); 52 | 53 | FlutterPay flutterPay = FlutterPay(); 54 | 55 | flutterPay.setEnvironment(environment: PaymentEnvironment.Test); 56 | 57 | String token = await flutterPay.requestPayment( 58 | googleParameters: GoogleParameters( 59 | gatewayName: "example", 60 | gatewayMerchantId: "example_id", 61 | merchantId: "example_merchant_id", 62 | merchantName: "exampleMerchantName", 63 | ), 64 | appleParameters: 65 | AppleParameters(merchantIdentifier: "merchant.flutterpay.example"), 66 | currencyCode: "USD", 67 | countryCode: "US", 68 | paymentItems: items, 69 | ); 70 | ``` 71 | 72 | Note that some arguments affects only Apple Pay or Google Pay. For example, **paymentItems** affects only Apple Pay. And the last item is used for grand total label. 73 | 74 | **merchantName** affects only Google Pay and will be shown to user. 75 | 76 | **gatewayName** also affects only Google Pay. See Google Pay integration section. 77 | 78 | ## Payment Network matrix 79 | 80 | | Payment Network | iOS | Android | 81 | |-------------------|-----|---------| 82 | | Visa | + | + | 83 | | MasterCard | + | + | 84 | | American Express | + | + | 85 | | Interac | + | + | 86 | | Discover | + | + | 87 | | JCB | + | + | 88 | | Maestro | + | | 89 | | Electron | + | | 90 | | Cartes Bancarries | + | | 91 | | Union Pay | + | | 92 | | EftPos | + | | 93 | | Elo | + | | 94 | | ID Credit | + | | 95 | | Mada | + | | 96 | | Private Label | + | | 97 | | Quic Pay | + | | 98 | | Suica | + | | 99 | | V Pay | + | | 100 | 101 | ## Roadmap 102 | 103 | - [x] Basic implementation 104 | - [ ] Complete docs 105 | - [ ] Add merchant capabilities support 106 | - [ ] Add billing and shipping info support 107 | 108 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:flutter_pay/flutter_pay.dart'; 4 | 5 | void main() => runApp(MyApp()); 6 | 7 | class MyApp extends StatefulWidget { 8 | @override 9 | _MyAppState createState() => _MyAppState(); 10 | } 11 | 12 | class _MyAppState extends State { 13 | FlutterPay flutterPay = FlutterPay(); 14 | 15 | String result = "Result will be shown here"; 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | } 21 | 22 | void makePayment() async { 23 | List items = [PaymentItem(name: "T-Shirt", price: 2.98)]; 24 | 25 | flutterPay.setEnvironment(environment: PaymentEnvironment.Test); 26 | 27 | flutterPay.requestPayment( 28 | googleParameters: GoogleParameters( 29 | gatewayName: "example", 30 | gatewayMerchantId: "example_id", 31 | ), 32 | appleParameters: AppleParameters( 33 | merchantIdentifier: "merchant.flutterpay.example", 34 | merchantCapabilities: [ 35 | MerchantCapability.threeDS, 36 | MerchantCapability.credit, 37 | MerchantCapability.debit 38 | ], 39 | ), 40 | currencyCode: "USD", 41 | countryCode: "US", 42 | paymentItems: items, 43 | ); 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return MaterialApp( 49 | home: Scaffold( 50 | appBar: AppBar( 51 | title: const Text('Plugin example app'), 52 | ), 53 | body: Container( 54 | padding: EdgeInsets.all(12.0), 55 | child: Column( 56 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 57 | children: [ 58 | Text( 59 | this.result, 60 | style: TextStyle( 61 | fontSize: 16.0, 62 | ), 63 | ), 64 | FlatButton( 65 | child: Text("Can make payments?"), 66 | onPressed: () async { 67 | try { 68 | bool result = await flutterPay.canMakePayments(); 69 | setState(() { 70 | this.result = "Can make payments: $result"; 71 | }); 72 | } catch (e) { 73 | setState(() { 74 | this.result = "$e"; 75 | }); 76 | } 77 | }, 78 | ), 79 | FlatButton( 80 | child: Text("Can make payments with verified card: $result"), 81 | onPressed: () async { 82 | try { 83 | bool result = 84 | await flutterPay.canMakePaymentsWithActiveCard( 85 | allowedPaymentNetworks: [ 86 | PaymentNetwork.visa, 87 | PaymentNetwork.masterCard, 88 | ], 89 | ); 90 | setState(() { 91 | this.result = "$result"; 92 | }); 93 | } catch (e) { 94 | setState(() { 95 | this.result = "Error: $e"; 96 | }); 97 | } 98 | }, 99 | ), 100 | FlatButton( 101 | child: Text("Try to pay?"), 102 | onPressed: () { 103 | makePayment(); 104 | }) 105 | ]), 106 | ), 107 | ), 108 | ); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/src/flutter_pay.dart: -------------------------------------------------------------------------------- 1 | part of flutter_pay; 2 | 3 | class FlutterPay { 4 | final MethodChannel _channel = MethodChannel('flutter_pay'); 5 | 6 | /// Switch Google Pay [environment] 7 | /// 8 | /// See [PaymentEnvironment] 9 | void setEnvironment( 10 | {PaymentEnvironment environment = PaymentEnvironment.Test}) { 11 | var params = { 12 | "isTestEnvironment": environment == PaymentEnvironment.Test, 13 | }; 14 | _channel.invokeMethod('switchEnvironment', params); 15 | } 16 | 17 | /// Returns `true` if Apple/ Google Pay is available on device 18 | Future canMakePayments() async { 19 | final canMakePayments = await _channel.invokeMethod('canMakePayments'); 20 | return canMakePayments; 21 | } 22 | 23 | /// Returns true if Apple/Google Pay is available on device and there is at least one activated card 24 | /// 25 | /// You can set allowed payment networks in [allowedPaymentNetworks] parameter. 26 | /// See [PaymentNetwork] 27 | Future canMakePaymentsWithActiveCard( 28 | {required List allowedPaymentNetworks}) async { 29 | var paymentNetworks = 30 | allowedPaymentNetworks.map((network) => network.getName).toList(); 31 | var params = {"paymentNetworks": paymentNetworks}; 32 | 33 | final canMakePayments = 34 | await _channel.invokeMethod('canMakePaymentsWithActiveCard', params); 35 | return canMakePayments; 36 | } 37 | 38 | /// Process the payment and returns the token from Apple/Google pay 39 | /// 40 | /// Can throw [FlutterPayError] 41 | /// 42 | /// * [googleParameters] - options for Google Pay 43 | /// * [appleParameters] - options for Apple Pay 44 | /// * [allowedPaymentNetworks] - List of allowed payment networks. 45 | /// See [PaymentNetwork]. 46 | /// * [allowedCardAuthMethods] - List of allowed authenticaion methods 47 | /// methods for Google Pay. 48 | /// * [paymentItems] - affects only Apple Pay. See [PaymentItem] 49 | /// * [merchantName] - affects only Google Pay. 50 | /// Mercant name which will be displayed to customer. 51 | Future requestPayment({ 52 | GoogleParameters? googleParameters, 53 | AppleParameters? appleParameters, 54 | List allowedPaymentNetworks = const [], 55 | required List paymentItems, 56 | bool emailRequired = false, 57 | required String currencyCode, 58 | required String countryCode, 59 | }) async { 60 | var items = paymentItems.map((item) => item.toJson()).toList(); 61 | var params = { 62 | "currencyCode": currencyCode, 63 | "countryCode": countryCode, 64 | "allowedPaymentNetworks": 65 | allowedPaymentNetworks.map((network) => network.getName).toList(), 66 | "items": items, 67 | "emailRequired": emailRequired, 68 | }; 69 | 70 | if (Platform.isAndroid && googleParameters != null) { 71 | params.addAll(googleParameters.toMap()); 72 | } else if (Platform.isIOS && appleParameters != null) { 73 | params.addAll(appleParameters.toMap()); 74 | } else { 75 | throw FlutterPayError(description: ""); 76 | } 77 | 78 | try { 79 | var response = await _channel.invokeMethod('requestPayment', params); 80 | var payResponse = Map.from(response); 81 | if (payResponse == null) { 82 | throw FlutterPayError(description: "Pay response cannot be parsed"); 83 | } 84 | 85 | var paymentToken = payResponse["token"]; 86 | if (paymentToken != null) { 87 | print("Payment token: $paymentToken"); 88 | return paymentToken; 89 | } else { 90 | print("Payment token: null"); 91 | return ""; 92 | } 93 | } on PlatformException catch (error) { 94 | if (error.code == "userCancelledError") { 95 | print(error.message); 96 | return ""; 97 | } 98 | if (error.code == "paymentError") { 99 | print(error.message); 100 | return ""; 101 | } 102 | throw FlutterPayError(code: error.code, description: error.message); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.16.0" 46 | effective_dart: 47 | dependency: "direct dev" 48 | description: 49 | name: effective_dart 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.2.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.3.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | matcher: 71 | dependency: transitive 72 | description: 73 | name: matcher 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.12.11" 77 | material_color_utilities: 78 | dependency: transitive 79 | description: 80 | name: material_color_utilities 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "0.1.4" 84 | meta: 85 | dependency: transitive 86 | description: 87 | name: meta 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.7.0" 91 | path: 92 | dependency: transitive 93 | description: 94 | name: path 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "1.8.1" 98 | sky_engine: 99 | dependency: transitive 100 | description: flutter 101 | source: sdk 102 | version: "0.0.99" 103 | source_span: 104 | dependency: transitive 105 | description: 106 | name: source_span 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.8.2" 110 | stack_trace: 111 | dependency: transitive 112 | description: 113 | name: stack_trace 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.10.0" 117 | stream_channel: 118 | dependency: transitive 119 | description: 120 | name: stream_channel 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "2.1.0" 124 | string_scanner: 125 | dependency: transitive 126 | description: 127 | name: string_scanner 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.1.0" 131 | term_glyph: 132 | dependency: transitive 133 | description: 134 | name: term_glyph 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.2.0" 138 | test_api: 139 | dependency: transitive 140 | description: 141 | name: test_api 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "0.4.9" 145 | vector_math: 146 | dependency: transitive 147 | description: 148 | name: vector_math 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.1.2" 152 | sdks: 153 | dart: ">=2.17.0-0 <3.0.0" 154 | flutter: ">=1.10.0" 155 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.16.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "0.1.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.3.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_pay: 66 | dependency: "direct dev" 67 | description: 68 | path: ".." 69 | relative: true 70 | source: path 71 | version: "1.0.1" 72 | flutter_test: 73 | dependency: "direct dev" 74 | description: flutter 75 | source: sdk 76 | version: "0.0.0" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "0.12.11" 84 | material_color_utilities: 85 | dependency: transitive 86 | description: 87 | name: material_color_utilities 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "0.1.4" 91 | meta: 92 | dependency: transitive 93 | description: 94 | name: meta 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "1.7.0" 98 | path: 99 | dependency: transitive 100 | description: 101 | name: path 102 | url: "https://pub.dartlang.org" 103 | source: hosted 104 | version: "1.8.1" 105 | sky_engine: 106 | dependency: transitive 107 | description: flutter 108 | source: sdk 109 | version: "0.0.99" 110 | source_span: 111 | dependency: transitive 112 | description: 113 | name: source_span 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.8.2" 117 | stack_trace: 118 | dependency: transitive 119 | description: 120 | name: stack_trace 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.10.0" 124 | stream_channel: 125 | dependency: transitive 126 | description: 127 | name: stream_channel 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "2.1.0" 131 | string_scanner: 132 | dependency: transitive 133 | description: 134 | name: string_scanner 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.1.0" 138 | term_glyph: 139 | dependency: transitive 140 | description: 141 | name: term_glyph 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.2.0" 145 | test_api: 146 | dependency: transitive 147 | description: 148 | name: test_api 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "0.4.9" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "2.1.2" 159 | sdks: 160 | dart: ">=2.17.0-0 <3.0.0" 161 | flutter: ">=1.10.0" 162 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterPayPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import PassKit 4 | 5 | @available(iOS 10.0, *) 6 | public class SwiftFlutterPayPlugin: NSObject, FlutterPlugin { 7 | 8 | let paymentAuthorizationController = PKPaymentAuthorizationController() 9 | 10 | public static func register(with registrar: FlutterPluginRegistrar) { 11 | let channel = FlutterMethodChannel(name: "flutter_pay", binaryMessenger: registrar.messenger()) 12 | let instance = SwiftFlutterPayPlugin() 13 | registrar.addMethodCallDelegate(instance, channel: channel) 14 | } 15 | 16 | private var flutterResult: FlutterResult? 17 | 18 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 19 | if(call.method == "canMakePayments") { 20 | canMakePayment(result: result) 21 | } else if(call.method == "canMakePaymentsWithActiveCard") { 22 | canMakePaymentsWithActiveCard(arguments: call.arguments, result: result) 23 | } else if(call.method == "requestPayment") { 24 | requestPayment(arguments: call.arguments, result: result) 25 | } else if(call.method == "switchEnvironment") {} 26 | 27 | } 28 | 29 | func canMakePayment(arguments: Any? = nil, result: @escaping FlutterResult) { 30 | let canMakePayment = PKPaymentAuthorizationController.canMakePayments() 31 | result(canMakePayment) 32 | } 33 | 34 | func canMakePaymentsWithActiveCard(arguments: Any? = nil, result: @escaping FlutterResult) { 35 | guard let params = arguments as? [String: Any], 36 | let paymentNetworks = params["paymentNetworks"] as? [String] else { 37 | result(FlutterError(code: "invalidParameters", message: "Invalid parameters", details: nil)) 38 | return; 39 | } 40 | let pkPaymentNetworks: [PKPaymentNetwork] = paymentNetworks.compactMap({ PaymentNetworkHelper.decodePaymentNetwork($0) }) 41 | let canMakePayments = PKPaymentAuthorizationController.canMakePayments(usingNetworks: pkPaymentNetworks) 42 | result(canMakePayments) 43 | } 44 | 45 | func requestPayment(arguments: Any? = nil, result: @escaping FlutterResult) { 46 | guard let params = arguments as? [String: Any], 47 | let merchantID = params["merchantIdentifier"] as? String, 48 | let currency = params["currencyCode"] as? String, 49 | let countryCode = params["countryCode"] as? String, 50 | let allowedPaymentNetworks = params["allowedPaymentNetworks"] as? [String], 51 | let items = params["items"] as? [[String: String]], 52 | let merchantCapabilities = params["merchantCapabilities"] as? [String]? else { 53 | result(FlutterError(code: "invalidParameters", message: "Invalid parameters", details: nil)) 54 | return 55 | } 56 | 57 | var paymentItems = [PKPaymentSummaryItem]() 58 | items.forEach { item in 59 | let itemTitle = item["name"] 60 | let itemPrice = item["price"] 61 | let itemDecimalPrice = NSDecimalNumber(string: itemPrice) 62 | let item = PKPaymentSummaryItem(label: itemTitle ?? "", amount: itemDecimalPrice) 63 | paymentItems.append(item) 64 | } 65 | 66 | let paymentNetworks = allowedPaymentNetworks.count > 0 ? allowedPaymentNetworks.compactMap { PaymentNetworkHelper.decodePaymentNetwork($0) } : PKPaymentRequest.availableNetworks() 67 | 68 | let paymentRequest = PKPaymentRequest() 69 | paymentRequest.paymentSummaryItems = paymentItems 70 | paymentRequest.merchantIdentifier = merchantID 71 | paymentRequest.merchantCapabilities = MerchantCapabilitiesHelper.decodeCapabilities(merchantCapabilities) 72 | paymentRequest.countryCode = countryCode 73 | paymentRequest.currencyCode = currency 74 | paymentRequest.supportedNetworks = paymentNetworks 75 | 76 | let paymentController = PKPaymentAuthorizationController(paymentRequest: paymentRequest) 77 | paymentController.delegate = self 78 | self.flutterResult = result 79 | paymentController.present(completion: nil) 80 | } 81 | 82 | private func paymentResult(pkPayment: PKPayment?) { 83 | if let result = flutterResult { 84 | if let payment = pkPayment { 85 | let token = String(data: payment.token.paymentData, encoding: .utf8) 86 | result(["token": token]) 87 | } else { 88 | result(FlutterError(code: "userCancelledError", message: "User cancelled the payment", details: nil)) 89 | } 90 | flutterResult = nil 91 | } 92 | } 93 | } 94 | 95 | @available(iOS 10.0, *) 96 | extension SwiftFlutterPayPlugin: PKPaymentAuthorizationControllerDelegate { 97 | public func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) { 98 | paymentResult(pkPayment: nil) 99 | controller.dismiss(completion: nil) 100 | } 101 | 102 | @available(iOS 11.0, *) 103 | public func paymentAuthorizationController(_ controller: PKPaymentAuthorizationController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) { 104 | paymentResult(pkPayment: payment) 105 | completion(PKPaymentAuthorizationResult(status: .success, errors: nil)) 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/xamelon/flutter_pay/FlutterPayPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.xamelon.flutter_pay 2 | 3 | import android.app.Activity 4 | import android.content.Intent 5 | import androidx.annotation.NonNull 6 | import com.google.android.gms.common.api.ApiException 7 | import com.google.android.gms.wallet.* 8 | import io.flutter.embedding.engine.plugins.FlutterPlugin 9 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 10 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 11 | import io.flutter.plugin.common.MethodCall 12 | import io.flutter.plugin.common.MethodChannel 13 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 14 | import io.flutter.plugin.common.MethodChannel.Result 15 | import io.flutter.plugin.common.PluginRegistry 16 | import io.flutter.plugin.common.PluginRegistry.Registrar 17 | import org.json.JSONArray 18 | import org.json.JSONObject 19 | 20 | /** FlutterPayPlugin */ 21 | class FlutterPayPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.ActivityResultListener, ActivityAware { 22 | 23 | private lateinit var googlePayClient: PaymentsClient 24 | private lateinit var activity: Activity 25 | private var environment = WalletConstants.ENVIRONMENT_PRODUCTION 26 | 27 | private val LOAD_PAYMENT_DATA_REQUEST_CODE = 991 28 | 29 | private var lastResult: Result? = null 30 | 31 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 32 | val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_pay") 33 | channel.setMethodCallHandler(this) 34 | } 35 | 36 | private fun createPaymentsClient() { 37 | val walletOptions = Wallet.WalletOptions.Builder() 38 | .setEnvironment(environment) 39 | .setTheme(WalletConstants.THEME_LIGHT) 40 | .build() 41 | this.googlePayClient = Wallet.getPaymentsClient(this.activity, walletOptions) 42 | } 43 | 44 | companion object { 45 | @JvmStatic 46 | fun registerWith(registrar: Registrar) { 47 | val channel = MethodChannel(registrar.messenger(), "flutter_pay") 48 | val plugin = FlutterPayPlugin() 49 | channel.setMethodCallHandler(plugin) 50 | registrar.addActivityResultListener(plugin) 51 | plugin.activity = registrar.activity()!! 52 | plugin.createPaymentsClient() 53 | } 54 | } 55 | 56 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 57 | this.lastResult = result 58 | 59 | val args = call.arguments as? Map 60 | val method = call.method as String 61 | if (args !is Map && (method == "canMakePaymentsWithActiveCard" || method == "requestPayment" || method == "switchEnvironment" )) { 62 | this.lastResult?.error("invalidParameters", "Invalid parameters", "Invalid parameters") 63 | return 64 | } 65 | 66 | when (method) { 67 | "getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}") 68 | "canMakePayments" -> canMakePayments(result) 69 | "canMakePaymentsWithActiveCard" -> canMakePaymentsWithActiveCard(call.arguments as Map, result) 70 | "requestPayment" -> requestPayment(call.arguments as Map) 71 | "switchEnvironment" -> switchEnvironment(call.arguments as Map, result) 72 | else -> { 73 | result.notImplemented() 74 | } 75 | } 76 | } 77 | 78 | private fun switchEnvironment(args: Map, result: Result) { 79 | val isTestEnvironment = args["isTestEnvironment"] as? Boolean 80 | if (isTestEnvironment != null) { 81 | environment = if (isTestEnvironment) { 82 | WalletConstants.ENVIRONMENT_TEST 83 | } else { 84 | WalletConstants.ENVIRONMENT_PRODUCTION 85 | } 86 | print("Is test Environment: $isTestEnvironment\n") 87 | createPaymentsClient() 88 | } 89 | result.success(true) 90 | } 91 | 92 | private fun getBaseRequest(): JSONObject { 93 | return JSONObject() 94 | .put("apiVersion", 2) 95 | .put("apiVersionMinor", 0) 96 | } 97 | 98 | private fun getGatewayJsonTokenizationType(gatewayName: String, gatewayMerchantID: String): JSONObject { 99 | return JSONObject().put("type", "PAYMENT_GATEWAY") 100 | .put("parameters", JSONObject() 101 | .put("gateway", gatewayName) 102 | .put("gatewayMerchantId", gatewayMerchantID)) 103 | } 104 | 105 | private fun getAllowedCardSystems(): JSONArray { 106 | return JSONArray() 107 | .put("MASTERCARD") 108 | .put("VISA") 109 | .put("AMEX") 110 | .put("DISCOVER") 111 | .put("INTERAC") 112 | .put("JCB") 113 | } 114 | 115 | private fun getAllowedCardAuthMethods(): JSONArray { 116 | return JSONArray() 117 | .put("PAN_ONLY") 118 | .put("CRYPTOGRAM_3DS") 119 | } 120 | 121 | private fun getBaseCardPaymentMethod(allowedPaymentNetworks: List? = null, allowedAuthMethods: List? = null): JSONObject { 122 | val cardPaymentMethod = JSONObject().put("type", "CARD") 123 | 124 | val cardNetworks: JSONArray = if (allowedPaymentNetworks == null) { 125 | getAllowedCardSystems() 126 | } else { 127 | JSONArray(allowedPaymentNetworks) 128 | } 129 | 130 | val authMethods: JSONArray = if (allowedAuthMethods == null) { 131 | getAllowedCardAuthMethods() 132 | } else { 133 | JSONArray(allowedAuthMethods) 134 | } 135 | 136 | print("getBaseCardPaymentMethod, authMethods: ${authMethods}\n") 137 | 138 | val params = JSONObject() 139 | .put("allowedAuthMethods", authMethods) 140 | .put("allowedCardNetworks", cardNetworks) 141 | 142 | cardPaymentMethod.put("parameters", params) 143 | return cardPaymentMethod 144 | } 145 | 146 | private fun getCardPaymentMethod(gatewayName: String, gatewayMerchantID: String, allowedPaymentNetworks: List? = null, allowedAuthMethods: List? = null): JSONObject { 147 | val cardPaymentMethod = getBaseCardPaymentMethod(allowedPaymentNetworks, allowedAuthMethods) 148 | val tokenizationOptions = getGatewayJsonTokenizationType(gatewayName, gatewayMerchantID) 149 | cardPaymentMethod.put("tokenizationSpecification", tokenizationOptions) 150 | return cardPaymentMethod 151 | } 152 | 153 | private fun getTransactionInfo(totalPrice: Double, currencyCode: String, countryCode: String): JSONObject { 154 | return JSONObject() 155 | .put("totalPrice", totalPrice.toString()) 156 | .put("totalPriceStatus", "FINAL") 157 | .put("countryCode", countryCode) 158 | .put("currencyCode", currencyCode) 159 | } 160 | 161 | private fun requestPayment(args: Map) { 162 | val items = args["items"] as? List> 163 | val allowedPaymentNetworks = args["allowedPaymentNetworks"] as List 164 | val allowedAuthMethods = args["allowedAuthMethods"] as List 165 | val currencyCode = args["currencyCode"] as? String 166 | val countryCode = args["countryCode"] as? String 167 | val emailRequired = args["emailRequired"] as? Boolean 168 | val gatewayName = args["gatewayName"] as? String 169 | val gatewayMerchantID = args["gatewayMerchantId"] as? String 170 | val merchantId = args["merchantId"] as? String 171 | val merchantName = args["merchantName"] as? String 172 | 173 | var totalPrice = 0.0 174 | items?.forEach { 175 | val price = it["price"]?.toDouble() 176 | if (price != null) { 177 | totalPrice += price 178 | } 179 | } 180 | 181 | val paymentNetworks: List = if (allowedPaymentNetworks.count() > 0) { 182 | allowedPaymentNetworks.mapNotNull { decodePaymentNetwork(it) } 183 | } else { 184 | availablePaymentNetworks 185 | } 186 | 187 | val authMethods: List = if (allowedAuthMethods.count() > 0) { 188 | allowedAuthMethods.mapNotNull { decodeAuthMethods(it) } 189 | } else { 190 | availableAuthMethods 191 | } 192 | print("requestPayment, authMethods: ${authMethods}\n") 193 | 194 | if (totalPrice <= 0.0) { 195 | this.lastResult?.error("zeroPrice", "Invalid price", "Total price cannot be zero or less than zero") 196 | return 197 | } 198 | if (gatewayName == null || gatewayMerchantID == null || currencyCode == null || countryCode == null) { 199 | this.lastResult?.error("invalidParameters", "Invalid parameters", "Invalid parameters") 200 | return 201 | } 202 | 203 | var merchantInfo = JSONObject() 204 | .putOpt("merchantName", merchantName) 205 | .putOpt("merchantId", merchantId) 206 | 207 | if (merchantInfo.length() == 0) merchantInfo = null 208 | 209 | val paymentRequestJson = getBaseRequest() 210 | .putOpt("merchantInfo", merchantInfo) 211 | .put("emailRequired", emailRequired) 212 | .put("transactionInfo", getTransactionInfo(totalPrice, currencyCode, countryCode)) 213 | .put("allowedPaymentMethods", JSONArray().put(getCardPaymentMethod(gatewayName, gatewayMerchantID, paymentNetworks, authMethods))) 214 | 215 | val paymentDataRequest = PaymentDataRequest.fromJson(paymentRequestJson.toString(4)) 216 | 217 | print("phone required: ${paymentDataRequest.isPhoneNumberRequired}\n") 218 | print("Payment data request: ${paymentDataRequest.toJson()}\n") 219 | 220 | if (paymentDataRequest != null) { 221 | val task = googlePayClient 222 | .loadPaymentData(paymentDataRequest) 223 | .addOnCompleteListener { 224 | try { 225 | print("${it.getResult(ApiException::class.java)}") 226 | } catch (e: ApiException) { 227 | 228 | print("Tortik: ${e.message}\n") 229 | } 230 | } 231 | AutoResolveHelper.resolveTask(task, this.activity, LOAD_PAYMENT_DATA_REQUEST_CODE) 232 | } 233 | 234 | } 235 | 236 | private fun canMakePayments(result: Result) { 237 | val baseRequest = getBaseRequest() 238 | baseRequest.put("allowedPaymentMethods", JSONArray().put(getBaseCardPaymentMethod())) 239 | 240 | val isReadyToPayRequest = IsReadyToPayRequest.fromJson(baseRequest.toString(4)) 241 | 242 | val task = googlePayClient.isReadyToPay(isReadyToPayRequest) 243 | task.addOnCompleteListener { 244 | try { 245 | if (it.getResult(ApiException::class.java) == true) { 246 | result.success(true) 247 | } else { 248 | result.success(false) 249 | } 250 | } catch (e: ApiException) { 251 | e.printStackTrace() 252 | result.success(false) 253 | } 254 | } 255 | } 256 | 257 | private fun canMakePaymentsWithActiveCard(args: Map, result: Result) { 258 | val rawPaymentNetworks = args["paymentNetworks"] as? List 259 | var paymentNetworks = rawPaymentNetworks?.mapNotNull { decodePaymentNetwork(it) } 260 | if (paymentNetworks?.count() == 0) { 261 | paymentNetworks = availablePaymentNetworks 262 | } 263 | val baseRequest = getBaseRequest() 264 | baseRequest.put("allowedPaymentMethods", JSONArray().put(getBaseCardPaymentMethod(paymentNetworks))) 265 | baseRequest.put("existingPaymentMethodRequired", true) 266 | 267 | val isReadyToPayRequest = IsReadyToPayRequest.fromJson(baseRequest.toString(4)) 268 | 269 | val task = googlePayClient.isReadyToPay(isReadyToPayRequest) 270 | task.addOnCompleteListener { 271 | try { 272 | if (it.getResult(ApiException::class.java) == true) { 273 | result.success(true) 274 | } else { 275 | result.success(false) 276 | } 277 | } catch (e: ApiException) { 278 | e.printStackTrace() 279 | result.success(false) 280 | } 281 | } 282 | } 283 | 284 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {} 285 | 286 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean { 287 | if (requestCode == LOAD_PAYMENT_DATA_REQUEST_CODE) { 288 | print("Result code: $resultCode\n") 289 | if (resultCode == Activity.RESULT_OK) { 290 | if (data != null) { 291 | val paymentData = PaymentData.getFromIntent(data) 292 | print("Payment data: ${paymentData?.toJson()}\n") 293 | 294 | if (paymentData != null) { 295 | val paymentDataString = paymentData.toJson() 296 | val paymentDataJSONObject = JSONObject(paymentDataString) 297 | val paymentMethodData = paymentDataJSONObject["paymentMethodData"] as? JSONObject 298 | if (paymentMethodData != null) { 299 | val tokenizationData = paymentMethodData["tokenizationData"] as? JSONObject 300 | if (tokenizationData != null) { 301 | val token = tokenizationData["token"] as? String 302 | if (token != null) { 303 | val response: Map = mapOf("token" to token) 304 | this.lastResult?.success(response) 305 | } 306 | } 307 | } 308 | } 309 | } 310 | 311 | } else if (resultCode == Activity.RESULT_CANCELED) { 312 | print("Activity.RESULT_CANCELED") 313 | this.lastResult?.error("userCancelledError", "User cancelled the payment", null) 314 | } else if (resultCode == AutoResolveHelper.RESULT_ERROR) { 315 | val status = AutoResolveHelper.getStatusFromIntent(data); 316 | print("AutoResolveHelper.RESULT_ERROR") 317 | print("Status: ${status?.toString()}") 318 | this.lastResult?.error("paymentError", "Google Pay returned payment error", null) 319 | } 320 | 321 | this.lastResult = null 322 | } 323 | return false 324 | } 325 | 326 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 327 | this.activity = binding.activity 328 | binding.addActivityResultListener(this) 329 | createPaymentsClient() 330 | } 331 | 332 | override fun onDetachedFromActivity() {} 333 | 334 | override fun onDetachedFromActivityForConfigChanges() {} 335 | 336 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 337 | this.activity = binding.activity 338 | binding.addActivityResultListener(this) 339 | createPaymentsClient() 340 | } 341 | } 342 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 010457AD51FF1661C8D816EA /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F50F8C57DDA095F2D51E281 /* Pods_Runner.framework */; }; 11 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 34 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 35 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 36 | 3E6CF8B0EA264A0277987C93 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 37 | 68DEF484248A248100145E56 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 38 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 39 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 41 | 7F50F8C57DDA095F2D51E281 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 43 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 44 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | B724453D5BA8BAA67494A2C2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 50 | E7DA6DE502A6BE0FAFAABA3D /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 010457AD51FF1661C8D816EA /* Pods_Runner.framework in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 7270A47D2F0184F0086D1F52 /* Pods */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 3E6CF8B0EA264A0277987C93 /* Pods-Runner.debug.xcconfig */, 69 | B724453D5BA8BAA67494A2C2 /* Pods-Runner.release.xcconfig */, 70 | E7DA6DE502A6BE0FAFAABA3D /* Pods-Runner.profile.xcconfig */, 71 | ); 72 | path = Pods; 73 | sourceTree = ""; 74 | }; 75 | 9740EEB11CF90186004384FC /* Flutter */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 79 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 80 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 81 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 82 | ); 83 | name = Flutter; 84 | sourceTree = ""; 85 | }; 86 | 97C146E51CF9000F007C117D = { 87 | isa = PBXGroup; 88 | children = ( 89 | 9740EEB11CF90186004384FC /* Flutter */, 90 | 97C146F01CF9000F007C117D /* Runner */, 91 | 97C146EF1CF9000F007C117D /* Products */, 92 | 7270A47D2F0184F0086D1F52 /* Pods */, 93 | FD3589E9075B13B913936BC9 /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 97C146EF1CF9000F007C117D /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 97C146EE1CF9000F007C117D /* Runner.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 97C146F01CF9000F007C117D /* Runner */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 68DEF484248A248100145E56 /* Runner.entitlements */, 109 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 110 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 111 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 112 | 97C147021CF9000F007C117D /* Info.plist */, 113 | 97C146F11CF9000F007C117D /* Supporting Files */, 114 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 115 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 116 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 117 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 118 | ); 119 | path = Runner; 120 | sourceTree = ""; 121 | }; 122 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | FD3589E9075B13B913936BC9 /* Frameworks */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 7F50F8C57DDA095F2D51E281 /* Pods_Runner.framework */, 133 | ); 134 | name = Frameworks; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 97C146ED1CF9000F007C117D /* Runner */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 143 | buildPhases = ( 144 | 8472E4666C93598E31458B53 /* [CP] Check Pods Manifest.lock */, 145 | 9740EEB61CF901F6004384FC /* Run Script */, 146 | 97C146EA1CF9000F007C117D /* Sources */, 147 | 97C146EB1CF9000F007C117D /* Frameworks */, 148 | 97C146EC1CF9000F007C117D /* Resources */, 149 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 150 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 151 | 33FECF361C34AF27BA303109 /* [CP] Embed Pods Frameworks */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = Runner; 158 | productName = Runner; 159 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | 97C146E61CF9000F007C117D /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastUpgradeCheck = 1020; 169 | ORGANIZATIONNAME = "The Chromium Authors"; 170 | TargetAttributes = { 171 | 97C146ED1CF9000F007C117D = { 172 | CreatedOnToolsVersion = 7.3.1; 173 | DevelopmentTeam = H9J5GR3S4T; 174 | LastSwiftMigration = 1100; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 179 | compatibilityVersion = "Xcode 3.2"; 180 | developmentRegion = en; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = 97C146E51CF9000F007C117D; 187 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | 97C146ED1CF9000F007C117D /* Runner */, 192 | ); 193 | }; 194 | /* End PBXProject section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | 97C146EC1CF9000F007C117D /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 202 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 203 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 204 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | /* End PBXResourcesBuildPhase section */ 209 | 210 | /* Begin PBXShellScriptBuildPhase section */ 211 | 33FECF361C34AF27BA303109 /* [CP] Embed Pods Frameworks */ = { 212 | isa = PBXShellScriptBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | ); 216 | inputPaths = ( 217 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 218 | "${BUILT_PRODUCTS_DIR}/flutter_pay/flutter_pay.framework", 219 | ); 220 | name = "[CP] Embed Pods Frameworks"; 221 | outputPaths = ( 222 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_pay.framework", 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | shellPath = /bin/sh; 226 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 227 | showEnvVarsInLog = 0; 228 | }; 229 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 230 | isa = PBXShellScriptBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | ); 234 | inputPaths = ( 235 | ); 236 | name = "Thin Binary"; 237 | outputPaths = ( 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | shellPath = /bin/sh; 241 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed\n/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin\n"; 242 | }; 243 | 8472E4666C93598E31458B53 /* [CP] Check Pods Manifest.lock */ = { 244 | isa = PBXShellScriptBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | ); 248 | inputFileListPaths = ( 249 | ); 250 | inputPaths = ( 251 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 252 | "${PODS_ROOT}/Manifest.lock", 253 | ); 254 | name = "[CP] Check Pods Manifest.lock"; 255 | outputFileListPaths = ( 256 | ); 257 | outputPaths = ( 258 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | shellPath = /bin/sh; 262 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 263 | showEnvVarsInLog = 0; 264 | }; 265 | 9740EEB61CF901F6004384FC /* Run Script */ = { 266 | isa = PBXShellScriptBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | ); 270 | inputPaths = ( 271 | ); 272 | name = "Run Script"; 273 | outputPaths = ( 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | shellPath = /bin/sh; 277 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 278 | }; 279 | /* End PBXShellScriptBuildPhase section */ 280 | 281 | /* Begin PBXSourcesBuildPhase section */ 282 | 97C146EA1CF9000F007C117D /* Sources */ = { 283 | isa = PBXSourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 287 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | /* End PBXSourcesBuildPhase section */ 292 | 293 | /* Begin PBXVariantGroup section */ 294 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 295 | isa = PBXVariantGroup; 296 | children = ( 297 | 97C146FB1CF9000F007C117D /* Base */, 298 | ); 299 | name = Main.storyboard; 300 | sourceTree = ""; 301 | }; 302 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 303 | isa = PBXVariantGroup; 304 | children = ( 305 | 97C147001CF9000F007C117D /* Base */, 306 | ); 307 | name = LaunchScreen.storyboard; 308 | sourceTree = ""; 309 | }; 310 | /* End PBXVariantGroup section */ 311 | 312 | /* Begin XCBuildConfiguration section */ 313 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_ANALYZER_NONNULL = YES; 318 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 319 | CLANG_CXX_LIBRARY = "libc++"; 320 | CLANG_ENABLE_MODULES = YES; 321 | CLANG_ENABLE_OBJC_ARC = YES; 322 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 323 | CLANG_WARN_BOOL_CONVERSION = YES; 324 | CLANG_WARN_COMMA = YES; 325 | CLANG_WARN_CONSTANT_CONVERSION = YES; 326 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 327 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 328 | CLANG_WARN_EMPTY_BODY = YES; 329 | CLANG_WARN_ENUM_CONVERSION = YES; 330 | CLANG_WARN_INFINITE_RECURSION = YES; 331 | CLANG_WARN_INT_CONVERSION = YES; 332 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 333 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 334 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 335 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 336 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 337 | CLANG_WARN_STRICT_PROTOTYPES = YES; 338 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | COPY_PHASE_STRIP = NO; 343 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 344 | ENABLE_NS_ASSERTIONS = NO; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 347 | GCC_NO_COMMON_BLOCKS = YES; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = iphoneos; 357 | SUPPORTED_PLATFORMS = iphoneos; 358 | TARGETED_DEVICE_FAMILY = "1,2"; 359 | VALIDATE_PRODUCT = YES; 360 | }; 361 | name = Profile; 362 | }; 363 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 364 | isa = XCBuildConfiguration; 365 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | CLANG_ENABLE_MODULES = YES; 369 | CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 370 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 371 | DEVELOPMENT_TEAM = H9J5GR3S4T; 372 | ENABLE_BITCODE = NO; 373 | FRAMEWORK_SEARCH_PATHS = ( 374 | "$(inherited)", 375 | "$(PROJECT_DIR)/Flutter", 376 | ); 377 | INFOPLIST_FILE = Runner/Info.plist; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 379 | LIBRARY_SEARCH_PATHS = ( 380 | "$(inherited)", 381 | "$(PROJECT_DIR)/Flutter", 382 | ); 383 | PRODUCT_BUNDLE_IDENTIFIER = com.xamelon.flutterpay.example; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 386 | SWIFT_VERSION = 5.0; 387 | VERSIONING_SYSTEM = "apple-generic"; 388 | }; 389 | name = Profile; 390 | }; 391 | 97C147031CF9000F007C117D /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ALWAYS_SEARCH_USER_PATHS = NO; 395 | CLANG_ANALYZER_NONNULL = YES; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 401 | CLANG_WARN_BOOL_CONVERSION = YES; 402 | CLANG_WARN_COMMA = YES; 403 | CLANG_WARN_CONSTANT_CONVERSION = YES; 404 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 405 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 406 | CLANG_WARN_EMPTY_BODY = YES; 407 | CLANG_WARN_ENUM_CONVERSION = YES; 408 | CLANG_WARN_INFINITE_RECURSION = YES; 409 | CLANG_WARN_INT_CONVERSION = YES; 410 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 411 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 412 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 413 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 414 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 415 | CLANG_WARN_STRICT_PROTOTYPES = YES; 416 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 417 | CLANG_WARN_UNREACHABLE_CODE = YES; 418 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 419 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 420 | COPY_PHASE_STRIP = NO; 421 | DEBUG_INFORMATION_FORMAT = dwarf; 422 | ENABLE_STRICT_OBJC_MSGSEND = YES; 423 | ENABLE_TESTABILITY = YES; 424 | GCC_C_LANGUAGE_STANDARD = gnu99; 425 | GCC_DYNAMIC_NO_PIC = NO; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_OPTIMIZATION_LEVEL = 0; 428 | GCC_PREPROCESSOR_DEFINITIONS = ( 429 | "DEBUG=1", 430 | "$(inherited)", 431 | ); 432 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 433 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 434 | GCC_WARN_UNDECLARED_SELECTOR = YES; 435 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 436 | GCC_WARN_UNUSED_FUNCTION = YES; 437 | GCC_WARN_UNUSED_VARIABLE = YES; 438 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 439 | MTL_ENABLE_DEBUG_INFO = YES; 440 | ONLY_ACTIVE_ARCH = YES; 441 | SDKROOT = iphoneos; 442 | TARGETED_DEVICE_FAMILY = "1,2"; 443 | }; 444 | name = Debug; 445 | }; 446 | 97C147041CF9000F007C117D /* Release */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | ALWAYS_SEARCH_USER_PATHS = NO; 450 | CLANG_ANALYZER_NONNULL = YES; 451 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 452 | CLANG_CXX_LIBRARY = "libc++"; 453 | CLANG_ENABLE_MODULES = YES; 454 | CLANG_ENABLE_OBJC_ARC = YES; 455 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 456 | CLANG_WARN_BOOL_CONVERSION = YES; 457 | CLANG_WARN_COMMA = YES; 458 | CLANG_WARN_CONSTANT_CONVERSION = YES; 459 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 460 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 461 | CLANG_WARN_EMPTY_BODY = YES; 462 | CLANG_WARN_ENUM_CONVERSION = YES; 463 | CLANG_WARN_INFINITE_RECURSION = YES; 464 | CLANG_WARN_INT_CONVERSION = YES; 465 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 466 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 467 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 468 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 469 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 470 | CLANG_WARN_STRICT_PROTOTYPES = YES; 471 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 472 | CLANG_WARN_UNREACHABLE_CODE = YES; 473 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 474 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 475 | COPY_PHASE_STRIP = NO; 476 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 477 | ENABLE_NS_ASSERTIONS = NO; 478 | ENABLE_STRICT_OBJC_MSGSEND = YES; 479 | GCC_C_LANGUAGE_STANDARD = gnu99; 480 | GCC_NO_COMMON_BLOCKS = YES; 481 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 482 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 483 | GCC_WARN_UNDECLARED_SELECTOR = YES; 484 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 485 | GCC_WARN_UNUSED_FUNCTION = YES; 486 | GCC_WARN_UNUSED_VARIABLE = YES; 487 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 488 | MTL_ENABLE_DEBUG_INFO = NO; 489 | SDKROOT = iphoneos; 490 | SUPPORTED_PLATFORMS = iphoneos; 491 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 492 | TARGETED_DEVICE_FAMILY = "1,2"; 493 | VALIDATE_PRODUCT = YES; 494 | }; 495 | name = Release; 496 | }; 497 | 97C147061CF9000F007C117D /* Debug */ = { 498 | isa = XCBuildConfiguration; 499 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 500 | buildSettings = { 501 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 502 | CLANG_ENABLE_MODULES = YES; 503 | CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 504 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 505 | DEVELOPMENT_TEAM = H9J5GR3S4T; 506 | ENABLE_BITCODE = NO; 507 | FRAMEWORK_SEARCH_PATHS = ( 508 | "$(inherited)", 509 | "$(PROJECT_DIR)/Flutter", 510 | ); 511 | INFOPLIST_FILE = Runner/Info.plist; 512 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 513 | LIBRARY_SEARCH_PATHS = ( 514 | "$(inherited)", 515 | "$(PROJECT_DIR)/Flutter", 516 | ); 517 | PRODUCT_BUNDLE_IDENTIFIER = com.xamelon.flutterpay.example; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 520 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 521 | SWIFT_VERSION = 5.0; 522 | VERSIONING_SYSTEM = "apple-generic"; 523 | }; 524 | name = Debug; 525 | }; 526 | 97C147071CF9000F007C117D /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 529 | buildSettings = { 530 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 531 | CLANG_ENABLE_MODULES = YES; 532 | CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 533 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 534 | DEVELOPMENT_TEAM = H9J5GR3S4T; 535 | ENABLE_BITCODE = NO; 536 | FRAMEWORK_SEARCH_PATHS = ( 537 | "$(inherited)", 538 | "$(PROJECT_DIR)/Flutter", 539 | ); 540 | INFOPLIST_FILE = Runner/Info.plist; 541 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 542 | LIBRARY_SEARCH_PATHS = ( 543 | "$(inherited)", 544 | "$(PROJECT_DIR)/Flutter", 545 | ); 546 | PRODUCT_BUNDLE_IDENTIFIER = com.xamelon.flutterpay.example; 547 | PRODUCT_NAME = "$(TARGET_NAME)"; 548 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 549 | SWIFT_VERSION = 5.0; 550 | VERSIONING_SYSTEM = "apple-generic"; 551 | }; 552 | name = Release; 553 | }; 554 | /* End XCBuildConfiguration section */ 555 | 556 | /* Begin XCConfigurationList section */ 557 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 558 | isa = XCConfigurationList; 559 | buildConfigurations = ( 560 | 97C147031CF9000F007C117D /* Debug */, 561 | 97C147041CF9000F007C117D /* Release */, 562 | 249021D3217E4FDB00AE95B9 /* Profile */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | 97C147061CF9000F007C117D /* Debug */, 571 | 97C147071CF9000F007C117D /* Release */, 572 | 249021D4217E4FDB00AE95B9 /* Profile */, 573 | ); 574 | defaultConfigurationIsVisible = 0; 575 | defaultConfigurationName = Release; 576 | }; 577 | /* End XCConfigurationList section */ 578 | }; 579 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 580 | } 581 | --------------------------------------------------------------------------------