Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ migrate_working_dir/
**/doc/api/
.dart_tool/
build/
ios/paystack_flutter_sdk/.build
example/pubspec.lock
example/.vscode
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.1-alpha.3

* Move platform interface to own package.
* Add web support

## 0.0.1-alpha.2

* Clean up for publishing max score
Expand Down
83 changes: 78 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,93 @@ A [Paystack](https://paystack.com) plugin for accepting payments in your Flutter
## Support
| Android | iOS | MacOS | Web | Linux | Windows |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
| ✓ | ✓ | ✗ | ✓ | ✗ | ✗ |

## Requirements
Paystack Flutter SDK builds upon the recent patterns in the Android and iOS, thus your app should target:
- Flutter >= 3.3.0
- iOS >= 13
- Flutter >= 3.4.0
- iOS >= 15
- Android
- Minimum SDK: 23
- Compile SDK: 34
- Minimum SDK: 24
- Compile SDK: 36

> [!IMPORTANT]
>
> Flutter (3.3.0 below, at the moment) extends the `FlutterActivity` as the base class for Android. The `FlutterActivity` doesn't have the `ComponentActivity`, a compulsory necessity for loading the payment views with the SDK, in its ancestral tree. To fix this, change the `FlutterActivity` to `FlutterFragmentActivity` in the `MainActivity` in the `android` folder of your project.

## Platform Support

#### Android Support
Please add the following snippet to your `android/app/proguard-rules.pro` file
```
# --- Keep annotation + inner class attributes ---
-keepattributes Annotation, InnerClasses, Signature

# --- Kotlinx Serialization ---
-dontnote kotlinx.serialization.AnnotationsKt

-keepclassmembers class kotlinx.serialization.json.** {
*** Companion;
}

-keepclasseswithmembers class kotlinx.serialization.json.** {
kotlinx.serialization.KSerializer serializer(...);
}

# --- Kotlin Standard + kotlinx packages ---
-keep class kotlin.** { *; }
-keep class kotlinx.** { *; }

-keepclassmembers class **$WhenMappings {
*;
}

-keepclassmembers class kotlin.Metadata {
public *;
}

# --- Parcelable Support ---
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

# --- Retrofit (Square or standard Retrofit2) ---
-keep interface retrofit2.Call
-keep class retrofit2.** { *; }
-keep interface retrofit2.* { *; }

# Keep Retrofit annotations
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}

# --- Retrofit – Square package (optional but safe) ---
-keep class com.squareup.retrofit2.** { *; }
-keep interface com.squareup.retrofit2.* { *; }

# --- Paystack SDK ---
-keep class com.paystack.android.core.api.** { *; }
-keep interface com.paystack.android.core.api.* { *; }
-keep class com.paystack.android.core.api.models.* { *; }

# Already defined above, but safe to repeat (R8 ignores duplicates)
-keepattributes Annotation
```

#### Flutter Web Support
Please add the following snippet to your `web/index.html` inside `<body></body>` in your Flutter project.
```
<script src="https://js.paystack.co/v2/inline.js"></script>
```

## Getting Started
- Install the dependency in your project
```sh
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android {
}

dependencies {
implementation 'com.paystack.android:paystack-ui:0.0.8'
implementation 'com.paystack.android:paystack-ui:0.0.10'

testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
Expand Down
45 changes: 45 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "b45fa18946ecc2d9b4009952c636ba7e2ffbb787"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: android
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: ios
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: linux
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: macos
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: web
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: windows
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
10 changes: 10 additions & 0 deletions example/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"configurations": [
{
"name": "example (Flutter)",
"program": "lib/main.dart",
"request": "launch",
"type": "dart"
}
]
}
3 changes: 2 additions & 1 deletion example/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
68 changes: 0 additions & 68 deletions example/android/app/build.gradle

This file was deleted.

44 changes: 44 additions & 0 deletions example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

android {
namespace = "com.paystack.paystack_sdk_example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.paystack.paystack_sdk_example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

flutter {
source = "../.."
}
5 changes: 3 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="paystack_flutter_example"
android:label="paystack_sdk_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand All @@ -31,7 +32,7 @@
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
Expand Down
18 changes: 0 additions & 18 deletions example/android/build.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions example/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}

val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
5 changes: 1 addition & 4 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
org.gradle.jvmargs=-Xmx4G
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
Loading