Skip to content

Update data classes to reflect latest web pixel schema #119

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
merged 6 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.4 August 7, 2024

- Update Web Pixel schema data classes.

## 3.0.3 August 6, 2024

- Tag instrumentation with `preloading` state.
Expand All @@ -16,9 +20,9 @@
## 3.0.0 May 20, 2024

- `ShopifyCheckoutSheet.present()` now returns an interface allowing clients to dismiss the sheet.
- Error handling has been improved*. The kit also attempts to load checkout in a recovery WebView when certain errors are encountered. See [Error Handling](https://github.com/Shopify/checkout-sheet-kit-android#error-handling) for more information.
- Error handling has been improved\*. The kit also attempts to load checkout in a recovery WebView when certain errors are encountered. See [Error Handling](https://github.com/Shopify/checkout-sheet-kit-android#error-handling) for more information.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is auto-formatting


*Please note the exception class hierarchy has been updated to be more comprehensive. Each exception class now returns an `isRecoverable: Boolean`, an `errorCode` and an `errorDescription`.
\*Please note the exception class hierarchy has been updated to be more comprehensive. Each exception class now returns an `isRecoverable: Boolean`, an `errorCode` and an `errorDescription`.

## 2.0.1 March 19, 2024

Expand All @@ -36,16 +40,16 @@ If you were previously setting the loading spinner color, the field has been ren

```diff
Colors(
- spinnerColor = Color.ResourceId(R.color.a_color),
+ progressIndicator = Color.ResourceId(R.color.a_color),
- spinnerColor = Color.ResourceId(R.color.a_color),
+ progressIndicator = Color.ResourceId(R.color.a_color),
)
```

2. **Breaking Changes** The `onCheckoutCompleted` callback now returns a completed event object, containing details about the order:

```kotlin
override fun onCheckoutCompleted(checkoutCompletedEvent: CheckoutCompletedEvent) {
println(checkoutCompletedEvent.orderDetails.id)
println(checkoutCompletedEvent.orderDetails.id)
}
```

Expand Down Expand Up @@ -81,12 +85,14 @@ _Note_: If your processor extends `DefaultCheckoutEventProcessor`, a no-op imple
```

2. Update the imports throughout your codebase:

```diff
- com.shopify.checkoutkit.*
+ com.shopify.checkoutsheetkit.*
```

3. Update the `present|preload|configure()` calls throughout your codebase:

```diff
- ShopifyCheckoutKit.present|preload|configure()
+ ShopifyCheckoutSheetKit.present|preload|configure()
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def resolveEnvVarValue(name, defaultValue) {
return rawValue ? rawValue : defaultValue
}

def versionName = resolveEnvVarValue("CHECKOUT_SHEET_KIT_VERSION", "3.0.3")
def versionName = resolveEnvVarValue("CHECKOUT_SHEET_KIT_VERSION", "3.0.4")

ext {
app_compat_version = '1.6.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,38 @@ public data class Checkout(
*/
public val billingAddress: MailingAddress? = null,

/**
* Indicates whether the customer has consented to be sent marketing material via email.
*/
public val buyerAcceptsEmailMarketing: Boolean? = null,

/**
* Indicates whether the customer has consented to be sent marketing material via SMS.
*/
public val buyerAcceptsSmsMarketing: Boolean? = null,

/**
* The three-letter code that represents the currency, for example, USD.
* Supported codes include standard ISO 4217 codes, legacy codes, and non-
* standard codes.
*/
public val currencyCode: String? = null,

/**
* Represents the selected delivery options for a checkout.
*/
public val delivery: Delivery? = null,

/**
* A list of discount applications.
*/
public val discountApplications: List<DiscountApplication>? = null,

/**
* The total amount of the discounts applied to the price of the checkout.
*/
public val discountsAmount: MoneyV2? = null,

/**
* The email attached to this checkout.
*/
Expand All @@ -529,6 +549,11 @@ public data class Checkout(
*/
public val lineItems: List<CheckoutLineItem>? = null,

/**
* Information about the active localized experience.
*/
public val localization: Localization? = null,

/**
* The resulting order from a paid checkout.
*/
Expand All @@ -551,6 +576,11 @@ public data class Checkout(
*/
public val shippingLine: ShippingRate? = null,

/**
* The phone number provided by the buyer after opting in to SMS marketing.
*/
public val smsMarketingPhone: String? = null,

/**
* The price at checkout before duties, shipping, and taxes.
*/
Expand Down Expand Up @@ -596,6 +626,53 @@ public data class Attribute(
public val value: String? = null
)

@Serializable
public data class Country(
/**
* The ISO-3166-1 code for this country, for example, "US".
*/
public val isoCode: String? = null,
)

@Serializable
public data class Language(
/**
* The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code, for example, "en-US".
*/
public val isoCode: String? = null,
)

@Serializable
public data class Market(
/**
* A human-readable, shop-scoped identifier.
*/
public val handle: String? = null,

/**
* A globally unique identifier.
*/
public val id: String? = null,
)

@Serializable
public data class Localization(
/**
* The country of the active localized experience.
*/
public val country: Country? = null,

/**
* The language of the active localized experience.
*/
public val language: Language? = null,

/**
* The market including the country of the active localized experience.
*/
public val market: Market? = null,
)

/**
* A mailing address for customers and shipping.
*/
Expand Down Expand Up @@ -755,16 +832,32 @@ public data class CheckoutLineItem(
*/
public val discountAllocations: List<DiscountAllocation>? = null,

/**
* The combined price of all of the items in the line item after line-level discounts have been applied.
*/
public val finalLinePrice: MoneyV2? = null,

/**
* A globally unique identifier.
*/
public val id: String? = null,

/**
* The properties of the line item. A shop may add, or enable customers to add custom information to a line item. Line item properties
* consist of a key and value pair.
*/
public val properties: List<Property>? = null,

/**
* The quantity of the line item.
*/
public val quantity: Double? = null,

/**
* The selling plan associated with the line item and the effect that each selling plan has on variants when they're purchased.
*/
public val sellingPlanAllocation: SellingPlanAllocation? = null,

/**
* The title of the line item. Defaults to the product's title.
*/
Expand All @@ -776,6 +869,47 @@ public data class CheckoutLineItem(
public val variant: ProductVariant? = null
)

@Serializable
public data class Delivery(
/**
* The selected delivery options for the event.
*/
public val selectedDeliveryOptions: List<DeliveryOption>? = null,
)

@Serializable
public data class DeliveryOption(
/**
* The cost of the delivery option.
*/
public val cost: MoneyV2? = null,

/**
* The cost of the delivery option after discounts have been applied.
*/
public val costAfterDiscounts: MoneyV2? = null,

/**
* The description of the delivery option.
*/
public val description: String? = null,

/**
* The unique identifier of the delivery option.
*/
public val handle: String? = null,

/**
* The title of the delivery option.
*/
public val title: String? = null,

/**
* The type of delivery option, e.g. pickup, pickupPoint, shipping, local.
*/
public val type: String? = null,
)

/**
* The discount that has been applied to the checkout line item.
*/
Expand All @@ -799,12 +933,59 @@ public data class DiscountAllocation(
*/
@Serializable
public data class Order(

/**
* The customer that placed the order.
*/
public val customer: OrderCustomer? = null,

/**
* The ID of the order.
*/
public val id: String? = null
)

@Serializable
public data class OrderCustomer(
/**
* The ID of the customer.
*/
public val id: String? = null,
)

@Serializable
public data class Property(
/**
* The key for the property.
*/
public val key: String? = null,
/**
* The value for the property.
*/
public val value: String? = null,
)

@Serializable
public data class SellingPlanAllocation(
/**
* A representation of how products and variants can be sold and purchased. For example, an individual selling plan could be
* '6 weeks of prepaid granola, delivered weekly'.
*/
public val sellingPlan: SellingPlan,
)

@Serializable
public data class SellingPlan(
/**
* A globally unique identifier.
*/
public val id: String? = null,
/**
* The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'.
*/
public val name: String? = null,
)

/**
* A shipping rate to be applied to a checkout.
*/
Expand All @@ -829,7 +1010,36 @@ public data class Transaction(
/**
* The name of the payment provider used for the transaction.
*/
public val gateway: String? = null
public val gateway: String? = null,

/**
* The payment method used for the transaction.
*/
public val paymentMethod: TransactionPaymentMethod? = null,
)

@Serializable
public data class TransactionPaymentMethod(
/**
* The name of the payment method used for the transaction. This may further specify the payment method used.
*/
public val name: String? = null,

/**
* The type of payment method used for the transaction.
*
* - creditCard: A vaulted or manually entered credit card.
* - redeemable: A redeemable payment method, such as a gift card or store credit.
* - deferred: A deferred payment, such as invoicing the buyer and collecting payment later.
* - local: A local payment method specific to the current region or market.
* - manualPayment: A manual payment method, such as an in-person retail transaction.
* - paymentOnDelivery: A payment that will be collected on delivery.
* - wallet: An integrated wallet, such as PayPal, Google Pay, Apple Pay, etc.
* - offsite: A payment processed outside of Shopify's checkout, excluding integrated wallets.
* - customOnSite: A custom payment method that is processed through a checkout extension with a payments app.
* - other: Another type of payment not defined here.
*/
public val type: String? = null,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CheckoutWebViewTest {
ShopifyCheckoutSheetKit.configuration.colorScheme = ColorScheme.Dark()
val view = CheckoutWebView.cacheableCheckoutView(URL, activity)

assertThat(view.settings.userAgentString).contains("ShopifyCheckoutSDK/3.0.3 ")
assertThat(view.settings.userAgentString).contains("ShopifyCheckoutSDK/3.0.4 ")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FallbackWebViewTest {
ShopifyCheckoutSheetKit.configuration.colorScheme = ColorScheme.Dark()
Robolectric.buildActivity(ComponentActivity::class.java).use { activityController ->
val view = FallbackWebView(activityController.get())
assertThat(view.settings.userAgentString).contains("ShopifyCheckoutSDK/3.0.3 ")
assertThat(view.settings.userAgentString).contains("ShopifyCheckoutSDK/3.0.4 ")
}
}

Expand Down
Loading