Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (![self.paymentView isValid]){
- return;
- if (![Stripe defaultPublishableKey]) {
- UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"No Publishable Key"
- message:@"Please specify a Stripe Publishable Key in Constants.m"
- delegate:nil
- cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
- otherButtonTitles:nil];
- [message show];
- return;
- }
- PTKCard* card = self.paymentView.card;
- NSLog(@"Card last4: %@", card.last4);
- NSLog(@"Card expiry: %lu/%lu", (unsigned long)card.expMonth, (unsigned long)card.expYear);
- NSLog(@"Card cvc: %@", card.cvc);
- [[NSUserDefaults standardUserDefaults] setValue:card.last4 forKey:@"card.last4"];
- [self.navigationController popViewControllerAnimated:YES];
- message:[error localizedDescription]
- delegate:nil
- cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
- otherButtonTitles:nil];
- [PFCloud callFunctionInBackground:@"stripeUpdateCustomer" withParameters:@{@"customerId":customerId,@"data":@{@"card":tokenId}}
- handler([[STPCard alloc]initWithAttributeDictionary:object],error);
- }];
- [PFCloud callFunctionInBackground:@"createCustomer"
- withParameters:@{
- @"tokenId":tokenId,
- }
- block:^(id object, NSError *error) {
- //Object is an NSDictionary that contains the stripe customer information, you can use this as is, or
- handler(object,error);
- }];
- success: function(httpResponse) {
- response.success(httpResponse.text);
- },
- error: function(httpResponse) {
- response.error('Request failed with response code ' + httpResponse.status);
- }
- }); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement