Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Second payment by credit card raises an exception #163

Closed
ghost opened this issue Jul 3, 2014 · 9 comments
Closed

Second payment by credit card raises an exception #163

ghost opened this issue Jul 3, 2014 · 9 comments

Comments

@ghost
Copy link

ghost commented Jul 3, 2014

I use pods with PayPal-iOS-SDK version 2.1.0
Steps to reproduce:
It look likes all you need is take second payment with credit card

  1. Put App in sandbox mode
  2. Launch app
  3. Follow to the PayPal payment view controller
  4. Press "Pay with Card"
  5. Scan card or Enter Manually
  6. Press "Charge Card"
  7. Take one more order not restarting the app Repeat steps 3 thru 6

Before a second payment:
Currently Payment Screen displays "(null) x-(Last 4 Digit of card)", (if rememberUser = YES)
Currently Payment Screen loose some labels and has no photo image inside "Pay with Card" cell. (if rememberUser = NO)

There is a brief summary:
The exception is raised into the PayPal SDK. The PayPal SDK uses inside itself the sources of another big library - CardIO. The interaction of this library sources and PayPal SDK results in a fatal error. I have attached the crash log from my device.

0 CoreFoundation 0x188762f50 _exceptionPreprocess + 132
1 libobjc.A.dylib 0x194c6c1fc objc_exception_throw + 60
2 CoreFoundation 0x188762e90 +[NSException raise:format:] + 128 << exception
3 Foundation 0x189210ab0 -[NSConcreteAttributedString initWithString:] + 132 << gets wrong attributes
4 Foundation 0x189210950 -[NSConcreteAttributedString initWithString:attributes:] + 36
5 sweetpixios 0x1001ecb4c -[CardIOViewController makeButtonWithTitle:withSelector:] + 476 << tries to create button with title
6 sweetpixios 0x1001ebab0 -[CardIOViewController viewDidLoad] + 1400
7 UIKit 0x18b72c670 -[UIViewController loadViewIfRequired] + 576 << view controller loads it's view
8 UIKit 0x18b7e4f90 -[UINavigationController _layoutViewController:] + 64
9 UIKit 0x18b7e4e8c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 248
10 UIKit 0x18b7e4360 -[UINavigationController _startTransition:fromViewController:toViewController:] + 112
11 UIKit 0x18b7e4000 -[UINavigationController startDeferredTransitionIfNeeded:] + 636
12 UIKit 0x18b7e3d24 -[UINavigationController viewWillLayoutSubviews] + 56
13 UIKit 0x18b7e3ca4 -[UILayoutContainerView layoutSubviews] + 200
14 UIKit 0x18b726ff8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 348
15 QuartzCore 0x18b318258 -[CALayer layoutSublayers] + 184
16 QuartzCore 0x18b312e20 CA::Layer::layout_if_needed(CA::Transaction
) + 300
17 QuartzCore 0x18b312cd8 CA::Layer::layout_and_display_if_needed(CA::Transaction
) + 32
18 QuartzCore 0x18b312560 CA::Context::commit_transaction(CA::Transaction
) + 280
19 QuartzCore 0x18b312304 CA::Transaction::commit() + 424
20 QuartzCore 0x18b30bc38 CA::Transaction::observer_callback(CFRunLoopObserver, unsigned long, void*) + 80 << app makes transaction to new view controller

This looks like the PayPal SDK has stored some data to present it's view controller and release a significant part of it after SDK succeeded the transaction. When PayPal view controller appears second time it loads partly released data and fails with exception.

What was done to resolve this issue:
1 I checked up all versions of PayPal SDK from 2.0 to the present one
2 I tried to reinit the SDK on every appear of the CheckoutViewController
3 Was disabled saving user settings.
4 Was added line of code to clear up all user data before showing the PayPal view controller.

@dgoldman-pdx
Copy link
Contributor

@estbyright thanks for the detailed report!

We'll investigate and post a fix ASAP.

I checked up all versions of PayPal SDK from 2.0 to the present one

The present version is 2.1.3. Did you test that one?

@dgoldman-pdx
Copy link
Contributor

@estbyright with version 2.1.0 (or newer) I haven't yet succeeded in reproducing your findings.

Can you reproduce when using the SampleApp that is included with the PayPal iOS SDK?

@alenababykina
Copy link

@dgoldman-ebay It crashes on PayPal-iOS-SDK version 2.1.4 too.

@dgoldman-pdx
Copy link
Contributor

@alenababykina, @estbyright I still haven't been able to reproduce this.

Can you reproduce when using the SampleApp that is included with the PayPal iOS SDK?

@ghost
Copy link
Author

ghost commented Jul 7, 2014

I found out the cause of this issue. This is the logic of cleaning files of the cache folder that runs on the beginnig of each "start over" cycle.
For some reason we had used this code in our app after the payment was successful.

NSURL *appCahesDirectoryURL
            = [[[NSFileManager defaultManager] URLsForDirectory: NSCachesDirectory inDomains:NSUserDomainMask] firstObject];
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL: appCahesDirectoryURL
                                                             includingPropertiesForKeys:nil
                                                                                options:NSDirectoryEnumerationSkipsSubdirectoryDescendants
                                                                           errorHandler:nil];

The second payment crashes. The PayPal SDK couldn't handle missing of its cached files correctly. Please check it up.

@dgoldman-pdx
Copy link
Contributor

@estbyright could you please post all of your relevant code? E.g., what then happens with enumerator?

@ghost
Copy link
Author

ghost commented Jul 7, 2014

Like I say, then it delete all founded files.
[NSFileManager removeItemAtURL:error:]

@dgoldman-pdx
Copy link
Contributor

Thanks, @estbyright. I see the problem in our code, and will post a fix soon.

I'm curious why you are programmatically clearing the entire app cache folder. That seems like overkill for most purposes I can think of.

In any case, we will fix this problem quickly, as deletion of app cache files can also occur at any time in low-memory situations.

@dgoldman-pdx
Copy link
Contributor

@estbyright okay, give version 2.1.5 a try. Let us know if you still encounter any problems.

(Note: I'm still curious as to why you are programmatically clearing the entire app cache folder.)

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

No branches or pull requests

2 participants