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

Add Multibanco bindings and PaymentSheet support #3531

Merged
merged 10 commits into from
Apr 24, 2024

Conversation

porter-stripe
Copy link
Collaborator

@porter-stripe porter-stripe commented Apr 22, 2024

Summary

  • Adds Multibanco bindings
  • Adds Multibanco support to PaymentSheet

Bindings

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-04-22.at.10.51.31.mp4

PaymentSheet

Simulator.Screen.Recording.-.iPhone.15.Plus.-.2024-04-23.at.09.26.24.mp4

Motivation

https://docs.google.com/document/d/1QVT2zuwkz9IFTBNyjsYV_zzfeOsWva8gpSz2vXPHfW8/edit

Testing

  • New tests
  • Manual

Changelog

See diff

Copy link

github-actions bot commented Apr 22, 2024

⚠️ Public API changes detected:

StripePayments

+ @objc final public let entity: Swift.String
+ @objc final public let reference: Swift.String
+ @objc final public let expiresAt: Foundation.Date
+ @objc final public let hostedVoucherURL: Foundation.URL
+ @objc public var allResponseFields: [Swift.AnyHashable : Any] {
+ get
+ }
+ @objc override dynamic public var description: Swift.String {
+ @objc get
+ }
+ @objc public static func decodedObject(fromAPIResponse response: [Swift.AnyHashable : Any]?) -> Self?
+ @objc deinit
+ @objc public var multibanco: StripePayments.STPPaymentMethodMultibanco? {
+ get
+ }
+ case multibanco
+ @objc public var multibanco: StripePayments.STPPaymentMethodMultibancoParams?
+ @objc convenience public init(multibanco: StripePayments.STPPaymentMethodMultibancoParams, billingDetails: StripePayments.STPPaymentMethodBillingDetails?, metadata: [Swift.String : Swift.String]?)
+ @objc public var allResponseFields: [Swift.AnyHashable : Any] {
+ get
+ }
+ @objc override dynamic public var description: Swift.String {
+ @objc get
+ }
+ @objc public static func decodedObject(fromAPIResponse response: [Swift.AnyHashable : Any]?) -> Self?
+ @objc deinit
+ case multibancoDisplayDetails
+ @objc final public let multibancoDisplayDetails: StripePayments.STPIntentActionMultibancoDisplayDetails?
+ @objc public var additionalAPIParameters: [Swift.AnyHashable : Any]
+ @objc public static func rootObjectName() -> Swift.String?
+ @objc public static func propertyNamesToFormFieldNamesMapping() -> [Swift.String : Swift.String]
+ @objc override dynamic public init()
+ @objc deinit

If you are adding a new public API consider the following:

  • Do these APIs need to be public or can they be protected with @_spi(STP)?
  • If these APIs need to be public, assess whether they require an API review.

If you are modifying or removing a public API:

  • Does this require a breaking version change?
  • Do these changes require API review?

If you confirm these APIs need to be added/updated and have undergone necessary review, add the label modifies public API to this PR to acknowledge and bypass this check.

@porter-stripe porter-stripe changed the title Add Multibanco bindings Add Multibanco bindings and PaymentSheet support Apr 23, 2024
@porter-stripe porter-stripe marked this pull request as ready for review April 23, 2024 16:38
@porter-stripe porter-stripe requested review from a team as code owners April 23, 2024 16:38
Comment on lines 1251 to 1252
createExpectation.fulfill()
clientSecret = createdClientSecret
Copy link
Collaborator

Choose a reason for hiding this comment

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

The fulfill should probably happen after

            clientSecret = createdClientSecret

let client = STPAPIClient(publishableKey: STPTestingDefaultPublishableKey)
let expectation = self.expectation(description: "Payment Intent confirm")

let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret!)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid clientSecret!:

waitForExpectations(...)
guard let clientSecret = clientSecret else {
   XCTFail("")
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Used XCTUnwrap!

paymentIntentParams.returnURL = "example-app-scheme://unused"
client.confirmPaymentIntent(with: paymentIntentParams) { paymentIntent, error in
XCTAssertNil(error, "With valid key + secret, should be able to confirm the intent")

Copy link
Collaborator

Choose a reason for hiding this comment

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

might better to:

guard let paymentIntent= paymentIntent else {
   XCTFail()
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried to use XCTUnwrap but the complier complains for some reason inside of a closure.

Comment on lines +717 to +720
case .amazonPay:
self.amazonPay = STPPaymentMethodAmazonPayParams()
case .alma:
self.alma = STPPaymentMethodAlmaParams()
Copy link
Collaborator

@wooj-stripe wooj-stripe Apr 24, 2024

Choose a reason for hiding this comment

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

oops -- i guess this was broken before. Thanks for fixing.

self.alma = STPPaymentMethodAlmaParams()
case .multibanco:
self.multibanco = STPPaymentMethodMultibancoParams()
self.billingDetails = paymentMethod.billingDetails
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.billingDetails = paymentMethod.billingDetails is being set prior to the case statement. this doesn't seem needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch, didn't see that

@@ -264,6 +274,10 @@ public class STPIntentAction: NSObject {
if let swishHandleRedirect = swishHandleRedirect {
props.append("swishHandleRedirect = \(swishHandleRedirect)")
}
case .multibancoDisplayDetails:
if let multibancoDisplayDetails = multibancoDisplayDetails {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we can get away with just if let multibancoDisplayDetails {

self
),
// MultibancoDisplayDetails
"number = \(String(describing: entity))",
Copy link
Collaborator

@wooj-stripe wooj-stripe Apr 24, 2024

Choose a reason for hiding this comment

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

is calling the entity a 'number' intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope! Good catch.

@porter-stripe porter-stripe enabled auto-merge (squash) April 24, 2024 22:10
@porter-stripe porter-stripe merged commit 3ef0224 into master Apr 24, 2024
3 checks passed
@porter-stripe porter-stripe deleted the porter/multibanco branch April 24, 2024 22:11
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.

2 participants