-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>flutter_braintree</name> | ||
<comment>Project flutter_braintree created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir= | ||
eclipse.preferences.version=1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,65 @@ | ||
package info.keepinmind.flutter_braintree; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
|
||
import com.braintreepayments.api.dropin.DropInActivity; | ||
import com.braintreepayments.api.dropin.DropInRequest; | ||
import com.braintreepayments.api.dropin.DropInResult; | ||
|
||
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; | ||
import io.flutter.plugin.common.PluginRegistry.Registrar; | ||
|
||
/** FlutterBraintreePlugin */ | ||
public class FlutterBraintreePlugin implements MethodCallHandler { | ||
/** Plugin registration. */ | ||
public class FlutterBraintreePlugin implements MethodCallHandler, PluginRegistry.ActivityResultListener { | ||
private final Registrar mRegistrar; | ||
private final static int REQUEST_CODE = 1; | ||
|
||
private FlutterBraintreePlugin(Registrar registrar) { | ||
this.mRegistrar = registrar; | ||
this.mRegistrar.addActivityResultListener(this); | ||
} | ||
|
||
public static void registerWith(Registrar registrar) { | ||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_braintree"); | ||
channel.setMethodCallHandler(new FlutterBraintreePlugin()); | ||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "info.keepinmind.flutter_braintree"); | ||
channel.setMethodCallHandler(new FlutterBraintreePlugin(registrar)); | ||
} | ||
|
||
@Override | ||
public void onMethodCall(MethodCall call, Result result) { | ||
if (call.method.equals("getPlatformVersion")) { | ||
result.success("Android " + android.os.Build.VERSION.RELEASE); | ||
if (call.method.equals("showDropIn")) { | ||
String clientToken = call.argument("clientToken"); | ||
|
||
DropInRequest dropInRequest = new DropInRequest() | ||
.clientToken(clientToken); | ||
|
||
mRegistrar.activity().startActivityForResult(dropInRequest.getIntent(mRegistrar.activity()), REQUEST_CODE); | ||
|
||
result.success("OK"); | ||
} else { | ||
result.notImplemented(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == REQUEST_CODE) { | ||
if (resultCode == Activity.RESULT_OK) { | ||
DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); | ||
// use the result to update your UI and send the payment method nonce to your server | ||
} else if (resultCode == Activity.RESULT_CANCELED) { | ||
// the user canceled | ||
} else { | ||
// handle errors here, an exception may be available in | ||
Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>android</name> | ||
<comment>Project android created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir= | ||
eclipse.preferences.version=1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>app</name> | ||
<comment>Project app created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir=.. | ||
eclipse.preferences.version=1 |