Skip to content

Commit

Permalink
[No ticket] - Merging Feature branch post campaign (#1988)
Browse files Browse the repository at this point in the history
* WIP pager experimentation

* Merge branch 'master' into mgriego/experimental_compose_pager

* add some fixes for add-ons screen, add shipping rules

* remove some unused imports

* updated spacing for add-ons container

* move checkout flow code to its own viewmodel

* [MBL-1257] Add existing logic for rewards carousel to new compose flow (#1978)

* adjust viewmodel to use UI State class for reward carousel

* Add logic for rewards carousel screen, fix a few visual bugs, adjust logic to use coroutines and flows/ui states

* lint

* more lint

* move reward carousel logic into its own viewmodel/ui state

* lint and info comments

* MBL-1258 Add logic for add ons screen (#1980)

* Skeleton AddOnsVM and navigation to Confirm Pledge Details screen

* Logic for location selector - hide for digital addons, update shipping costs when location changes

* Fix bug with currentShippingRule state not persisting

* Update AddOnsUIState.currentAddOnsSelection instead of local addOnsMap to correctly count total addons

* Fix bug where addOnCount is not remembered when navigating back to addons

* Clean up ktlint

* Clear previous addons selection when a new reward is selected

* Also clear individual item count when new reward is selected

* If reward cannot be shipped, only display addons that also cannot be shipped

* Fix ktlint

* Reset shippingSelectorIsGone when new reward is selected

* Copy over Alex's fix on master

* ktlint

* Add comment back to config.yml

* MBL-1291: Feature Flag for latePledges (#1986)

* [MBL-1259] Add logic for confirm checkout page (#1979)

* add display logic for confirm details screen

* add stripe card ids

* remove unused import

* add create checkout call to move on from confirmation page

* formatting and default action on next button

* lint

* add logic for quantities for confirm screen

* fix logic when displaying the shipping location an amounts

* add bonus support min additions and amount conversions

* lint

* update implementation in checkout screen based on local changes

* remove unneeded disclaimer text on reward cards

* remove unused import

* add new translated string

* fix shipping amount for rewards (add-ons not working?)

* add full id list for confirm checkout, calculate totals more accurately

* [NoTicket] Fix add-ons shipping rule logic  (#1987)

* move add-ons and shipping rules logic out of flow viewmodel, fix add-ons shipping amounts diplayed, update add-ons when shipping rule changes, filter add-ons based on reward selection

* lint

* clean up state emission

* remove unneeded binging reference

---------

Co-authored-by: Matthew <[email protected]>
Co-authored-by: mtgriego <[email protected]>
Co-authored-by: Yun Cheng <[email protected]>
  • Loading branch information
4 people authored Mar 27, 2024
1 parent 037f96d commit 30da44f
Show file tree
Hide file tree
Showing 27 changed files with 2,087 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ base_job: &base_job
executor:
name: android/android-machine
resource-class: xlarge
tag: default
tag: default #https://circleci.com/developer/images/image/cimg/android
working_directory: "~/project"
environment:
TERM: dumb
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
android:screenOrientation="portrait"
android:exported="true"
android:configChanges="screenSize|orientation"
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustPan"
tools:ignore="LockedOrientationActivity" >

</activity>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ fragment payment on CreditCard {
expirationDate
type
state
stripeCardId
}

fragment freeformPost on FreeformPost {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/graphql/payments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ query UserPayments {
state
paymentType
type
stripeCardId
}
}
}
Expand All @@ -28,6 +29,7 @@ mutation SavePaymentMethod($paymentType: PaymentTypes, $stripeToken: String, $st
state
paymentType
type
stripeCardId
}
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/kickstarter/libs/utils/RewardUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ object RewardUtils {
*/
fun hasBackers(reward: Reward) = reward.backersCount().isNonZero()

fun isAvailable(project: Project, reward: Reward) = project.isLive && !isLimitReached(reward) && !isExpired(reward)
fun isAvailable(project: Project, reward: Reward) =
(project.isLive || (project.isInPostCampaignPledgingPhase() ?: false && project.postCampaignPledgingEnabled() ?: false)) && !isLimitReached(reward) && !isExpired(reward)

/**
* Returns `true` if the reward has expired.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ fun Project.updateProjectWith(config: Config, user: User?): Project {
.build()
}

fun Project.showLatePledgeFlow() = this.isInPostCampaignPledgingPhase() ?: false && this.postCampaignPledgingEnabled() ?: false

/**
* Checks if the given card type is listed in the available card types
*
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/kickstarter/models/StoredCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ class StoredCard private constructor(
private val lastFourDigits: String?,
private val type: CreditCardTypes?,
private val resourceId: Int?,
private val clientSetupId: String?
private val clientSetupId: String?,
private val stripeCardId: String?
) : Parcelable {
fun id() = this.id
fun expiration() = this.expiration
fun lastFourDigits() = this.lastFourDigits
fun type() = this.type
fun resourceId() = this.resourceId
fun clientSetupId() = this.clientSetupId
fun stripeCardId() = this.stripeCardId

@Parcelize
data class Builder(
Expand All @@ -29,21 +31,24 @@ class StoredCard private constructor(
private var expiration: Date? = null,
private var type: CreditCardTypes? = CreditCardTypes.`$UNKNOWN`,
private var resourceId: Int? = null,
private var clientSetupId: String? = null
private var clientSetupId: String? = null,
private var stripeCardId: String? = null
) : Parcelable {
fun id(id: String?) = apply { this.id = id }
fun lastFourDigits(lastFourDigits: String?) = apply { this.lastFourDigits = lastFourDigits }
fun expiration(expiration: Date?) = apply { this.expiration = expiration }
fun type(type: CreditCardTypes?) = apply { this.type = type }
fun resourceId(resourceId: Int?) = apply { this.resourceId = resourceId }
fun clientSetupId(clientSetupId: String?) = apply { this.clientSetupId = clientSetupId }
fun stripeCardId(stripeCardId: String?) = apply { this.stripeCardId = stripeCardId }
fun build() = StoredCard(
id = id,
lastFourDigits = lastFourDigits,
expiration = expiration,
type = type,
resourceId = resourceId,
clientSetupId = clientSetupId
clientSetupId = clientSetupId,
stripeCardId = stripeCardId
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ fun StoredCard.getBackingData(
setupIntentClientSecret = this.clientSetupId(),
locationId = locationId,
rewardsIds = rewards,
refTag = if (cookieRefTag?.tag()?.isNotEmpty() == true) cookieRefTag else null
refTag = if (cookieRefTag?.tag()?.isNotEmpty() == true) cookieRefTag else null,
stripeCardId = this.stripeCardId()
)
} else {
CreateBackingData(
Expand All @@ -48,7 +49,8 @@ fun StoredCard.getBackingData(
paymentSourceId = this.id(),
locationId = locationId,
rewardsIds = rewards,
refTag = if (cookieRefTag?.tag()?.isNotEmpty() == true) cookieRefTag else null
refTag = if (cookieRefTag?.tag()?.isNotEmpty() == true) cookieRefTag else null,
stripeCardId = this.stripeCardId()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient
.id(cardData.id())
.lastFourDigits(cardData.lastFour())
.type(it.type())
.stripeCardId(it.stripeCardId())
.build()
cardsList.add(card)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import com.kickstarter.libs.RefTag
import com.kickstarter.models.Project
import com.kickstarter.models.Reward

data class CreateBackingData(val project: Project, val amount: String, val paymentSourceId: String? = null, val setupIntentClientSecret: String? = null, val locationId: String?, val reward: Reward? = null, val rewardsIds: List<Reward>? = null, val refTag: RefTag?)
data class CreateBackingData(val project: Project, val amount: String, val paymentSourceId: String? = null, val setupIntentClientSecret: String? = null, val locationId: String?, val reward: Reward? = null, val rewardsIds: List<Reward>? = null, val refTag: RefTag?, val stripeCardId: String? = null)
Loading

0 comments on commit 30da44f

Please sign in to comment.