-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BANKCON-15711] Pass billing address and email address to payment det…
…ails API (#4148) Android equivalent: stripe/stripe-android#9446 ## Summary This passes the billing address model and a billing email to the `/consumers/payment_details/` API. More details: https://docs.google.com/document/d/1IP66DkxVK6DzeGCmuw00Gt9okFhEHQgM3lqBZSA-M4E/edit?usp=sharing ## Motivation BANKCON-15711 ## Testing Unit tests, and I've verified the billing fields are correctly passed from MPE to the API call: <img width="1246" alt="Screenshot 2024-10-16 at 3 12 25 PM" src="https://github.com/user-attachments/assets/1d780fdd-bc69-45ba-9b22-0cf3f3295683"> ## Changelog N/a
- Loading branch information
1 parent
8856caf
commit 7abb1ad
Showing
11 changed files
with
197 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
StripeCore/StripeCore/Source/Connections Bindings/BillingAddress.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// BillingAddress.swift | ||
// StripeCore | ||
// | ||
// Created by Mat Schmid on 2024-10-16. | ||
// | ||
|
||
import Foundation | ||
|
||
@_spi(STP) public struct BillingAddress: Encodable { | ||
let name: String? | ||
let line1: String? | ||
let line2: String? | ||
let city: String? | ||
let state: String? | ||
let postalCode: String? | ||
let countryCode: String? | ||
|
||
@_spi(STP) public init( | ||
name: String? = nil, | ||
line1: String? = nil, | ||
line2: String? = nil, | ||
city: String? = nil, | ||
state: String? = nil, | ||
postalCode: String? = nil, | ||
countryCode: String? = nil | ||
) { | ||
self.name = name | ||
self.line1 = line1 | ||
self.line2 = line2 | ||
self.city = city | ||
self.state = state | ||
self.postalCode = postalCode | ||
self.countryCode = countryCode | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case name | ||
case line1 = "line_1" | ||
case line2 = "line_2" | ||
case city = "locality" | ||
case state = "administrative_area" | ||
case postalCode = "postal_code" | ||
case countryCode = "country_code" | ||
} | ||
|
||
// Custom encoder to only encode non-nil & non-empty properties. | ||
@_spi(STP) public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
if let name, !name.isEmpty { try container.encode(name, forKey: .name) } | ||
if let line1, !line1.isEmpty { try container.encode(line1, forKey: .line1) } | ||
if let line2, !line2.isEmpty { try container.encode(line2, forKey: .line2) } | ||
if let city, !city.isEmpty { try container.encode(city, forKey: .city) } | ||
if let state, !state.isEmpty { try container.encode(state, forKey: .state) } | ||
if let postalCode, !postalCode.isEmpty { try container.encode(postalCode, forKey: .postalCode) } | ||
if let countryCode, !countryCode.isEmpty { try container.encode(countryCode, forKey: .countryCode) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters