Flutter Mad Pay
Easy integration with Google Pay and Apple Pay for your flutter app.
SDK Features
- Pay with Apple Pay and Google Pay
- Checking payment availability on your device
- Checking the user's active cards
Installing
Add this to your package's pubspec.yaml file:
dependencies:
  mad_pay: ^2.2.14
For Android
- In the file [project_name]/android/app/build.gradle, setminSdkVersionto at least version 21.
- In the file [project_name]/android/app/build.gradle, add the lineproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'tobuildTypes.release
- Create the proguard-rules.profile in the[project_name]/android/appfolder and add the line-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
example/android/app
Usage
To start using payment you need to get Merchant Identifier:
Use without buttons (for your design)
final MadPay pay = MadPay();
// To find out if payment is available on this device
await pay.checkPayments();
// If you need to check if user has at least one active card
await pay.checkActiveCard(
  paymentNetworks: <PaymentNetwork>[
    PaymentNetwork.visa,
    PaymentNetwork.mastercard,
  ],
);
// To pay with Apple Pay or Google Pay
await pay.processingPayment(
  PaymentRequest(
    google: GoogleParameters(
      gatewayName: 'Your Gateway',
      gatewayMerchantId: 'Your id',
      merchantId: 'example_id',
    ),
    apple: AppleParameters(
      merchantIdentifier: 'Your id',
    ),
    currencyCode: 'USD',
    countryCode: 'US',
    paymentItems: <PaymentItem>[
      PaymentItem(name: 'T-Shirt', price: 2.98),
      PaymentItem(name: 'Trousers', price: 15.24),
    ],
    paymentNetworks: <PaymentNetwork>[
      PaymentNetwork.visa,
      PaymentNetwork.mastercard,
    ],
  )
);
Using with buttons (by guideline)
Apple Pay button Widget (Native):
ApplePayButton(
  style: ApplePayButtonStyle.automatic,
  type: ApplePayButtonType.buy,
  request: PaymentRequest.apple(
    apple: AppleParameters(
      merchantIdentifier: 'Your id',
    ),
    currencyCode: 'USD',
    countryCode: 'US',
    paymentItems: <PaymentItem>[
      PaymentItem(name: 'T-Shirt', price: 2.98),
      PaymentItem(name: 'Trousers', price: 15.24),
    ],
  ),
  onPaymentResult: (PaymentResponse? req) {
    // ...
  },
  onError: (Object? e) {
    // ...
  },
);
Google Pay button Widget (Flutter):
GooglePayButton(
  type: GooglePayButtonType.plain,
  request: PaymentRequest.google(
    google: GoogleParameters(
      gatewayName: 'Your Gateway',
      gatewayMerchantId: 'Your id',
      merchantId: 'example_id',
    ),
    currencyCode: 'USD',
    countryCode: 'US',
    paymentItems: <PaymentItem>[
      PaymentItem(name: 'T-Shirt', price: 2.98),
      PaymentItem(name: 'Trousers', price: 15.24),
    ],
  ),
  onPaymentResult: (PaymentResponse? req) {
    // ...
  },
  onError: (Object? e) {
    // ...
  },
);
Adaptive Pay button Widget (uses ApplePayButton and GooglePayButton):
AdaptivePayButton(
  applePayButton: ApplePayButton(...),
  googlePayButton: GooglePayButton(...),
),
Example
The Example is in the corresponding folder
Payment Network matrix
| Payment Network | iOS | Android | 
|---|---|---|
| Visa | + | + | 
| MasterCard | + | + | 
| American Express | + | + | 
| Interac | + | + | 
| Discover | + | + | 
| JCB | + | + | 
| Maestro | + | |
| Electron | + | |
| Mir Pay | + | + | 
| Cartes Bancarries | + | |
| Union Pay | + | |
| EftPos | + | |
| Elo | + | |
| ID Credit | + | |
| Mada | + | |
| Private Label | + | |
| Quic Pay | + | |
| Suica | + | |
| V Pay | + | |
| Dankort | + | |
| Nanaco | + | |
| Waon | + | |
| Girocard | + | |
| BARCODE | + | 
Additional resources
Take a look at the following resources to manage your payment accounts and learn more about the APIs for the supported providers:
| Google Pay | Apple Pay | |
|---|---|---|
| Platforms | Android | iOS | 
| Documentation | Overview | Overview | 
| Console | Google Pay Business Console | Developer portal | 
| Reference | API reference | Apple Pay API | 
| Style guidelines | Brand guidelines | Buttons and Marks | 
