TMa*_*Man 3 cocoa-touch paypal paypal-sandbox
我已将新的PayPal iOS SDK集成到我的应用程序中.参考可以在这里找到.新的SDK非常容易设置,它允许您在3种不同的环境中工作1.)PayPalEnvrionmentNoNetwork 2.)PayPalEnvironmentSandBox和3)没有环境意味着进入他们的实时服务器.一切都适用于NoNetwork环境,显然是因为它使用模拟虚拟数据,而不必访问任何服务器.当我尝试切换到SandBox环境时,PayPal无法连接到服务器,我收到以下错误:
We're Sorry
There was a problem communicating with the PayPal servers. [Cancel][Try Again]
Run Code Online (Sandbox Code Playgroud)
我不确定这是我身边还是他们的问题.以下是配置:
#define kPayPalClientId @"AbRN_BAV7YMsvde9KUFPsbSC_72NA9swMcY-j0QZL629lXrjSc9CNwfFn8Ac"
#define kPayPalReceiverEmail @"The email I use to login into PayPal"
- (IBAction)pay {
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:@"14.99"];
payment.currencyCode = @"USD";
payment.shortDescription = @"Testing.";
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
}
// Any customer identifier that you have will work here. Do NOT use a device- or
// hardware-based identifier.
NSString *customerId = nil;
// Set the environment:
// - For live charges, use PayPalEnvironmentProduction (default).
// - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
// - For testing, use PayPalEnvironmentNoNetwork.
[PayPalPaymentViewController setEnvironment:self.environment];
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
receiverEmail:kPayPalReceiverEmail
payerId:customerId
payment:payment
delegate:self];
paymentViewController.hideCreditCardButton = NO;
[self presentViewController:paymentViewController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
FIX:最后我想出了问题,你需要在视图加载后添加它.我根本没有这个.
[PayPalPaymentViewController prepareForPaymentUsingClientId:kPayPalClientId];
Run Code Online (Sandbox Code Playgroud)