Skip to content

Commit

Permalink
Merge pull request #466 from gini/IPC-161_Universal_links_for_payment…
Browse files Browse the repository at this point in the history
…_providers

feat(GiniHealthSDK): Payment provider universal link to launch the payment provider app IPC-161
  • Loading branch information
razvancapra authored Mar 26, 2024
2 parents 4faa62d + e0795b8 commit dae2a13
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ public struct PaymentProvider: Codable {
var minAppVersion: MinAppVersions?
public var iconData: Data
public var appStoreUrlIOS: String?
public var universalLinkIOS: String

public init(id: String, name: String, appSchemeIOS: String, minAppVersion: MinAppVersions?, colors: ProviderColors, iconData: Data, appStoreUrlIOS: String?) {
public init(id: String, name: String, appSchemeIOS: String, minAppVersion: MinAppVersions?, colors: ProviderColors, iconData: Data, appStoreUrlIOS: String?, universalLinkIOS: String) {
self.id = id
self.name = name
self.appSchemeIOS = appSchemeIOS
self.minAppVersion = minAppVersion
self.colors = colors
self.iconData = iconData
self.appStoreUrlIOS = appStoreUrlIOS
self.universalLinkIOS = universalLinkIOS
}
}
public typealias PaymentProviders = [PaymentProvider]
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ public struct PaymentProviderResponse: Codable {
var minAppVersion: MinAppVersions?
public var iconLocation: String
public var appStoreUrlIOS: String?
public var universalLinkIOS: String

public init(id: String, name: String, appSchemeIOS: String, minAppVersion: MinAppVersions?, colors: ProviderColors, iconLocation: String, appStoreUrlIOS: String?) {
public init(id: String, name: String, appSchemeIOS: String, minAppVersion: MinAppVersions?, colors: ProviderColors, iconLocation: String, appStoreUrlIOS: String?, universalLinkIOS: String) {
self.id = id
self.name = name
self.appSchemeIOS = appSchemeIOS
self.minAppVersion = minAppVersion
self.colors = colors
self.iconLocation = iconLocation
self.appStoreUrlIOS = appStoreUrlIOS
self.universalLinkIOS = universalLinkIOS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ extension PaymentService {
self.file(urlString: providerResponse.iconLocation) { result in
switch result {
case let .success(imageData):
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData, appStoreUrlIOS: providerResponse.appStoreUrlIOS)
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData, appStoreUrlIOS: providerResponse.appStoreUrlIOS, universalLinkIOS: providerResponse.universalLinkIOS)
providers.append(provider)
case let .failure(error):
completion(.failure(error))
Expand Down Expand Up @@ -210,7 +210,7 @@ extension PaymentService {
self.file(urlString: providerResponse.iconLocation) { result in
switch result {
case let .success(imageData):
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData, appStoreUrlIOS: providerResponse.appStoreUrlIOS)
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData, appStoreUrlIOS: providerResponse.appStoreUrlIOS, universalLinkIOS: providerResponse.universalLinkIOS)
completion(.success(provider))
case let .failure(error):
completion(.failure(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"background": "009EDC",
"text": "FFFFFF"
},
"iconLocation": "https://pay-api.gini.net/paymentProviders/b09ef70a-490f-11eb-952e-9bc6f4646c57/icon"
"iconLocation": "https://pay-api.gini.net/paymentProviders/b09ef70a-490f-11eb-952e-9bc6f4646c57/icon",
"universalLinkIOS": "ginipay-bank://"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"background": "009EDC",
"text": "FFFFFF"
},
"iconLocation": "https://pay-api.gini.net/paymentProviders/b09ef70a-490f-11eb-952e-9bc6f4646c57/icon"
"iconLocation": "https://pay-api.gini.net/paymentProviders/b09ef70a-490f-11eb-952e-9bc6f4646c57/icon",
"universalLinkIOS": "ginipay-bank://"
},
{
"id": "dbe3a2ca-c9df-11eb-a1d8-a7efff6e88b7",
Expand All @@ -27,7 +28,8 @@
"background": "daa520",
"text": "54f1db"
},
"iconLocation": "https://pay-api.gini.net/paymentProviders/dbe3a2ca-c9df-11eb-a1d8-a7efff6e88b7/icon"
"iconLocation": "https://pay-api.gini.net/paymentProviders/dbe3a2ca-c9df-11eb-a1d8-a7efff6e88b7/icon",
"universalLinkIOS": "ginipay-ingdiba://"
},
{
"id": "f7d06ee0-51fd-11ec-8216-97f0937beb16",
Expand All @@ -42,7 +44,8 @@
"background": "FFFFFF",
"text": "009EDC"
},
"iconLocation": "https://pay-api.gini.net/paymentProviders/f7d06ee0-51fd-11ec-8216-97f0937beb16/icon"
"iconLocation": "https://pay-api.gini.net/paymentProviders/f7d06ee0-51fd-11ec-8216-97f0937beb16/icon",
"universalLinkIOS": "ginipay-ginibank://"
},
{
"id": "a65b0646-51fe-11ec-8736-c338396b2f09",
Expand All @@ -57,6 +60,7 @@
"background": "4DBED3",
"text": "FFFFFF"
},
"iconLocation": "https://pay-api.gini.net/paymentProviders/a65b0646-51fe-11ec-8736-c338396b2f09/icon"
"iconLocation": "https://pay-api.gini.net/paymentProviders/a65b0646-51fe-11ec-8736-c338396b2f09/icon",
"universalLinkIOS": "ginipay-consorsbank://"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func loadProviders() -> PaymentProviders {
let providersResponse = try! JSONDecoder().decode([PaymentProviderResponse].self, from: jsonData!)
for providerResponse in providersResponse {
let imageData = UIImage(named: "Gini-Test-Payment-Provider", in: Bundle.module, compatibleWith: nil)?.pngData()
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData ?? Data(), appStoreUrlIOS: providerResponse.appStoreUrlIOS)
let provider = PaymentProvider(id: providerResponse.id, name: providerResponse.name, appSchemeIOS: providerResponse.appSchemeIOS, minAppVersion: providerResponse.minAppVersion, colors: providerResponse.colors, iconData: imageData ?? Data(), appStoreUrlIOS: providerResponse.appStoreUrlIOS, universalLinkIOS: providerResponse.universalLinkIOS)
providers.append(provider)
}
return providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ public struct DataForReview {

- Parameters:
- requestID: Id of the created payment request.
- appScheme: App scheme for the selected payment provider
- universalLink: Universal link for the selected payment provider

*/
public func openPaymentProviderApp(requestID: String, appScheme: String) {
public func openPaymentProviderApp(requestID: String, universalLink: String) {
let queryItems = [URLQueryItem(name: "id", value: requestID)]
let urlString = appScheme + "://payment"
let urlString = universalLink + "://payment"
var urlComponents = URLComponents(string: urlString)!
urlComponents.queryItems = queryItems
let resultUrl = urlComponents.url!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct PaymentInfo {
public var recipient,iban: String
public var bic: String
public var amount, purpose: String
public var paymentProviderScheme: String
public var paymentUniversalLink: String
public var paymentProviderId: String

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class PaymentReviewModel: NSObject {
switch result {
case let .success(requestId):
self?.isLoading = false
self?.openPaymentProviderApp(requestId: requestId, appScheme: paymentInfo.paymentProviderScheme)
self?.openPaymentProviderApp(requestId: requestId, universalLink: paymentInfo.paymentUniversalLink)
case let .failure(error):
self?.isLoading = false
if let delegate = self?.healthSDK.delegate, delegate.shouldHandleErrorInternally(error: error) {
Expand All @@ -112,8 +112,8 @@ public class PaymentReviewModel: NSObject {
}
}

func openPaymentProviderApp(requestId: String, appScheme: String) {
healthSDK.openPaymentProviderApp(requestID: requestId, appScheme: appScheme)
func openPaymentProviderApp(requestId: String, universalLink: String) {
healthSDK.openPaymentProviderApp(requestID: requestId, universalLink: universalLink)
}

func fetchImages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public final class PaymentReviewViewController: UIViewController, UIGestureRecog
iban: ibanTextFieldView.text ?? "",
bic: "", amount: amountText,
purpose: usageTextFieldView.text ?? "",
paymentProviderScheme: selectedProvider.appSchemeIOS,
paymentUniversalLink: selectedProvider.universalLinkIOS,
paymentProviderId: selectedProvider.id)
model?.createPaymentRequest(paymentInfo: paymentInfo)
let paymentRecipientExtraction = Extraction(box: nil,
Expand Down

0 comments on commit dae2a13

Please sign in to comment.