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

Vault without Purchase #172

Merged
merged 29 commits into from
Aug 17, 2023
Merged

Vault without Purchase #172

merged 29 commits into from
Aug 17, 2023

Conversation

KunJeongPark
Copy link
Collaborator

@KunJeongPark KunJeongPark commented Aug 1, 2023

Summary of changes

  • Create setup token with empty card object in demo app, simulating merchant server's behavior and output
  • Use graphQL endpoint to update setup token with payment method.
  • Create VaultDelegate protocol and delegate methods to return setup token id and vault status to merchant app
  • Implement creating actual payment token using setupToken in demo app via sample merchant server call to PayPal API
  • Fix unit tests, add new ones from changes

There is currently a refactor ticket (#177) on the network layer that includes replacing GraphQLClient. There are some TODO comments to mark some changes to address after the refactor.

TODO for another PR handling 3DS contingency:

  • Use GET request for getting setupToken to get minimum PaymentSource information and for 3DS contingency, updated
    status, 3Ds results.

    We are not fetching minimum paymentSource from UpdateSetupToken graphQL endpoint. (following JS implementation)
    I am assuming that this is because of cards with 3DS contingency where GET request is needed
    for updated status. Using a separate GET request lets me use objects internal to CardPayments module.

  • Not clear on 3DS contingency => I am not getting 3DS url (helios link) from setup token endpoints (from setup token create with or without card info, update setup token endpoint) with many of the test cards that I've
    tried. These test cards did trigger 3DS contingency in checkout flow.

I am confused about whether 3DS contingency gets kicked off at moment of standalone vault or during checkout process with the vaulted method. I think it's the former but wanted to make sure I know all the steps involved in creating 3DS contingency correctly for standalone vaulting.

Checklist

  • Added a changelog entry

Authors

@KunJeongPark KunJeongPark changed the title vault without purchase Vault without Purchase Aug 2, 2023
@KunJeongPark KunJeongPark marked this pull request as ready for review August 11, 2023 04:32
@KunJeongPark KunJeongPark requested a review from a team as a code owner August 11, 2023 04:32
Demo/Demo/Models/PaymentTokenRequest.swift Outdated Show resolved Hide resolved
Demo/Demo/Models/PaymentTokenRequest.swift Outdated Show resolved Hide resolved
Demo/Demo/Models/PaymentTokenRequest.swift Outdated Show resolved Hide resolved
Demo/Demo/Models/PaymentTokenRequest.swift Outdated Show resolved Hide resolved
Demo/Demo/Models/SetupTokenRequest.swift Outdated Show resolved Hide resolved
Sources/CardPayments/CardClient.swift Outdated Show resolved Hide resolved
Sources/CardPayments/Models/Card.swift Show resolved Hide resolved
Demo/Demo/Models/PaymentTokenRequest.swift Outdated Show resolved Hide resolved
Demo/Demo/Networking/DemoMerchantAPI.swift Outdated Show resolved Hide resolved
Demo/Demo/Networking/DemoMerchantAPI.swift Outdated Show resolved Hide resolved
Demo/Demo/Networking/DemoMerchantAPI.swift Show resolved Hide resolved
Demo/Demo/Networking/DemoMerchantAPI.swift Show resolved Hide resolved
Sources/CardPayments/CardClient.swift Show resolved Hide resolved
Sources/CardPayments/CardClient.swift Outdated Show resolved Hide resolved
Sources/CardPayments/CardClient.swift Show resolved Hide resolved
Sources/CardPayments/CardClientError.swift Outdated Show resolved Hide resolved
Copy link
Collaborator

@jaxdesmarais jaxdesmarais left a comment

Choose a reason for hiding this comment

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

Just a few questions/cleanup comments

]
]
]
return try? JSONSerialization.data(withJSONObject: requestBody)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return try? JSONSerialization.data(withJSONObject: requestBody)
return try? JSONSerialization.data(withJSONObject: requestBody)

]
]
]
return try? JSONSerialization.data(withJSONObject: requestBody)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return try? JSONSerialization.data(withJSONObject: requestBody)
return try? JSONSerialization.data(withJSONObject: requestBody)

environment: DemoSettings.environment,
selectedMerchantIntegration: selectedMerchantIntegration
)
let data = try await data(for: urlRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is a little too far indented

@@ -69,6 +69,23 @@ struct SwiftUICardDemo: View {
)
.cornerRadius(10)
.disabled(!baseViewModel.isCardFormValid(cardNumber: cardNumberText, expirationDate: expirationDateText, cvv: cvvText))
Button("Vault Card without Purchase") {
guard let card = baseViewModel.createCard(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha - should we print an error here or something in that case or do some sort of validation for the buttons?

var mockErrorResponse: Error?

override func callGraphQL<T, Q>(
name: String, query: Q
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
name: String, query: Q
name: String,
query: Q

@KunJeongPark KunJeongPark merged commit 7660350 into main Aug 17, 2023
4 checks passed
@KunJeongPark KunJeongPark deleted the vaultWithoutPurchase branch August 17, 2023 01:18
scannillo pushed a commit that referenced this pull request Aug 24, 2023
* vault without purchase

* clean up cardClient initializer

* Use associatedType for variables for GraphQLQuery protocol

* moving setuptoken call to demo app

* use APIRequest for merchantServer setupToken request

* use enum for PaymentSourceInput for different payment options

* get request for setup token details

* move graphQL request, responses from Core to Card module

* remove APIRequest use in demo app

* Add VaultCardDelegate for VaultCardResult

* Add payment token creation in demo app

* remove duplicate UpdateSetupTokenQuery.swift

* rename UpdateSetupTokenRequest to UpdateSetupTokenQuery

* added newly named file reference to project

* add mocks for unit tests, pr feedback

* disable swiftlint for multiline query, target for card test

* correct target for MockGraphQLClient

* CardClient vault error tests

* docStrings and CHANGELOG

* PR feedback

* PR feedback

* PR feedback nodoc String for GraphQLQuery requestBody()

* spacing in paymentTokenRequest

* PR feedback

* PR feedback from Jax 8/16/23

* PR feedback from Jax cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants