Skip to content
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

[NT-720] Add ApplePayCapableType to Environment, add Checkout Properties #1015

Merged
merged 14 commits into from
Jan 13, 2020

Conversation

ifbarrera
Copy link
Contributor

@ifbarrera ifbarrera commented Jan 8, 2020

📲 What

In order to better access and better test Apple Pay capabilities, this PR creates ApplePayCapableType and adds this type as a property on the Environment. This allows us to easily access Apple Pay capabilities from the environment, and to mock out various Apple Pay capabilities during testing.

🤔 Why

Events cleanup.

🛠 How

This refactor made it possible to access applePayCapableFor(project) from the PledgeViewModel without needing to inject this value into the configuration.

Additionally, this PR adds the following "Checkout Properties:

  • checkout_amount // including shipping
  • checkout_payment_type // APPLE_PAY or CREDIT_CARD
  • checkout_reward_id
  • checkout_reward_title
  • checkout_revenue_in_usd_cents
  • checkout_shipping_amount
  • checkout_reward_estimated_delivery_on
  • checkout_reward_shipping_enabled
  • checkout_user_has_eligibile_stored_apple_pay_card

To test these checkout properties, this PR adds the "Checkout Completed" event.

♿️ Accessibility

N/A

🏎 Performance

N/A

✅ Acceptance criteria

  • verify that checkout out with Apple Pay is working normally

⏰ TODO

  • add checkout_revenue_in_usd_cents

@nativeksr
Copy link
Collaborator

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up and making it all testable, great work!

Library/Extensions/Double.swift Outdated Show resolved Hide resolved
import KsApi
import PassKit

public protocol ApplePayCapableType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering about the name seeing as it does a little more than just tell us whether the device is capable of Apple Pay. Anyway, no super strong feelings about it, but just ApplePayType would probably be fine too 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the term I was going for here is capabilities to encompass all Apple-Pay-related capabilities. But ApplePayCapabilitiesType didn't quite have the same ring to it 😅. ApplePayType and then ApplePay seems a little vague to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally like ApplePayCababilities, because it's more general. For me, ApplePayCapable refers to something with a boolean type (function, var...).

@ifbarrera ifbarrera added the blocked a PR that is blocked for external reasons label Jan 9, 2020
@ifbarrera ifbarrera removed the blocked a PR that is blocked for external reasons label Jan 10, 2020
Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

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

Nice job, @ifbarrera . I only left a couple of questions/suggestions.

@@ -497,7 +497,13 @@ public final class DeprecatedRewardPledgeViewModel: Type, Inputs, Outputs {
)
.map { ($0.0, $0.1, $1, $2, $3) }
.takeWhen(Signal.merge(applePayEventAfterLogin, loggedInUserTappedApplePayButton))
.map(PKPaymentRequest.paymentRequest(for:reward:pledgeAmount:selectedShippingRule:merchantIdentifier:))
.map { PKPaymentRequest.paymentRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for curiosity, is there any reason why you decided to pass the values explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler needed help 😓

XCTAssertEqual(
["Pledge Screen Viewed", "Pledge Button Clicked"],
self.trackingClient.events
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm.. I think the properties are not being tested here.


self.scheduler.run()

XCTAssertEqual(["Pledge Screen Viewed"], self.trackingClient.events)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too... which properties are involved in this test? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right, we actually don't need this test anymore because we don't have the Completed Checkout event anymore. Will remove!

import KsApi
import PassKit

public protocol ApplePayCapableType {
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally like ApplePayCababilities, because it's more general. For me, ApplePayCapable refers to something with a boolean type (function, var...).

Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

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

🚢 🚢 🚢 🚢

@ifbarrera ifbarrera merged commit 7d0bb76 into master Jan 13, 2020
@ifbarrera ifbarrera deleted the NT-720-checkout-properties branch January 13, 2020 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants