我正在将 Paypal ios SDK 2.1 版集成到我的应用程序中,但遇到了问题。SDK似乎将过去的支付卡保存在内存中,即使我[PayPalMobile clearAllUserData]
在支付完成后打电话。
@interface AirliftCartViewController : AirliftViewController <AVCaptureMetadataOutputObjectsDelegate, UITableViewDelegate, AirliftCartTotalsChangeDelegate, PayPalPaymentDelegate>
@property (strong) AVCaptureSession * captureSession;
@property (strong, nonatomic) UIView *cameraPreview;
@property (nonatomic, strong, readwrite) PayPalConfiguration *payPalConfiguration;
- (IBAction)initiateCreditCardCheckout:(id)sender;
@end
...
@implementation AirliftCartViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil timeout:(NSUInteger)timeoutInSeconds screenName:(NSString *)screenName
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil timeout:timeoutInSeconds screenName:@"AirliftCartView"];
if (self) {
// Custom initialization
self.payPalConfiguration = [[PayPalConfiguration alloc] init];
self.payPalConfiguration.rememberUser = NO;
}
return self;
}
- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController
{
NSLog(@"payment cancelled!");
// The payment was canceled; dismiss the PayPalPaymentViewController.
[paymentViewController dismissViewControllerAnimated:YES completion:^{
// clear all paypal user information
[PayPalMobile clearAllUserData];
}];
}
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment
{
NSLog(@"Payment was successful");
// Payment was processed successfully; send to server for verification and fulfillment.
[self verifyCompletedPayment:completedPayment];
// Dismiss the PayPalPaymentViewController.
[paymentViewController dismissViewControllerAnimated:YES completion:^{
// clear all paypal user information
[PayPalMobile clearAllUserData];
// emptycart
[self.cartController emptyCart];
// reset metadata
[self.metaDataFound removeAllObjects];
}
- (IBAction)initiateCheckout:(id)sender {
NSLog(@"checkout requested!");
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentSandbox];
// present paypal payment
PayPalPaymentViewController * payPalVC = [[PayPalPaymentViewController alloc]
initWithPayment:[self.cartController getPayPalPaymentFromCart]
configuration:self.payPalConfiguration delegate:self];
[self presentViewController:payPalVC animated:YES completion:^{
[self.captureSession stopRunning];
[self.cameraPreview removeFromSuperview];
}];
}
@end
我像这样展示 PayPalPaymentViewController (所以我可以告诉它没有强烈的参考)
为我的应用程序保留任何卡信息是不可接受的,有人有什么想法吗?
编辑:根据要求添加用户步骤:
- 用户选择要购买的产品,然后单击以initialCheckout 作为其操作的结帐按钮。
- 这会打开 paypalpaymentviewcpntroller,它显示以前使用的卡作为唯一的支付选项(我第一次启动控制器时提供了登录贝宝或使用卡的选择)
编辑 2:为和扩展定义添加captureSession
了cameraPreview
属性init
声明
编辑 3:添加截图