capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apple Pay iOS not working, amount nil inside ApplePayExecutor

PronosSport opened this issue · comments

Platform

  • Web
  • iOS
  • Android

Describe the bug
Apple Pay not working, amount is nil inside ApplePayExecutor. working fine with Android play, and classic credit card/paypal with createPaymentSheet method.

To Reproduce
Steps to reproduce the behavior:
1.
await Stripe.createApplePay({ paymentIntentClientSecret: paymentIntent, paymentSummaryItems: [ { label: 'xxx', amount: 500, }, ], merchantIdentifier: 'merchant.com.xxx', countryCode: 'FR', currency: 'EUR', });

error inside ApplePayExecutor :
`
func createApplePay(_ call: CAPPluginCall) {
let paymentIntentClientSecret = call.getString("paymentIntentClientSecret") ?? nil
if paymentIntentClientSecret == nil {
call.reject("Invalid Params. this method require paymentIntentClientSecret")
return
}

    let items = call.getArray("paymentSummaryItems", [String: Any].self) ?? nil
    if items == nil {
        call.reject("Invalid Params. this method require paymentSummaryItems")
        return
    }

    var paymentSummaryItems: [PKPaymentSummaryItem] = []
    if let strs = items {
        for item in strs {
            let label = item["label"] as? String ?? ""
            let amount = item["amount"] as? NSNumber
            let amountD: NSDecimalNumber

            amountD = NSDecimalNumber(decimal: **amount!**.decimalValue)

       // .........
    `

CapacitorCommunityStripe/ApplePayExecutor.swift:42: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Expected behavior
getting amount should not be nil

Screenshots
Capture d’écran 2024-04-26 à 11 35 15

Additional context
iOS simulator : iPhone 15 pro.
I follow all step from documentation, merchant certificate etc...

Using Function:

  • Payment Sheet / Payment Flow
  • Apple Pay
  • Google Pay
  • Identity (@capacitor-community/stripe-identity)
  • Terminal(@capacitor-community/stripe-terminal)