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
6 changes: 6 additions & 0 deletions .pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# .pubignore
example/.idea/
example/android/gradle/wrapper/gradle-wrapper.jar
example/android/gradlew
example/android/gradlew.bat
example/example.iml
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### v1.7.11 Jul 22, 2025

* Upgraded plugin to support Flutter Embedding v2 and newer Flutter versions (specifically Flutter 3.29.3+ with Dart 3.7.2+).

### v1.7.10 Jan 28, 2025

* Upgraded plugin to be compatible with AGP-8.x.x.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,43 @@ public void onMethodCall(MethodCall call, Result result) {
result.success(null);
break;
case "startCardEntryFlow":
boolean collectPostalCode = call.argument("collectPostalCode");
cardEntryModule.startCardEntryFlow(result, collectPostalCode);
boolean sce_collectPostalCode = call.argument("collectPostalCode");
cardEntryModule.startCardEntryFlow(result, sce_collectPostalCode);
break;
case "startCardEntryFlowWithBuyerVerification":
boolean sce_bv_collectPostalCode = call.argument("collectPostalCode");
String sce_bv_locationId = call.argument("squareLocationId");
String sce_bv_buyerAction = call.argument("buyerAction");
HashMap<String, Object> sce_bv_moneyMap = call.argument("money");
HashMap<String, Object> sce_bv_contactMap = call.argument("contact");
String sce_bv_paymentSourceId = call.argument("paymentSourceId");

cardEntryModule.startCardEntryFlowWithBuyerVerification(
result,
sce_bv_collectPostalCode,
sce_bv_locationId,
sce_bv_buyerAction,
sce_bv_moneyMap,
sce_bv_contactMap,
sce_bv_paymentSourceId);
break;
case "startGiftCardEntryFlow":
cardEntryModule.startGiftCardEntryFlow(result);
break;
case "startGiftCardEntryFlowWithBuyerVerification":
String sge_bv_locationId = call.argument("squareLocationId");
String sge_bv_buyerAction = call.argument("buyerAction");
HashMap<String, Object> sge_bv_moneyMap = call.argument("money");
HashMap<String, Object> sge_bv_contactMap = call.argument("contact");
String sge_bv_paymentSourceId = call.argument("paymentSourceId");
cardEntryModule.startGiftCardEntryFlowWithBuyerVerification(
result,
sge_bv_locationId,
sge_bv_buyerAction,
sge_bv_moneyMap,
sge_bv_contactMap,
sge_bv_paymentSourceId);
break;
case "completeCardEntry":
cardEntryModule.completeCardEntry(result);
break;
Expand All @@ -105,43 +136,65 @@ public void onMethodCall(MethodCall call, Result result) {
cardEntryModule.showCardNonceProcessingError(result, errorMessage);
break;
case "initializeGooglePay":
String squareLocationId = call.argument("squareLocationId");
int environment = call.argument("environment");
googlePayModule.initializeGooglePay(squareLocationId, environment);
String igp_squareLocationId = call.argument("squareLocationId");
int igp_environment = call.argument("environment");
googlePayModule.initializeGooglePay(igp_squareLocationId, igp_environment);
result.success(null);
break;
case "canUseGooglePay":
googlePayModule.canUseGooglePay(result);
break;
case "requestGooglePayNonce":
String price = call.argument("price");
String currencyCode = call.argument("currencyCode");
int priceStatus = call.argument("priceStatus");
googlePayModule.requestGooglePayNonce(result, price, currencyCode, priceStatus);
String rgp_price = call.argument("price");
String rgp_currencyCode = call.argument("currencyCode");
int rgp_priceStatus = call.argument("priceStatus");
googlePayModule.requestGooglePayNonce(result, rgp_price, rgp_currencyCode, rgp_priceStatus);
break;
case "startCardEntryFlowWithBuyerVerification":
boolean collectPostal = call.argument("collectPostalCode");
String locationId = call.argument("squareLocationId");
String buyerAction = call.argument("buyerAction");
HashMap<String, Object> moneyMap = call.argument("money");
HashMap<String, Object> contactMap = call.argument("contact");

cardEntryModule.startCardEntryFlowWithBuyerVerification(result, collectPostal, locationId, buyerAction, moneyMap, contactMap);
case "requestGooglePayNonceWithBuyerVerification":
String rgp_bv_locationId = call.argument("squareLocationId");
String rgp_bv_buyerAction = call.argument("buyerAction");
HashMap<String, Object> rgp_bv_moneyMap = call.argument("money");
HashMap<String, Object> rgp_bv_contactMap = call.argument("contact");
String rgp_bv_paymentSourceId = call.argument("paymentSourceId");
String rgp_bv_price = call.argument("price");
String rgp_bv_currencyCode = call.argument("currencyCode");
int rgp_bv_priceStatus = call.argument("priceStatus");

googlePayModule.requestGooglePayNonceWithBuyerVerification(
result,
rgp_bv_buyerAction,
rgp_bv_moneyMap,
rgp_bv_locationId,
rgp_bv_contactMap,
rgp_bv_paymentSourceId,
rgp_bv_price,
rgp_bv_currencyCode,
rgp_bv_priceStatus);
break;
case "startBuyerVerificationFlow":
String locationId2 = call.argument("squareLocationId");
String buyerAction2 = call.argument("buyerAction");
HashMap<String, Object> moneyMap2 = call.argument("money");
HashMap<String, Object> contactMap2 = call.argument("contact");
String paymentSourceId = call.argument("paymentSourceId");

cardEntryModule.startBuyerVerificationFlow(result, buyerAction2, moneyMap2, locationId2, contactMap2, paymentSourceId);
String bv_locationId = call.argument("squareLocationId");
String bv_buyerAction = call.argument("buyerAction");
HashMap<String, Object> bv_moneyMap = call.argument("money");
HashMap<String, Object> bv_contactMap = call.argument("contact");
String bv_paymentSourceId = call.argument("paymentSourceId");

cardEntryModule.startBuyerVerificationFlow(
result,
bv_buyerAction,
bv_moneyMap,
bv_locationId,
bv_contactMap,
bv_paymentSourceId);
break;
case "startSecureRemoteCommerce":
int amount = call.argument("amount");
// Not yet implemented
result.notImplemented();
break;
case "startSecureRemoteCommerceWithBuyerVerification":
// Not yet implemented
result.notImplemented();
break;
default:
result.notImplemented();
break;
Expand Down
71 changes: 68 additions & 3 deletions android/src/main/java/sqip/flutter/internal/CardEntryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public final class CardEntryModule {
private Contact contact;
private CardDetails cardResult;
private String paymentSourceId;
private boolean collectPostalCode;

private boolean shouldListen = false;
private boolean shouldContinueWithRequestCardEntry = false;
private boolean shouldContinueWithRequestGiftCardEntry = false;

public CardEntryModule(Context context, MethodChannel channel) {
this.channel = channel;
Expand Down Expand Up @@ -84,6 +89,13 @@ public CardEntryActivityCommand handleEnteredCardInBackground(CardDetails cardDe
public void attachActivityResultListener(ActivityPluginBinding activityPluginBinding, MethodChannel channel) {
this.currentActivity = activityPluginBinding.getActivity();
activityPluginBinding.addActivityResultListener((requestCode, resultCode, data) -> {
// prevent multiple calls to the activity result listener when is called from GooglePay module
// added because "requestCode == BuyerVerification.DEFAULT_BUYER_VERIFICATION_REQUEST_CODE" is used in GooglePay module
if (!shouldListen) {
return false;
}
shouldListen = false;

if (requestCode == CardEntry.DEFAULT_CARD_ENTRY_REQUEST_CODE) {
CardEntry.handleActivityResult(data, cardEntryActivityResult -> {
if (cardEntryActivityResult.isSuccess() && CardEntryModule.this.contact != null) {
Expand Down Expand Up @@ -116,7 +128,16 @@ public void attachActivityResultListener(ActivityPluginBinding activityPluginBin
payload.put("token", result.getSuccessValue().getVerificationToken());
}
channel.invokeMethod("onBuyerVerificationSuccess", payload);
if (shouldContinueWithRequestCardEntry) {
shouldContinueWithRequestCardEntry = false;
CardEntry.startCardEntryActivity(currentActivity, collectPostalCode);
} else if (shouldContinueWithRequestGiftCardEntry) {
shouldContinueWithRequestGiftCardEntry = false;
CardEntry.startGiftCardEntryActivity(currentActivity);
}
} else if (result.isError()) {
shouldContinueWithRequestCardEntry = false;
shouldContinueWithRequestGiftCardEntry = false;
Error error = result.getErrorValue();
Map<String, String> errorMap = ErrorHandlerUtils.getCallbackErrorObject(
error.getCode().name(),
Expand All @@ -135,11 +156,13 @@ public void attachActivityResultListener(ActivityPluginBinding activityPluginBin
}

public void startCardEntryFlow(MethodChannel.Result result, boolean collectPostalCode) {
shouldListen = true;
CardEntry.startCardEntryActivity(currentActivity, collectPostalCode);
result.success(null);
}

public void completeCardEntry(MethodChannel.Result result) {
shouldListen = true;
reference.set(new CardEntryActivityCommand.Finish());
countDownLatch.countDown();
result.success(null);
Expand All @@ -152,28 +175,70 @@ public void showCardNonceProcessingError(MethodChannel.Result result, String err
}

public void startGiftCardEntryFlow(MethodChannel.Result result) {
shouldListen = true;
CardEntry.startGiftCardEntryActivity(currentActivity);
result.success(null);
}

public void startCardEntryFlowWithBuyerVerification(MethodChannel.Result result, boolean collectPostalCode, String squareLocationId, String buyerActionString, Map<String, Object> moneyMap, Map<String, Object> contactMap) {
public void startGiftCardEntryFlowWithBuyerVerification(
MethodChannel.Result result,
String squareLocationId,
String buyerActionString,
Map<String, Object> moneyMap,
Map<String, Object> contactMap,
String paymentSourceId
) {
shouldListen = true;

this.squareIdentifier = new SquareIdentifier.LocationToken(squareLocationId);
Money money = getMoney(moneyMap);
this.buyerAction = getBuyerAction(buyerActionString, money);
this.contact = getContact(contactMap);
this.paymentSourceId = null;
this.paymentSourceId = paymentSourceId;

CardEntry.startCardEntryActivity(currentActivity, collectPostalCode);
shouldContinueWithRequestGiftCardEntry = true;

VerificationParameters params = new VerificationParameters(paymentSourceId, buyerAction, squareIdentifier, contact);
BuyerVerification.verify(currentActivity, params);
result.success(null);
}

public void startCardEntryFlowWithBuyerVerification(
MethodChannel.Result result,
boolean collectPostalCode,
String squareLocationId,
String buyerActionString,
Map<String, Object> moneyMap,
Map<String, Object> contactMap,
String paymentSourceId
) {
shouldListen = true;

this.collectPostalCode = collectPostalCode;
this.squareIdentifier = new SquareIdentifier.LocationToken(squareLocationId);
Money money = getMoney(moneyMap);
this.buyerAction = getBuyerAction(buyerActionString, money);
this.contact = getContact(contactMap);
this.paymentSourceId = paymentSourceId;

shouldContinueWithRequestCardEntry = true;

VerificationParameters params = new VerificationParameters(paymentSourceId, buyerAction, squareIdentifier, contact);
BuyerVerification.verify(currentActivity, params);
result.success(null);
}

public void startBuyerVerificationFlow(MethodChannel.Result result, String buyerActionString, Map<String, Object> moneyMap, String squareLocationId, Map<String, Object> contactMap, String paymentSourceId) {
shouldListen = true;
this.squareIdentifier = new SquareIdentifier.LocationToken(squareLocationId);
Money money = getMoney(moneyMap);
this.buyerAction = getBuyerAction(buyerActionString, money);
this.contact = getContact(contactMap);
this.paymentSourceId = paymentSourceId;

shouldContinueWithRequestCardEntry = false;
shouldContinueWithRequestGiftCardEntry = false;

VerificationParameters params = new VerificationParameters(paymentSourceId, buyerAction, squareIdentifier, contact);
BuyerVerification.verify(currentActivity, params);
result.success(null);
Expand Down
Loading