我在id上使用PayPal sdk有一些问题。我在https://developer.paypal.com/webapps/developer/applications/myapps上创建了我的应用程序,并获得了客户端id。我使用paypal示例应用程序的ID,它在模拟和沙箱模式下工作良好。每当我的应用程序在模拟数据模式下运行时,我都会从paypal服务器获得响应。
{
client = {
environment = mock;
"paypal_sdk_version" = "2.2.1";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
response = {
"create_time" = "2014-08-27T10:18:57Z";
id = "PAY-8UD377151U972354RKOQ3DTQ";
intent = sale;
state = approved;
};
"response_type" = payment;
}.i不是用来设置沙箱模式的,而是我需要使用的变量。
- (void)viewDidLoad
{
// Set up payPalConfig
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;
_payPalConfig.languageOrLocale = @"en";
_payPalConfig.merchantName = @"KicksCloset Shoes, Inc.";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
_payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
_payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
// use default environment, should be Production in real life
self.environment = @"sandbox";
NSLog(@"PayPal iOS SDK version: %@", [PayPalMobile libraryVersion]);
}这是我的薪酬诉讼
{
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:amountforserver];
payment.currencyCode = @"USD";
payment.shortDescription = creditsforserver;
// payment.items = items; // if not including multiple items, then leave payment.items as nil
// payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil
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.
}
// Update payPalConfig re accepting credit cards.
self.payPalConfig.acceptCreditCards = self.acceptCreditCards;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}发布于 2014-08-27 11:50:58
你的行动方法有问题。
只需通过环境{
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:amountforserver];
payment.currencyCode = @"USD";
payment.shortDescription = creditsforserver;
// payment.items = items; // if not including multiple items, then leave payment.items as nil
// payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil
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.
}
self.environment = kPayPalEnvironment;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];},只需使用以下代码
-(void)viewWillAppear:(BOOL)animated{
[PayPalMobile preconnectWithEnvironment:self.environment];
}发布于 2014-08-27 11:05:12
将paypal环境更改为PayPalEnvironmentSandbox
这是沙箱模式
self.environment = PayPalEnvironmentSandbox;如果你想用现场直播方式..。
self.environment = PayPalEnvironmentProduction;查看PayPalMobile.h文件
//此环境必须用于App提交。
extern NSString *const PayPalEnvironmentProduction;/ Sandbox:使用PayPal沙箱进行事务处理。对发展有用。
extern NSString *const PayPalEnvironmentSandbox;/ NoNetwork:模拟模式。不向PayPal提交事务。伪造成功的回应。对单元测试有用。
extern NSString *const PayPalEnvironmentNoNetwork;https://stackoverflow.com/questions/25525286
复制相似问题