afterpay / sdk-ios

Afterpay iOS SDK
https://developers.afterpay.com
Apache License 2.0
20 stars 10 forks source link

Bug: `shippingAddressDidChange` callback is not being called #178

Closed EvgenyKarkan closed 3 years ago

EvgenyKarkan commented 3 years ago

🌎 Environment

💬 Description

The shippingAddressDidChange callback is not being called as documentation states (neither when express checkout is launched nor when shipping address changed).

🦶 Reproduction Steps

I'm following your readme and trying to do an AfterPay Express checkout. I obtained a token from my service and was able to start a user experience. I see the AP screen as follows. ap

However I'm not getting the shippingAddressDidChange callback as your documentation states, thus I cannot obtain a shipping address to call my service to get shipping options and then pass shipping options to your SDK so you can reload UI.

This callback also is not being called when I switch between shipping addresses.

Afterpay.presentCheckoutV2Modally(over: self,
                                  animated: true,
                                  options: options) { (tokenResultCompletion) in
    let result = TokenResult.success(token) // <-- token obtained from my server
    tokenResultCompletion(result)
} shippingAddressDidChange: { (shippingAddress, shippingOptionsCompletion) in
    /// code flow doesn't reach here
} shippingOptionDidChange: { (shippingOption) in

} completion: { (result) in

}

I tried setting a custom handler, but this function does not work as well, so seems there is no way to obtain an address.

func shippingAddressDidChange(address: ShippingAddress, completion: @escaping ShippingOptionsCompletion) 

Am I doing something wrong, or this is a known issue? If this is a known issue do you guys have an ETA with the fix?

🤔 Expected Results

The shippingAddressDidChange callback is being called when an express checkout is launched or when the address is changed.

😲 Actual Results

The shippingAddressDidChange callback is not being called

EvgenyKarkan commented 3 years ago

I guess I've found the root cause. I was setting the wrong popupOriginUrl value, instead of https://static.afterpay.com mentioned in Readme. After setting it as you suggest - was able to obtain the callback.

EvgenyKarkan commented 3 years ago

Closing the ticket.