-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ef421c2
Showing
111 changed files
with
6,441 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
*.iml | ||
.idea | ||
.gradle | ||
local.properties | ||
|
||
android/keystores/debug.keystore | ||
|
||
example/ios/Pods | ||
coverage/ | ||
.dart_tool/ | ||
.metadata | ||
.packages | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Cloudipsp | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# cloudipsp_mobile | ||
|
||
Cloudipsp SDK for Mobile(Android, iOS) | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter | ||
[plug-in package](https://flutter.dev/developing-packages/), | ||
a specialized package that includes platform-specific implementation code for | ||
Android and/or iOS. | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 30 | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly 'com.google.android.gms:play-services-base:17.6.0' | ||
compileOnly 'com.google.android.gms:play-services-wallet:18.1.3' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'cloudipsp_mobile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.cloudipsp.mobile"> | ||
</manifest> |
167 changes: 167 additions & 0 deletions
167
android/src/main/java/com/cloudipsp/mobile/CloudipspMobilePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package com.cloudipsp.mobile; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import com.google.android.gms.common.ConnectionResult; | ||
import com.google.android.gms.common.GoogleApiAvailability; | ||
import com.google.android.gms.wallet.AutoResolveHelper; | ||
import com.google.android.gms.wallet.PaymentData; | ||
import com.google.android.gms.wallet.PaymentDataRequest; | ||
import com.google.android.gms.wallet.PaymentsClient; | ||
import com.google.android.gms.wallet.Wallet; | ||
import com.google.android.gms.wallet.WalletConstants; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.util.Map; | ||
|
||
import io.flutter.embedding.engine.plugins.FlutterPlugin; | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware; | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
import io.flutter.plugin.common.MethodChannel.Result; | ||
import io.flutter.plugin.common.PluginRegistry; | ||
|
||
|
||
public class CloudipspMobilePlugin implements | ||
ActivityAware, | ||
FlutterPlugin, | ||
MethodCallHandler, | ||
PluginRegistry.ActivityResultListener { | ||
private static final int RC_GOOGLE_PAY = 41750; | ||
|
||
private ActivityPluginBinding activityPluginBinding; | ||
private Context applicationContext; | ||
private MethodChannel channel; | ||
private Result activeGooglePayResult; | ||
|
||
@Override | ||
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { | ||
applicationContext = flutterPluginBinding.getApplicationContext(); | ||
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "cloudipsp_mobile"); | ||
channel.setMethodCallHandler(this); | ||
} | ||
|
||
@Override | ||
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { | ||
channel.setMethodCallHandler(null); | ||
channel = null; | ||
applicationContext = null; | ||
} | ||
|
||
@Override | ||
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | ||
if ("supportsGooglePay".equals(call.method)) { | ||
supportsGooglePay(result); | ||
} else if ("googlePay".equals(call.method)) { | ||
googlePay(new JSONObject((Map)call.arguments), result); | ||
} else { | ||
result.notImplemented(); | ||
} | ||
} | ||
|
||
private static boolean isGooglePayRuntimeProvided() { | ||
try { | ||
Class.forName("com.google.android.gms.common.GoogleApiAvailability"); | ||
Class.forName("com.google.android.gms.wallet.PaymentDataRequest"); | ||
return true; | ||
} catch (ClassNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
|
||
private void supportsGooglePay(@NonNull Result result) { | ||
boolean supports = false; | ||
if (isGooglePayRuntimeProvided()) { | ||
supports = GoogleApiAvailability.getInstance() | ||
.isGooglePlayServicesAvailable(applicationContext) == ConnectionResult.SUCCESS; | ||
} | ||
result.success(supports); | ||
} | ||
|
||
private void googlePay(JSONObject config, @NonNull Result result) { | ||
if (activeGooglePayResult != null) { | ||
result.error("IllegalState", "GooglePay already launched", null); | ||
} | ||
final ActivityPluginBinding activityPluginBinding = this.activityPluginBinding; | ||
if (activityPluginBinding == null) { | ||
result.error("IllegalState", "ActivityPluginBinding was not set", null); | ||
return; | ||
} | ||
|
||
activeGooglePayResult = result; | ||
final PaymentDataRequest request = PaymentDataRequest.fromJson(config.toString()); | ||
|
||
final Activity activity = activityPluginBinding.getActivity(); | ||
final PaymentsClient paymentsClient = Wallet.getPaymentsClient(activity, | ||
new Wallet.WalletOptions.Builder() | ||
.setEnvironment( | ||
"PRODUCTION".equals(config.optString("environment")) | ||
? WalletConstants.ENVIRONMENT_PRODUCTION | ||
: WalletConstants.ENVIRONMENT_TEST | ||
) | ||
.build()); | ||
AutoResolveHelper.resolveTask( | ||
paymentsClient.loadPaymentData(request), | ||
activity, | ||
RC_GOOGLE_PAY); | ||
} | ||
|
||
@Override | ||
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { | ||
activityPluginBinding = binding; | ||
binding.addActivityResultListener(this); | ||
} | ||
|
||
@Override | ||
public void onDetachedFromActivity() { | ||
if (activityPluginBinding != null) { | ||
activityPluginBinding.removeActivityResultListener(this); | ||
activityPluginBinding = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void onDetachedFromActivityForConfigChanges() { | ||
|
||
} | ||
|
||
@Override | ||
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode != RC_GOOGLE_PAY) { | ||
return false; | ||
} | ||
if (activeGooglePayResult == null) { | ||
return false; | ||
} | ||
final Result result = activeGooglePayResult; | ||
activeGooglePayResult = null; | ||
|
||
if (resultCode == Activity.RESULT_CANCELED) { | ||
result.error("CANCELED", null, null); | ||
} else if (resultCode == Activity.RESULT_OK) { | ||
final PaymentData paymentData = PaymentData.getFromIntent(data); | ||
if (paymentData == null) { | ||
result.error("ERROR", "Missed payment data", null); | ||
} else { | ||
result.success(paymentData.toJson()); | ||
} | ||
} else { | ||
result.error("ERROR", "Unsupported result code", null); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# cloudipsp_mobile_example | ||
|
||
Demonstrates how to use the cloudipsp_mobile plugin. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
|
||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties |
Oops, something went wrong.