Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
laurentbourg opened this issue May 4, 2023 · 16 comments

Comments

@laurentbourg
Copy link

IMG_5671

@scannillo
Copy link
Collaborator

scannillo commented May 4, 2023

👋 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?

@laurentbourg
Copy link
Author

laurentbourg commented May 5, 2023

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.

@scannillo
Copy link
Collaborator

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

@laurentbourg
Copy link
Author

laurentbourg commented May 6, 2023

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

@scannillo
Copy link
Collaborator

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.

@laurentbourg
Copy link
Author

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

@laurentbourg
Copy link
Author

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.

@scannillo
Copy link
Collaborator

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.

@laurentbourg
Copy link
Author

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.

@laurentbourg
Copy link
Author

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.

@laurentbourg
Copy link
Author

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.

@scannillo
Copy link
Collaborator

scannillo commented May 10, 2023

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.

@laurentbourg
Copy link
Author

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

@scannillo
Copy link
Collaborator

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 👏 .

@laurentbourg
Copy link
Author

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

@scannillo
Copy link
Collaborator

👋 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants