paypal/paypal-ios

Native checkout - the button has a persistent progress view on it when selecting payment

laurentbourg opened this issue ยท 16 comments

๐Ÿ‘‹ Hi @laurentbourg - thanks for using the PayPal iOS SDK!

Please consult our repo docs here. You need to call actions.approve() or actions.reject() when either of the PayPalNativeShippingDelegate methods get called in order to continue the flow and stop the spinner.

Have you done that?

Thanks @scannillo for your reply, I was not implementing the shipping delegate, I implemented it just now and it never gets called when the sheet pops up, this issue does not happen when I try to modify shipping details, it happens immediately when the sheet pops up. The button has a spinner but I can still tap it and capture the order fine.

Also, I am not getting a spinner when using the PayPalCheckout sdk directly.

Can you provide us a few more details:

  • SDK Version:
  • SDK environment: sand or production
  • Either a sample project or sample code showing more details on how you're integrating the PayPalNativePayments module

Hi please see below:

latest SDK version from main branch
Environment: sandbox

Here is the key view model code:

 func checkout(orderid: String) {
        Task {
            do {
                self.orderid = orderid
                await initialize()
                if state == .ready {
                    state = .creatingOrder
                    if let paypal_orderID = try await GetNoshAPI.shared.createPayPalOrder(orderid: orderid) {
                        state = .orderCreated
                        let request = PayPalNativeCheckoutRequest(orderID: paypal_orderID)
                        await payPalClient?.start(request: request)
                    }
                }
            } catch let error {
                payPalClient = nil
                state = .error(desc: error.localizedDescription)
            }
        }
    }

// Initialize method initializes the payPalClient object

I implemented it just now and it never gets called when the sheet pops up, this issue does not happen when I try to modify shipping details

Did you make sure to set payPalClient?.shippingDelegate = self?

Also, can you share what the details of your order request look like? If there is address information included, you may actually need to implement those shipping callbacks and call shippingActions.approve() when called.

That worked thanks Sammy for your help :) My 2 cents: It might not be super intuitive to require an additional delegate to be implemented, most people expect the main delegate (i.e PayPalNativeCheckoutDelegate) to suffice for the basic flow. If it's a requirement then maybe it's better to include shipping requirements in the main delegate so that the user knows at compile time that he needs to implement the shipping methods or by some other mechanism keeping the shipping methods in a separate delegate but that will break at compile time if not implemented.

Laurent

Just to add to this point, the native PayPalCheckout behavior does not seem to require the implementation of a shipping delegate. If one is not provided, the flow still works well. But if a shipping delegate is provided, then it requires the user to approve and reject adequately otherwise you get the same spinning behavior.

This is really valuable feedback. We really appreciate any and all feedback as we prepare to go GA v1 very soon.

The PayPalNativeShippingDelegate was made optional before we learned that patching was required by the merchant for some use cases.

Current behavior:

  • Order IDs created with shipping_preference = NO_SHIPPING or SET_PROVIDED_ADDRESS - require no server-side patching, therefore PayPalNativeShippingDelegate doesn't need to be implemented.
  • Order IDs created with shipping_preference =GET_FROM_FILE - server-side patching must be done via hooks exposed in PayPalNativeShippingDelegate (see Orders V2 Documentation).

That said - it's confusing. We should make it more clear that using GET_FROM_FILE to create your orderID requires the delegate to be implemented.

Thanks for your clarifications/details, much appreciated as well. I ended up setting my server side to a SET_PROVIDED_ADDRESS as my business workflow does not allow any change of the shipping address at payment time, and in that case the PayPalNativeShippingDelegate is indeed not needed.

One side question to wrap this thread, my order creation is done with a CAPTURE Intent. The button that is displayed on the payment sheet says "Review Order", why doesn't it say "Pay" since the next step is to capture the payment? This is the same behavior in the PayPalCheckout library, I am just not clear on why it behaves this way.

I think I can just answer this question, it seems there is a user_action field in the PayPal experience context which allows the change this behavior.

I think I can just answer this question, it seems there is a user_action field in the PayPal experience context which allows the change this behavior.

Great find! I see the documentation for user_action here, but it is marked as deprecated. I will double check the best option to use with our PayPal Native Checkout team internally.

I think this one works fine payment_source.paypal.experience_context.user_action

Once the above PRs are merged, I will close this issue. Thank you for bringing this up and don't hesitate to open new issues in the future, it helps us a ton ๐Ÿ‘ .

Thanks again for all your help @scannillo. Will be following up regarding the other issue.

๐Ÿ‘‹ Hello @laurentbourg . PR https://github.com/paypal/iOS-SDK/pull/150 was merged, which addresses the original issue this thread was opened for. Thank you for the valuable feedback!

Please don't hesitate to open more issues with questions in the future!