Skip to content

Commit

Permalink
Merge pull request #15 from afterpay/maintenance/update-from-upstream…
Browse files Browse the repository at this point in the history
…-button-cashapp

maintenance: update from upstream - CashAppPay via Afterpay Button
  • Loading branch information
ScottAntonacAP authored Jun 23, 2024
2 parents 3a5df18 + 4e8e895 commit 3ba3fbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ object Afterpay {
* Returns an [Intent] for the given [context] and options that can be passed to
* [startActivityForResult][android.app.Activity.startActivityForResult] to initiate the
* Afterpay checkout.
*
* @param isCashApp Should this checkout be backed by Cash App (true) or Afterpay (false)
*/
@JvmStatic
@JvmOverloads
Expand All @@ -271,6 +273,7 @@ object Afterpay {
orderTotal: OrderTotal,
items: Array<CheckoutV3Item> = arrayOf(),
buyNow: Boolean,
isCashApp: Boolean,
configuration: CheckoutV3Configuration? = checkoutV3Configuration,
): Intent {
requireNotNull(configuration) {
Expand All @@ -281,6 +284,7 @@ object Afterpay {
orderTotal = orderTotal,
items = items,
configuration = configuration,
isCashAppPay = isCashApp,
)
val options = AfterpayCheckoutV3Options(
buyNow = buyNow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ internal object CheckoutV3 {
val merchant: Merchant,
val shipping: Contact?,
val billing: Contact?,
val isCashAppPay: Boolean?,
) {
companion object {
@JvmStatic
fun create(
consumer: CheckoutV3Consumer,
isCashAppPay: Boolean?,
orderTotal: OrderTotal,
items: Array<CheckoutV3Item>,
configuration: CheckoutV3Configuration,
Expand Down Expand Up @@ -75,6 +77,8 @@ internal object CheckoutV3 {
),
shipping = Contact.create(consumer.shippingInformation),
billing = Contact.create(consumer.billingInformation),
// server only handles true or null
isCashAppPay = isCashAppPay?.let { if (!it) null else true },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class CheckoutFragment : Fragment() {
),
),
buyNow = command.buyNow,
isCashApp = false,
)
startActivityForResult(intent, CHECKOUT_WITH_AFTERPAY_V3)
}
Expand Down

0 comments on commit 3ba3fbe

Please sign in to comment.