Skip to content

Commit

Permalink
[PAY-1979] Update Backing Mutation To Use Setup Intent (#1744)
Browse files Browse the repository at this point in the history
* update graph schema from staging and added setupIntentClientSecret to updateBackingInput

* added logic to filter out all contexts except .fixpaymentmethod from allowing payment sheet appearance and creation of cards.

* updated constructor with setup intent client secret.

* wasnt previously sending setup intent client secret to update backing

* updated tests
  • Loading branch information
msadoon committed Oct 11, 2022
1 parent f2f731d commit 3dfa5c7
Show file tree
Hide file tree
Showing 11 changed files with 463 additions and 473 deletions.
70 changes: 10 additions & 60 deletions KsApi/GraphAPI.swift
Expand Up @@ -630,11 +630,11 @@ public enum GraphAPI {
/// - rewardIds: List of Relay encoded Reward/Add-on IDs
/// - locationId
/// - paymentSourceId: new payment source id
/// - intentClientSecret: Stripe SetupIntent client secret
/// - applePay
/// - googlePay
/// - clientMutationId: A unique identifier for the client performing the mutation.
public init(id: GraphQLID, amount: Swift.Optional<String?> = nil, rewardId: Swift.Optional<GraphQLID?> = nil, rewardIds: Swift.Optional<[GraphQLID]?> = nil, locationId: Swift.Optional<String?> = nil, paymentSourceId: Swift.Optional<String?> = nil, applePay: Swift.Optional<ApplePayInput?> = nil, googlePay: Swift.Optional<GooglePayInput?> = nil, clientMutationId: Swift.Optional<String?> = nil) {
graphQLMap = ["id": id, "amount": amount, "rewardId": rewardId, "rewardIds": rewardIds, "locationId": locationId, "paymentSourceId": paymentSourceId, "applePay": applePay, "googlePay": googlePay, "clientMutationId": clientMutationId]
public init(id: GraphQLID, amount: Swift.Optional<String?> = nil, rewardId: Swift.Optional<GraphQLID?> = nil, rewardIds: Swift.Optional<[GraphQLID]?> = nil, locationId: Swift.Optional<String?> = nil, paymentSourceId: Swift.Optional<String?> = nil, intentClientSecret: Swift.Optional<String?> = nil, applePay: Swift.Optional<ApplePayInput?> = nil, clientMutationId: Swift.Optional<String?> = nil) {
graphQLMap = ["id": id, "amount": amount, "rewardId": rewardId, "rewardIds": rewardIds, "locationId": locationId, "paymentSourceId": paymentSourceId, "intentClientSecret": intentClientSecret, "applePay": applePay, "clientMutationId": clientMutationId]
}

public var id: GraphQLID {
Expand Down Expand Up @@ -694,21 +694,22 @@ public enum GraphAPI {
}
}

public var applePay: Swift.Optional<ApplePayInput?> {
/// Stripe SetupIntent client secret
public var intentClientSecret: Swift.Optional<String?> {
get {
return graphQLMap["applePay"] as? Swift.Optional<ApplePayInput?> ?? Swift.Optional<ApplePayInput?>.none
return graphQLMap["intentClientSecret"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "applePay")
graphQLMap.updateValue(newValue, forKey: "intentClientSecret")
}
}

public var googlePay: Swift.Optional<GooglePayInput?> {
public var applePay: Swift.Optional<ApplePayInput?> {
get {
return graphQLMap["googlePay"] as? Swift.Optional<GooglePayInput?> ?? Swift.Optional<GooglePayInput?>.none
return graphQLMap["applePay"] as? Swift.Optional<ApplePayInput?> ?? Swift.Optional<ApplePayInput?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "googlePay")
graphQLMap.updateValue(newValue, forKey: "applePay")
}
}

Expand All @@ -723,57 +724,6 @@ public enum GraphAPI {
}
}

/// Necessary fields for Google Pay
public struct GooglePayInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - token: Stripe token
/// - googleTransactionId
/// - instrumentDetails
/// - instrumentType
public init(token: String, googleTransactionId: Swift.Optional<String?> = nil, instrumentDetails: String, instrumentType: String) {
graphQLMap = ["token": token, "googleTransactionId": googleTransactionId, "instrumentDetails": instrumentDetails, "instrumentType": instrumentType]
}

/// Stripe token
public var token: String {
get {
return graphQLMap["token"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "token")
}
}

public var googleTransactionId: Swift.Optional<String?> {
get {
return graphQLMap["googleTransactionId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "googleTransactionId")
}
}

public var instrumentDetails: String {
get {
return graphQLMap["instrumentDetails"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "instrumentDetails")
}
}

public var instrumentType: String {
get {
return graphQLMap["instrumentType"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "instrumentType")
}
}
}

/// Autogenerated input type of UpdateUserAccount
public struct UpdateUserAccountInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap
Expand Down

0 comments on commit 3dfa5c7

Please sign in to comment.