Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
40914ab
feat: setup android inline component
kieran-osgood-shopify Nov 12, 2025
91ab2c3
fix: ensure we can respond to address change events
kieran-osgood-shopify Nov 12, 2025
6eb56fa
chore: remove redundant address change map
kieran-osgood-shopify Nov 12, 2025
b55ea61
remove unused imports
kieran-osgood-shopify Nov 12, 2025
4319800
fix: rename CheckoutCompletedEvent -> CheckoutCompleteEvent
kieran-osgood-shopify Nov 13, 2025
e585ce7
refactor: remove deprecated method overrides
kieran-osgood-shopify Nov 13, 2025
c38175e
chore: cleaning up token and networking debugging
kieran-osgood-shopify Nov 13, 2025
f0e5ced
fix: remove android debugging code - readd timeout
kieran-osgood-shopify Nov 13, 2025
c2730a0
fix: add event handlers for CheckoutScreen
kieran-osgood-shopify Nov 13, 2025
278620a
refactor: remove unnecessary view in buynowbutton
kieran-osgood-shopify Nov 13, 2025
1323004
fix: yarn module build errors
kieran-osgood-shopify Nov 13, 2025
704cfb1
refactor(RCTCheckoutWebView): replace complicated if checks with .equ…
kieran-osgood-shopify Nov 14, 2025
4926b04
refactor: remove lint warnings on type coersion
kieran-osgood-shopify Nov 14, 2025
2684297
refactor: use shorter kotlin unit instance
kieran-osgood-shopify Nov 14, 2025
09e2522
fix: remove absolute user path
kieran-osgood-shopify Nov 26, 2025
049a571
fix: issues with inconsistent names of events
kieran-osgood-shopify Nov 27, 2025
1bd7aa0
refactor: remove unnecesasry logging and overrides
kieran-osgood-shopify Nov 27, 2025
3b9ad9d
remove classPaths from build.gradle
kieran-osgood-shopify Nov 27, 2025
fe15ad7
feat: add event handling to inline webview android
kieran-osgood-shopify Nov 27, 2025
f80904b
refactor: simplifying map construction
kieran-osgood-shopify Nov 27, 2025
d33096f
refactor: remove deprecated event emitting
kieran-osgood-shopify Nov 27, 2025
ffbb322
refactor: extract CheckoutEvent for instance based events
kieran-osgood-shopify Nov 27, 2025
73fb035
fix: webview not loading
kieran-osgood-shopify Nov 27, 2025
0664faf
cleanup events that arent ready - rename onClickLink
kieran-osgood-shopify Nov 27, 2025
0d3b83a
add nonnull annotation for getEventName
kieran-osgood-shopify Nov 27, 2025
857fa72
fix: remove onLoad from swift
kieran-osgood-shopify Nov 27, 2025
fa56ba3
rename customeventprocessor -> Sheeteventprocessor
kieran-osgood-shopify Nov 27, 2025
3c82c9a
refactor: undo changes to reuse custom event processor for inline
kieran-osgood-shopify Nov 27, 2025
0d0d0f3
fix: intermitent flakiness of layout for checkout webview inline
kieran-osgood-shopify Nov 27, 2025
51c1ff4
remove unused variable
kieran-osgood-shopify Nov 27, 2025
43464ab
fix: flatten onerror - implement onlinkclick
kieran-osgood-shopify Nov 27, 2025
9999547
format files
kieran-osgood-shopify Nov 28, 2025
2e7b283
fix: type in TAG - remove unused comments
kieran-osgood-shopify Nov 28, 2025
95b387d
fix: remove record (java16 feature)
kieran-osgood-shopify Nov 28, 2025
d22b70f
fix: ensure layout params are applied to webview
kieran-osgood-shopify Nov 28, 2025
6d88aa0
test: RctCheckoutWebViewTests
kieran-osgood-shopify Nov 28, 2025
3a7c499
refactor: improve tests with side effects of setup checks
kieran-osgood-shopify Nov 28, 2025
7464de9
refactor: remove intent from event naming
kieran-osgood-shopify Nov 25, 2025
f153c9b
fix: align types to rfc
kieran-osgood-shopify Nov 27, 2025
f0f8bb9
feat: add paymentInstruments and payment delegation
kieran-osgood-shopify Nov 28, 2025
244f103
feat: add onPaymentMethodChangeStart to inline event processor
kieran-osgood-shopify Nov 28, 2025
bbda17d
format: function arguments implicit types
kieran-osgood-shopify Nov 28, 2025
d9a3354
Merge branch 'prototype/development' into prototype-development/issue…
kieran-osgood-shopify Nov 28, 2025
082539d
Merge branch 'prototype/development' into prototype-development/issue…
kieran-osgood-shopify Nov 28, 2025
7f5a7bc
fix: incorrect type returned in onPaymentMethodChangeStart
kieran-osgood-shopify Nov 28, 2025
f76b543
fix: linting
kieran-osgood-shopify Nov 28, 2025
89cf35f
fix: use CheckoutPaymentMethodChangeStartResponse for respondWith
kieran-osgood-shopify Dec 1, 2025
500215d
refactor: use enum for event types
kieran-osgood-shopify Dec 1, 2025
401ddbb
Merge branch 'prototype/development' into prototype-development/issue…
kieran-osgood-shopify Dec 1, 2025
ef4161c
fix: increase strictness of respondWith
kieran-osgood-shopify Dec 2, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
MIT License

Copyright 2023 - Present, Shopify Inc.

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.
*/

package com.shopify.reactnative.checkoutsheetkit;

/**
* Registering a new type in this enum will automatically register a channel
* that can trigger an event to be received back in React Native.
*
* For example, you can trigger an event from Java/Kotlin by calling:
*
* RCTCheckoutWebView.sendEvent(CheckoutEventType.ON_START, null);
*
* This will execute the corresponding prop in JavaScript:
*
* <ShopifyCheckout
* onStart={() => {}} // <- Will be executed
* />
*/
public enum CheckoutEventType {
ON_START("onStart"),
ON_ERROR("onError"),
ON_COMPLETE("onComplete"),
ON_CANCEL("onCancel"),
ON_LINK_CLICK("onLinkClick"),
ON_ADDRESS_CHANGE_START("onAddressChangeStart"),
ON_PAYMENT_METHOD_CHANGE_START("onPaymentMethodChangeStart"),
ON_SUBMIT_START("onSubmitStart");

private final String eventName;

CheckoutEventType(String eventName) {
this.eventName = eventName;
}

public String getEventName() {
return eventName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ of this software and associated documentation files (the "Software"), to deal
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;

Expand All @@ -42,6 +41,7 @@ of this software and associated documentation files (the "Software"), to deal

import com.shopify.checkoutsheetkit.Authentication;
import com.shopify.checkoutsheetkit.CheckoutException;
import com.shopify.checkoutsheetkit.CheckoutPaymentMethodChangeStartParams;
import com.shopify.checkoutsheetkit.DefaultCheckoutEventProcessor;
import com.shopify.checkoutsheetkit.CheckoutOptions;
import com.shopify.checkoutsheetkit.CheckoutWebView;
Expand All @@ -55,11 +55,14 @@ of this software and associated documentation files (the "Software"), to deal
import com.shopify.checkoutsheetkit.lifecycleevents.CheckoutStartEvent;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutAddressChangeStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutAddressChangeStartEvent;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStartEvent;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutPaymentMethodChangeStart;

import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStartEvent;


import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -286,18 +289,18 @@ private String getErrorTypeName(CheckoutException error) {
}
}

private void sendEvent(String eventName, WritableMap params) {
private void sendEvent(CheckoutEventType eventType, WritableMap params) {
ReactContext reactContext = this.context.getReactApplicationContext();
int viewId = getId();

EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId);
if (eventDispatcher == null) {
Log.w(TAG, "Cannot send event '" + eventName + "': EventDispatcher not available (viewId=" + viewId + ")");
Log.w(TAG, "Cannot send event '" + eventType.getEventName() + "': EventDispatcher not available (viewId=" + viewId + ")");
return;
}

int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
eventDispatcher.dispatchEvent(new CheckoutEvent(surfaceId, viewId, eventName, params));
eventDispatcher.dispatchEvent(new CheckoutEvent(surfaceId, viewId, eventType.getEventName(), params));
}

private class InlineCheckoutEventProcessor extends DefaultCheckoutEventProcessor {
Expand All @@ -310,7 +313,7 @@ public InlineCheckoutEventProcessor(android.content.Context context) {
public void onStart(@NonNull CheckoutStartEvent event) {
try {
WritableMap data = serializeToWritableMap(event);
sendEvent("onStart", data);
sendEvent(CheckoutEventType.ON_START, data);
} catch (Exception e) {
Log.e(TAG, "Error processing start event", e);
}
Expand All @@ -320,20 +323,20 @@ public void onStart(@NonNull CheckoutStartEvent event) {
public void onComplete(@NonNull CheckoutCompleteEvent event) {
try {
WritableMap data = serializeToWritableMap(event);
sendEvent("onComplete", data);
sendEvent(CheckoutEventType.ON_COMPLETE, data);
} catch (Exception e) {
Log.e(TAG, "Error processing complete event", e);
}
}

@Override
public void onFail(@NonNull CheckoutException error) {
sendEvent("onError", buildErrorMap(error));
sendEvent(CheckoutEventType.ON_ERROR, buildErrorMap(error));
}

@Override
public void onCancel() {
sendEvent("onCancel", null);
sendEvent(CheckoutEventType.ON_CANCEL, null);
}

@Override
Expand All @@ -347,13 +350,28 @@ public void onAddressChangeStart(@NonNull CheckoutAddressChangeStart event) {
eventData.put("addressType", params.getAddressType());
eventData.put("cart", params.getCart());

sendEvent("onAddressChangeStart", serializeToWritableMap(eventData));
sendEvent(CheckoutEventType.ON_ADDRESS_CHANGE_START, serializeToWritableMap(eventData));
} catch (Exception e) {
Log.e(TAG, "Error processing address change start event", e);
}
}

@Override
public void onPaymentMethodChangeStart(@NonNull CheckoutPaymentMethodChangeStart event) {
try {
CheckoutPaymentMethodChangeStartParams params = event.getParams();

Map<String, Object> eventData = new HashMap<>();
eventData.put("id", event.getId());
eventData.put("type", "paymentMethodChangeStart");
eventData.put("cart", params.getCart());

sendEvent(CheckoutEventType.ON_PAYMENT_METHOD_CHANGE_START, serializeToWritableMap(eventData));
} catch (Exception e) {
Log.e(TAG, "Error processing address change start event", e);
}
}

public void onSubmitStart(@NonNull CheckoutSubmitStart event) {
try {
CheckoutSubmitStartEvent params = event.getParams();
Expand All @@ -367,7 +385,7 @@ public void onSubmitStart(@NonNull CheckoutSubmitStart event) {
checkoutData.put("id", params.getCheckout().getId());
eventData.put("checkout", checkoutData);

sendEvent("onSubmitStart", serializeToWritableMap(eventData));
sendEvent(CheckoutEventType.ON_SUBMIT_START, serializeToWritableMap(eventData));
} catch (Exception e) {
Log.e(TAG, "Error processing submit start event", e);
}
Expand All @@ -377,7 +395,7 @@ public void onSubmitStart(@NonNull CheckoutSubmitStart event) {
public void onLinkClick(@NonNull Uri uri) {
WritableMap params = Arguments.createMap();
params.putString("url", uri.toString());
sendEvent("onLinkClick", params);
sendEvent(CheckoutEventType.ON_LINK_CLICK, params);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,15 @@ public void receiveCommand(@NonNull RCTCheckoutWebView view, String commandId, @
@Override
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
Map<String, Object> events = new HashMap<>();
events.put("onStart", createEventMap("onStart"));
events.put("onError", createEventMap("onError"));
events.put("onComplete", createEventMap("onComplete"));
events.put("onCancel", createEventMap("onCancel"));
events.put("onLinkClick", createEventMap("onLinkClick"));
events.put("onAddressChangeStart", createEventMap("onAddressChangeStart"));
events.put("onSubmitStart", createEventMap("onSubmitStart"));
for (CheckoutEventType eventType : CheckoutEventType.values()) {
String eventName = eventType.getEventName();
Map<String, String> event = new HashMap<>();
event.put("registrationName", eventName);
events.put(eventName, event);
}
return events;
}

private Map<String, String> createEventMap(String eventName) {
Map<String, String> event = new HashMap<>();
event.put("registrationName", eventName);
return event;
}

@Override
public void onDropViewInstance(@NonNull RCTCheckoutWebView view) {
Log.d(TAG, "onDropViewInstance: Properly cleaning up CheckoutWebView");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ of this software and associated documentation files (the "Software"), to deal

import com.shopify.checkoutsheetkit.CheckoutException;
import com.shopify.checkoutsheetkit.CheckoutExpiredException;
import com.shopify.checkoutsheetkit.CheckoutPaymentMethodChangeStartParams;
import com.shopify.checkoutsheetkit.CheckoutSheetKitException;
import com.shopify.checkoutsheetkit.ClientException;
import com.shopify.checkoutsheetkit.ConfigurationException;
Expand All @@ -44,6 +45,8 @@ of this software and associated documentation files (the "Software"), to deal
import com.shopify.checkoutsheetkit.lifecycleevents.CheckoutStartEvent;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutAddressChangeStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutAddressChangeStartEvent;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutPaymentMethodChangeStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStart;
import com.shopify.checkoutsheetkit.rpc.events.CheckoutSubmitStartEvent;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -175,6 +178,22 @@ public void onAddressChangeStart(@NonNull CheckoutAddressChangeStart event) {
}

@Override
public void onPaymentMethodChangeStart(@NonNull CheckoutPaymentMethodChangeStart event) {
try {
CheckoutPaymentMethodChangeStartParams params = event.getParams();

Map<String, Object> eventData = new HashMap<>();
eventData.put("id", event.getId());
eventData.put("type", "paymentMethodChangeStart");
eventData.put("cart", params.getCart());

String data = mapper.writeValueAsString(eventData);
sendEventWithStringData("paymentMethodChangeStart", data);
} catch (IOException e) {
Log.e(TAG, "Error processing address change start event", e);
}
}

public void onSubmitStart(@NonNull CheckoutSubmitStart event) {
try {
CheckoutSubmitStartEvent params = event.getParams();
Expand All @@ -200,7 +219,6 @@ public void onSubmitStart(@NonNull CheckoutSubmitStart event) {
}

// Private

private Map<String, Object> populateErrorDetails(CheckoutException error) {
Map<String, Object> errorMap = new HashMap<>(Map.of(
"__typename", getErrorTypeName(error),
Expand Down
Loading
Loading