Skip to content

Commit

Permalink
feat: change allowedCountriesError to allowedCountriesErrorDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubén García de Longoria committed Jan 29, 2024
1 parent 18f7ea0 commit f487ea8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/payment/ios/Plugin/ApplePay/ApplePayExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ApplePayExecutor: NSObject, ApplePayContextDelegate {
private var payCallId: String?
private var paymentRequest: PKPaymentRequest?
private var allowedCountries: [String] = []
private var allowedCountriesError: String = ""
private var allowedCountriesErrorDescription: String = ""

func isApplePayAvailable(_ call: CAPPluginCall) {
if !StripeAPI.deviceSupportsApplePay() {
Expand Down Expand Up @@ -50,7 +50,7 @@ class ApplePayExecutor: NSObject, ApplePayContextDelegate {
let merchantIdentifier = call.getString("merchantIdentifier") ?? ""
let requiredShippingContactFields = call.getArray("requiredShippingContactFields", String.self) ?? [""]
self.allowedCountries = call.getArray("allowedCountries", String.self) ?? []
self.allowedCountriesError = call.getString("allowedCountriesError") ?? "Country not allowed"
self.allowedCountriesErrorDescription = call.getString("allowedCountriesErrorDescription") ?? "Country not allowed"

let paymentRequest = StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: call.getString("countryCode", "US"), currency: call.getString("currency", "USD"))
paymentRequest.paymentSummaryItems = paymentSummaryItems
Expand Down Expand Up @@ -145,7 +145,7 @@ extension ApplePayExecutor {
let addressIsoCountry = (contact.postalAddress?.isoCountryCode as? String ?? "").lowercased();
if !self.allowedCountries.contains(addressIsoCountry) {
handler(PKPaymentRequestShippingContactUpdate.init(
errors: [PKPaymentRequest.paymentShippingAddressInvalidError(withKey: CNPostalAddressISOCountryCodeKey, localizedDescription: self.allowedCountriesError)],
errors: [PKPaymentRequest.paymentShippingAddressInvalidError(withKey: CNPostalAddressISOCountryCodeKey, localizedDescription: self.allowedCountriesErrorDescription)],
paymentSummaryItems: self.paymentRequest?.paymentSummaryItems ?? [],
shippingMethods: self.paymentRequest?.shippingMethods ?? []))
return
Expand Down
2 changes: 1 addition & 1 deletion packages/payment/src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export interface CreateApplePayOption {
currency: string;
requiredShippingContactFields?: ('postalAddress' | 'phoneNumber' | 'emailAddress' | 'name')[];
allowedCountries?: string[];
allowedCountriesError?: string;
allowedCountriesErrorDescription?: string;
}

export interface CreateGooglePayOption {
Expand Down

0 comments on commit f487ea8

Please sign in to comment.