capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
185 stars 75 forks source link

Apple Pay iOS not working, amount nil inside ApplePayExecutor #351

Open PronosSport opened 2 months ago

PronosSport commented 2 months ago

Platform

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', });

2. 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: