Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 贝宝sdk没有';无法进入沙盒模式,且应用程序id未更改_Ios_Paypal_Paypal Sandbox_Sandbox - Fatal编程技术网

Ios 贝宝sdk没有';无法进入沙盒模式,且应用程序id未更改

Ios 贝宝sdk没有';无法进入沙盒模式,且应用程序id未更改,ios,paypal,paypal-sandbox,sandbox,Ios,Paypal,Paypal Sandbox,Sandbox,我在iOS上使用PayPal sdk时遇到一些问题。我在上创建了我的应用程序,并获得了客户端id。我使用了带有我ID的paypal示例应用程序,它在模拟和沙箱模式下运行良好。每当我的应用程序以模拟数据模式移动时,我都会从paypal服务器得到响应。id始终为API-PAYMENT-id-1843 client = { environment = mock; "paypal_sdk_version" = "2.10.2"; platform = iOS; "

我在iOS上使用PayPal sdk时遇到一些问题。我在上创建了我的应用程序,并获得了客户端id。我使用了带有我ID的paypal示例应用程序,它在模拟和沙箱模式下运行良好。每当我的应用程序以模拟数据模式移动时,我都会从paypal服务器得到响应。id始终为API-PAYMENT-id-1843

client =     {
    environment = mock;
    "paypal_sdk_version" = "2.10.2";
    platform = iOS;
    "product_name" = "PayPal iOS SDK";
};
response =     {
    "create_time" = "2015-05-26T09:51:13Z";
    id = "API-PAYMENT-ID-1843";
    intent = sale;
    state = approved;
};
"response_type" = payment;
我的代码如下

PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [NSDecimalNumber decimalNumberWithString:numberStr];
payment.currencyCode = @"USD";
payment.shortDescription = [NSString stringWithFormat:@"Buy %@ Invites",[self.invitesDict objectForKey:@"invites_count"]];
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.
}
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;

PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                                            configuration:self.payPalConfig
                                                                                                 delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];

有什么解决办法吗?嗨,这里我附上了所有贝宝代码。请参阅此代码

重要

在你的应用程序委托中,你应该考虑环境

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


//
//    [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"Aat-VBAY9zLQVYJJpC-xxxxxx",
//                                                           PayPalEnvironmentSandbox : @"api.sandbox.paypal.com"}];


    [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"API KEY"}];
    return YES;
}
头文件

@property (nonatomic, strong, readwrite) PayPalConfiguration *payPalConfiguration;
实现文件

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        _payPalConfiguration = [[PayPalConfiguration alloc] init];

        // See PayPalConfiguration.h for details and default values.
        // Should you wish to change any of the values, you can do so here.
        // For example, if you wish to accept PayPal but not payment card payments, then add:
        _payPalConfiguration.acceptCreditCards = YES;
        // Or if you wish to have the user choose a Shipping Address from those already
        // associated with the user's PayPal account, then add:
        _payPalConfiguration.payPalShippingAddressOption = PayPalShippingAddressOptionNone;
    }
    return self;
}
//调用此方法以单击“付款”按钮事件


谢谢你的回复。我可以使用paypal帐户登录进行支付,但使用借记卡或信用卡时,我得到了正确的响应检查此方法-(instancetype)initWithCoder:(NSCoder*)aDecoder{你添加了这一行吗"payPalConfiguration.acceptCreditCards=YES;YES@puvan现在我收到以下错误PayPal SDK:请求失败,错误为:未知"错误-系统错误。请稍后重试。(400)| PayPal调试ID:d71a0b18d00b7[沙盒,PayPal iOS SDK 2.10.2]检查此链接
- (void)paypalPaymentSettilement:(NSString *)amount{

    float rate = [amount floatValue];
    float totalAmount = [self.lblTotal.text floatValue];

    float usdValue = rate * totalAmount;

    NSNumberFormatter *format = [[NSNumberFormatter alloc]init];
    [format setNumberStyle:NSNumberFormatterDecimalStyle];
    [format setRoundingMode:NSNumberFormatterRoundHalfUp];
    [format setMaximumFractionDigits:2];
    NSString *temp = [format stringFromNumber:[NSNumber numberWithFloat:usdValue]];

    PayPalPayment *payment = [[PayPalPayment alloc] init];

    payment.amount = [[NSDecimalNumber alloc] initWithString:temp];
    payment.currencyCode = @"USD";
    payment.shortDescription = @"payment";
    payment.intent = PayPalPaymentIntentSale;

    if (!payment.processable) {
        NSLog(@"Error");
    }

    PayPalPaymentViewController *paymentViewController;
    paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                   configuration:self.payPalConfiguration
                                                                        delegate:self];

    [self presentViewController:paymentViewController animated:YES completion:nil];

}