-
Notifications
You must be signed in to change notification settings - Fork 14
feat(card): native Apple/Google Pay push provisioning via MeaWallet MPP #2754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,092
−23
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4a8a0ad
feat(card): native Apple/Google Pay push provisioning via MeaWallet MPP
innolope-dev 4a6a488
chore: sync api types (provisioning-data 503 + rate-limit code)
innolope-dev 58453ab
fix: review findings — workflow config guard, postsync anchors, walle…
innolope-dev fed3e94
feat(ios): scaffold Wallet issuer-provisioning extension targets
innolope-dev 03c4022
fix(android): use legacy pushCard (TSP-only) instead of Unified push
innolope-dev e075697
review(coderabbit): gate nativeAvailable on alreadyInWallet
innolope-dev c4ce2b4
Merge remote-tracking branch 'origin/dev' into feat/push-provisioning
innolope-dev 5411f1d
review(chip): yellow-path continuation, sheet cancellation, extension…
innolope-dev 0e2800a
review(chip): Watch-only provisioning and the Google Wallet install gate
innolope-dev a9f5595
review(chip): per-platform MeaWallet Nexus secret names
innolope-dev 2d98692
review(chip): embed and sign the Wallet provisioning extensions
innolope-dev 876cb25
fix(card): close the native path until the provisioning route is depl…
innolope-dev 54d2daf
fix(android): gate the MeaWallet SDK on both Nexus credentials
innolope-dev 418825b
fix(card): keep Android on the manual carousel until Google supplies …
innolope-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
174 changes: 174 additions & 0 deletions
174
android/app/src/meawallet/java/me/peanut/wallet/PushProvisioningPlugin.java
This file contains hidden or 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,174 @@ | ||
| package me.peanut.wallet; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.Intent; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| import com.getcapacitor.JSObject; | ||
| import com.getcapacitor.Plugin; | ||
| import com.getcapacitor.PluginCall; | ||
| import com.getcapacitor.PluginMethod; | ||
| import com.getcapacitor.annotation.CapacitorPlugin; | ||
| import com.google.android.gms.tapandpay.issuer.TokenInfo; | ||
| import com.google.android.gms.tapandpay.issuer.UserAddress; | ||
| import com.meawallet.mpp.GooglePayRegisteredTokensListener; | ||
| import com.meawallet.mpp.MeaPushProvisioning; | ||
| import com.meawallet.mpp.MppCardDataParameters; | ||
| import com.meawallet.mpp.MppError; | ||
| import com.meawallet.mpp.MppPaymentNetwork; | ||
| import com.meawallet.mpp.MppPushCardToGooglePayListener; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Google Pay push provisioning via the MeaWallet MPP SDK. This file lives in | ||
| * src/meawallet/java, which app/build.gradle adds to the source set only when | ||
| * the MeaWallet Nexus credentials are present — builds without the SDK never | ||
| * compile it, and MainActivity registers it via a reflection lookup that | ||
| * tolerates its absence. The mea_config SDK config ships in res/raw (gitignored, | ||
| * CI-injected); without it every method reports unavailable. | ||
| */ | ||
| @CapacitorPlugin(name = "PushProvisioning") | ||
| public class PushProvisioningPlugin extends Plugin { | ||
|
|
||
| private static boolean initialize(android.content.Context context) { | ||
| try { | ||
| if (!MeaPushProvisioning.isInitialized()) { | ||
| MeaPushProvisioning.initialize(context); | ||
| } | ||
| return true; | ||
| } catch (Exception e) { | ||
| // Missing/broken mea_config — treat as "SDK not in this build". | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| /** Called reflectively from MainActivity.onActivityResult — must not throw. */ | ||
| public static boolean handleGooglePayActivityResult(int requestCode, int resultCode, Intent data, Activity activity) { | ||
| try { | ||
| if (!MeaPushProvisioning.isInitialized()) return false; | ||
| return MeaPushProvisioning.GooglePay.handleOnActivityResult(requestCode, resultCode, data, activity); | ||
| } catch (Exception e) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| private boolean hasMeaConfig() { | ||
| return getContext().getResources().getIdentifier("mea_config", "raw", getContext().getPackageName()) != 0; | ||
| } | ||
|
|
||
| @PluginMethod | ||
| public void isAvailable(PluginCall call) { | ||
| if (!hasMeaConfig() || !initialize(getContext())) { | ||
|
innolope-dev marked this conversation as resolved.
Outdated
|
||
| JSObject out = new JSObject(); | ||
| out.put("available", false); | ||
| out.put("alreadyInWallet", false); | ||
| call.resolve(out); | ||
| return; | ||
| } | ||
| String last4 = call.getString("last4", ""); | ||
| if (last4 == null || last4.isEmpty()) { | ||
| JSObject out = new JSObject(); | ||
| out.put("available", true); | ||
| out.put("alreadyInWallet", false); | ||
| call.resolve(out); | ||
| return; | ||
| } | ||
| MeaPushProvisioning.GooglePay.checkWalletForCardSuffix(last4, new GooglePayRegisteredTokensListener() { | ||
| @Override | ||
| public void onSuccess(@NonNull List<TokenInfo> tokens) { | ||
| JSObject out = new JSObject(); | ||
| out.put("available", tokens.isEmpty()); | ||
|
innolope-dev marked this conversation as resolved.
Outdated
|
||
| out.put("alreadyInWallet", !tokens.isEmpty()); | ||
| call.resolve(out); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(@NonNull MppError error) { | ||
| // Can't tell — let the button show; the push flow surfaces the | ||
| // real error if the card is genuinely already tokenized. | ||
| JSObject out = new JSObject(); | ||
| out.put("available", true); | ||
| out.put("alreadyInWallet", false); | ||
| call.resolve(out); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @PluginMethod | ||
| public void addCard(PluginCall call) { | ||
| String cardId = call.getString("cardId"); | ||
| String cardSecret = call.getString("cardSecret"); | ||
| if (cardId == null || cardSecret == null) { | ||
| call.reject("cardId and cardSecret are required", "BAD_PARAMS"); | ||
| return; | ||
| } | ||
| if (!hasMeaConfig() || !initialize(getContext())) { | ||
| call.reject("MeaWallet SDK unavailable in this build", "UNAVAILABLE"); | ||
| return; | ||
| } | ||
| Activity activity = getActivity(); | ||
| if (activity == null) { | ||
| call.reject("No foreground activity", "UNAVAILABLE"); | ||
| return; | ||
| } | ||
|
|
||
| MppCardDataParameters cardParams = MppCardDataParameters.withCardSecret(cardId, cardSecret); | ||
| String displayName = call.getString("displayName", "Peanut Card"); | ||
| UserAddress userAddress = buildUserAddress(call); | ||
|
|
||
| // LEGACY flow on purpose: pushCard(...) is Google's TSP-only Push | ||
| // Provisioning, push(...) (same signature) is Unified Push Provisioning. | ||
| // Rain does not support UPP yet (docs.rain.xyz/docs/push-provisioning); | ||
| // Google deprecates legacy end of 2026, so this becomes push(...) once | ||
| // Rain confirms UPP support + the Google UPP onboarding is done. | ||
| // Intermediate results come back through onActivityResult — | ||
| // MainActivity forwards them to handleGooglePayActivityResult above. | ||
| MeaPushProvisioning.GooglePay.pushCard(cardParams, displayName, userAddress, activity, new MppPushCardToGooglePayListener() { | ||
| @Override | ||
| public void onSuccess(String tokenReferenceId, String cardLastFourDigits, MppPaymentNetwork cardNetwork) { | ||
| JSObject out = new JSObject(); | ||
| out.put("added", true); | ||
| out.put("last4", cardLastFourDigits); | ||
| call.resolve(out); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(MppError error) { | ||
| JSObject out = new JSObject(); | ||
| out.put("added", false); | ||
| out.put("error", error != null ? error.getMessage() : "unknown"); | ||
|
innolope-dev marked this conversation as resolved.
Outdated
|
||
| call.resolve(out); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Billing address from the provisioning-data endpoint → Google's UserAddress. | ||
| * Google uses it to prefill the tokenization sheet; incomplete fields are | ||
| * tolerated here (the backend already refused cards with no billing at all). | ||
| */ | ||
| private UserAddress buildUserAddress(PluginCall call) { | ||
| JSObject addr = call.getObject("address", new JSObject()); | ||
| UserAddress.Builder builder = UserAddress.newBuilder(); | ||
| String name = call.getString("cardholderName", ""); | ||
| if (name != null && !name.isEmpty()) builder.setName(name); | ||
| putIfPresent(addr, "line1", builder::setAddress1); | ||
| putIfPresent(addr, "line2", builder::setAddress2); | ||
| putIfPresent(addr, "city", builder::setLocality); | ||
| putIfPresent(addr, "region", builder::setAdministrativeArea); | ||
| putIfPresent(addr, "postalCode", builder::setPostalCode); | ||
| putIfPresent(addr, "countryCode", builder::setCountryCode); | ||
| return builder.build(); | ||
| } | ||
|
|
||
| private interface Setter { | ||
| void set(String value); | ||
| } | ||
|
|
||
| private static void putIfPresent(JSObject obj, String key, Setter setter) { | ||
| String value = obj.getString(key, ""); | ||
| if (value != null && !value.isEmpty()) setter.set(value); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.