Skip to content

Commit eddfec3

Browse files
authored
initial version (#1)
* initial version * include metadata and description in the example * make description in payment config required * add mada
1 parent 7b1947b commit eddfec3

File tree

115 files changed

+3817
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3817
-1
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
doc/api/
2+
.DS_Store
3+
.atom/
4+
.idea
5+
.packages
6+
.pub/
7+
build/
8+
ios/.generated/
9+
packages
10+
.flutter-plugins
11+
.flutter-plugins-dependencies
12+
.dart_tool
13+
*.log
14+
15+

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 1.0.0
2+
3+
- Build the Dart Moyasar API wrapper.
4+
- Add Apple Pay widget.
5+
- Add Credit Card widget with managed 3DS step.
6+
- Add tests.
7+
- Add documentation.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Moyasar
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.

README.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
# Moyasar Flutter SDK
1+
Easily accept payments through Apple Pay or Credit Card (with managed 3DS step) in your Flutter app with Moyasar.
2+
3+
![Moyasar Flutter SDK Demo](./assets/demo.gif)
4+
5+
## Features
6+
7+
Use this plugin to support:
8+
9+
- **Apple Pay**: Quickly and safely accept Apple Pay payments.
10+
- **Credit Card**: Easily accept many card companies while not worrying about managing the required 3DS step.
11+
12+
## Getting started
13+
14+
### Prerequisites
15+
16+
#### **Accepting Apple Pay Payments in iOS**
17+
18+
Complete the following steps to easily accept Apple Pay payments:
19+
20+
- Follow [this guide](https://moyasar.com/docs/dashboard/apple-pay/developer-account/) to setup your Apple developer account and integrate it with Moyasar.
21+
- Follow [this guide](https://help.apple.com/xcode/mac/9.3/#/deva43983eb7?sub=dev44ce8ef13) to enable accepting Apple Pay in your application using xCode.
22+
- Create a file named `default_payment_profile_apple_pay.json` under the root of your assets folder. e.g. `assets/default_payment_profile_apple_pay.json`, and don't forget to update the `merchantIdentifier` and `displayName` values.
23+
24+
```json
25+
{
26+
"provider": "apple_pay",
27+
"data": {
28+
"merchantIdentifier": "YOUR_MERCHANT_ID",
29+
"displayName": "YOUR_SHOP_NAME",
30+
"merchantCapabilities": ["3DS", "debit", "credit"],
31+
"supportedNetworks": ["amex", "visa", "mada", "masterCard"],
32+
"countryCode": "SA",
33+
"currencyCode": "SAR"
34+
}
35+
}
36+
```
37+
38+
#### **Accepting Credit Card Payments in Android**
39+
40+
Due to depending on the `flutter_webview` package to manage the 3DS step, make sure to set the correct minSdkVersion in android/app/build.gradle if it was previously lower than 19:
41+
42+
```
43+
android {
44+
defaultConfig {
45+
minSdkVersion 19
46+
}
47+
}
48+
```
49+
50+
### Installation
51+
52+
```sh
53+
flutter pub get moyasar
54+
```
55+
56+
## Usage
57+
58+
```dart
59+
import 'package:flutter/material.dart';
60+
import 'package:moyasar/moyasar.dart';
61+
62+
class PaymentMethods extends StatelessWidget {
63+
PaymentMethods({super.key});
64+
65+
final paymentConfig = PaymentConfig(
66+
publishableApiKey: 'YOUR_API_KEY',
67+
amount: 25758, // SAR 257.58
68+
description: 'Blue Coffee Beans',
69+
metadata: {'size': '250g'},
70+
);
71+
72+
void onPaymentResult(result) {
73+
if (result is PaymentResponse) {
74+
switch (result.status) {
75+
case PaymentStatus.paid:
76+
// handle success.
77+
break;
78+
case PaymentStatus.failed:
79+
// handle failure.
80+
break;
81+
}
82+
}
83+
}
84+
85+
@override
86+
Widget build(BuildContext context) {
87+
return Column(
88+
children: [
89+
ApplePay(
90+
config: paymentConfig,
91+
onPaymentResult: onPaymentResult,
92+
),
93+
const Text("or"),
94+
CreditCard(
95+
config: paymentConfig,
96+
onPaymentResult: onPaymentResult,
97+
)
98+
],
99+
);
100+
}
101+
}
102+
```

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include: package:flutter_lints/flutter.yaml
2+
# Additional information about this file can be found at
3+
# https://dart.dev/guides/language/analysis-options

assets/demo.gif

473 KB
Loading

assets/images/amex.png

1.9 KB
Loading

assets/images/mada.png

1.69 KB
Loading

assets/images/mastercard.png

1.5 KB
Loading

assets/images/visa.png

1.79 KB
Loading

0 commit comments

Comments
 (0)