Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. if (![self.paymentView isValid]){
  2.  
  3. return;
  4.  
  5. if (![Stripe defaultPublishableKey]) {
  6.  
  7. UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"No Publishable Key"
  8.  
  9. message:@"Please specify a Stripe Publishable Key in Constants.m"
  10.  
  11. delegate:nil
  12.  
  13. cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
  14.  
  15. otherButtonTitles:nil];
  16.  
  17. [message show];
  18.  
  19. return;
  20.  
  21. }
  22.  
  23. PTKCard* card = self.paymentView.card;
  24.  
  25.  
  26.  
  27. NSLog(@"Card last4: %@", card.last4);
  28.  
  29. NSLog(@"Card expiry: %lu/%lu", (unsigned long)card.expMonth, (unsigned long)card.expYear);
  30.  
  31. NSLog(@"Card cvc: %@", card.cvc);
  32.  
  33.  
  34.  
  35. [[NSUserDefaults standardUserDefaults] setValue:card.last4 forKey:@"card.last4"];
  36.  
  37. [self.navigationController popViewControllerAnimated:YES];
  38.  
  39. message:[error localizedDescription]
  40.  
  41. delegate:nil
  42.  
  43. cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
  44.  
  45. otherButtonTitles:nil];
  46.  
  47. [PFCloud callFunctionInBackground:@"stripeUpdateCustomer" withParameters:@{@"customerId":customerId,@"data":@{@"card":tokenId}}
  48.  
  49. handler([[STPCard alloc]initWithAttributeDictionary:object],error);
  50.  
  51. }];
  52.  
  53. [PFCloud callFunctionInBackground:@"createCustomer"
  54.  
  55. withParameters:@{
  56.  
  57. @"tokenId":tokenId,
  58.  
  59. }
  60.  
  61. block:^(id object, NSError *error) {
  62.  
  63. //Object is an NSDictionary that contains the stripe customer information, you can use this as is, or
  64.  
  65. handler(object,error);
  66.  
  67. }];
  68.  
  69. success: function(httpResponse) {
  70. response.success(httpResponse.text);
  71. },
  72. error: function(httpResponse) {
  73. response.error('Request failed with response code ' + httpResponse.status);
  74. }
  75. }); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement