Created
November 29, 2018 21:41
-
-
Save melwaraki/0d2dc481e5ca0a58388ced204c5ca557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//class that generates the ephermal key | |
class StripeCustomerSessionManager: NSObject, STPEphemeralKeyProvider { | |
func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) { | |
let parameters = [ | |
"api_version": apiVersion | |
] | |
//this runs async, could this be causing an issue? i think the app crashes before it runs though | |
//i commented out the next part and the app still crashed | |
Alamofire.request(Constants.apiBaseUrl() + "user/stripe/key", method: .post, parameters: parameters, encoding: URLEncoding.default, headers: APIManager.generateHeaders()) | |
.validate(statusCode: 200..<300) | |
.responseJSON { responseJSON in | |
print(responseJSON.response) | |
print(responseJSON.result) | |
switch responseJSON.result { | |
case .success(let json): | |
completion(json as? [String: AnyObject], nil) | |
case .failure(let error): | |
completion(nil, error) | |
} | |
} | |
} | |
} | |
//issuing stripe key on the backend - python | |
def issue_stripe_key(request): | |
# api_version = request.POST['api_version'] | |
customerId = request.user.stripe_customer_id | |
key = stripe.EphemeralKey.create(customer=customerId, api_version="2018-11-08") | |
return JsonResponse(data=key) | |
//stack trace on Firebase Crashlytics - lines 2 and 29 are highlighted | |
Fatal Exception: NSInvalidArgumentException | |
0 CoreFoundation 0x1969e3ea0 __exceptionPreprocess | |
1 libobjc.A.dylib 0x195bb5a40 objc_exception_throw | |
2 CoreFoundation 0x1968fcd04 -[NSOrderedSet initWithSet:copyItems:] | |
3 UIKitCore 0x1c3bdeb38 -[UIResponder doesNotRecognizeSelector:] | |
4 Stripe 0x106ae1904 (Missing) | |
5 CoreFoundation 0x1969e94b4 ___forwarding___ | |
6 CoreFoundation 0x1969eb45c _CF_forwarding_prep_0 | |
7 UIKitCore 0x1c35ef9cc -[UIViewController _setViewAppearState:isAnimating:] | |
8 UIKitCore 0x1c354cf14 -[UINavigationController viewDidAppear:] | |
9 UIKitCore 0x1c35ef9cc -[UIViewController _setViewAppearState:isAnimating:] | |
10 UIKitCore 0x1c35f034c -[UIViewController _endAppearanceTransition:] | |
11 UIKitCore 0x1c3511f60 -[UIPresentationController transitionDidFinish:] | |
12 UIKitCore 0x1c351b220 -[_UICurrentContextPresentationController transitionDidFinish:] | |
13 UIKitCore 0x1c3516154 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.440 | |
14 UIKitCore 0x1c3614090 -[_UIViewControllerTransitionContext completeTransition:] | |
15 UIKitCore 0x1c4015f4c -[UITransitionView notifyDidCompleteTransition:] | |
16 UIKitCore 0x1c4015be4 -[UITransitionView _didCompleteTransition:] | |
17 UIKitCore 0x1c4017cf4 -[UITransitionView _transitionDidStop:finished:] | |
18 UIKitCore 0x1c4020154 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] | |
19 UIKitCore 0x1c4020740 -[UIViewAnimationState animationDidStop:finished:] | |
20 UIKitCore 0x1c40207e0 -[UIViewAnimationState animationDidStop:finished:] | |
21 QuartzCore 0x19afe85d0 CA::Layer::run_animation_callbacks(void*) | |
22 libdispatch.dylib 0x19641e484 _dispatch_client_callout | |
23 libdispatch.dylib 0x1963ca9b4 _dispatch_main_queue_callback_4CF$VARIANT$mp | |
24 CoreFoundation 0x196973dd0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ | |
25 CoreFoundation 0x19696ec98 __CFRunLoopRun | |
26 CoreFoundation 0x19696e1cc CFRunLoopRunSpecific | |
27 GraphicsServices 0x198be5584 GSEventRunModal | |
28 UIKitCore 0x1c3bb1054 UIApplicationMain | |
29 Visavis 0x104b09bd8 main (AppDelegate.swift:25) | |
30 libdyld.dylib 0x19642ebb4 start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment