Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #JS FILE
  2. import {
  3. NativeModules
  4. } from 'react-native';
  5.  
  6. const PLStripe = NativeModules.PLStripe;
  7.  
  8. PLStripe.addCard('4242424242424242', 9, 20, '422');
  9.  
  10.  
  11. #OBJECTIVE C FILE
  12.  
  13. #import "PLStripe.h"
  14. #import <React/RCTLog.h>
  15. #import <Stripe/Stripe.h>
  16.  
  17. @implementation PLStripe
  18.  
  19. RCT_EXPORT_MODULE();
  20.  
  21. RCT_EXPORT_METHOD(addCard:(NSString *)cardNumber cardExpirationMonth:(NSString *)cardExpirationMonth cardExpirationYear:(NSString *)cardExpirationYear cardCVC:(NSString *)cardCVC)
  22. {
  23. RCTLogInfo(@"Cheking for card number %@ expiration MONTH : %@ expiration YEAR : %@ cvs : %@", cardNumber, cardExpirationMonth, cardExpirationYear, cardCVC);
  24.  
  25. STPCardParams *cardParams = [STPCardParams new];
  26. cardParams.number = cardNumber;
  27. cardParams.expMonth = cardExpirationMonth;
  28. cardParams.expYear = cardExpirationYear;
  29. cardParams.cvc = cardCVC;
  30.  
  31. [[STPAPIClient sharedClient] createTokenWithCard:cardParams completion:^(STPToken * _Nullable token, NSError * _Nullable error) {
  32. if (token == nil) {
  33. // Handle the error
  34. RCTLogInfo(@"Token error %@", error);
  35. return;
  36. }
  37. // Use the token in the next step
  38. }];
  39. }
  40.  
  41. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement