我正在尝试使用最新的IOS SDK 2处理PayPal付款 - 基本上我试图按照示例 -
https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/single_payment.md
没有太多运气。我在澳大利亚。
我使用paypal sdk在IOS应用中付款。然后,应用程序调用PHP Web服务器,该服务器将验证paypal付款,然后在PHP服务器后端更新订阅。
我做了什么以及我遇到了什么。
我已经设置了一个经典的API应用程序。
我使用 -
设置了制作和沙盒环境 [PayPalMobile initializeWithClientIdsForEnvironments:
@{PayPalEnvironmentProduction : @"HIDDEN",
PayPalEnvironmentSandbox : @"HIDDEN"}
];
将HIDDEN文本替换为真实文本。
我使用以下代码,成功启动了paypal对话框 -
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentSandbox];
PayPalPayment *payment = [[PayPalPayment alloc] init];
NSDecimalNumber *total_cost = NSDecimalNumber decimalNumberWithString:@"4.30"];
// Amount, currency, and description
payment.amount = total_cost;
payment.currencyCode = @"USD";
payment.shortDescription = @"test";
// Use the intent property to indicate that this is a "sale" payment,
// meaning combined Authorization + Capture. To perform Authorization only,
// and defer Capture to your server, use PayPalPaymentIntentAuthorize.
payment.intent = PayPalPaymentIntentSale;
// Check whether payment is processable.
if (!payment.processable) {
[self display_message: @"Payment could not be processed. This can happen for a variety of reasons, i.e. the payment amount was negative, etc. Please contact us if you believe you have received this message in error."];
return;
}
// Create a PayPalPaymentViewController.
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfiguration
delegate:self];
// Present the PayPalPaymentViewController.
[self presentViewController:paymentViewController animated:YES completion:nil];
出现paypal对话框,但随后显示"无法与服务器通信错误,请稍后重试"。
xcode控制台上出现以下内容 -
2014-03-25 10:42:22.432 PayPal SDK:请求失败,错误:
pp_service_error_json_parse_error - System error. Please try again later. (500) | PayPal Debug-ID: a26da2c300c31 | Details: (
{
"ns_error" = "Error Domain=NSCocoaErrorDomain Code=3840 \"The operation couldn\U2019t be completed. (Cocoa error 3840.)\" (No value.) UserInfo=0xbadecd0 {NSDebugDescription=No value.}";
}
).
所以问题(1)任何想法为什么会这样。
和问题(2)之后,我可以付款,然后我需要确认从PayPal返回的付款信息吗?即我 -
希望这是有道理的。
PS我发现文档令人难以置信的混淆。
编辑:好的,所以第二天没有任何改变,我尝试再次运行应用程序,这次不同的xcode控制台错误 - "无效的客户端凭据"。在https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/single_payment.md的这个示例中没有任何地方指定客户端凭据,除了这部分客户端ID -
[PayPalMobile initializeWithClientIdsForEnvironments:
@{PayPalEnvironmentProduction : @"HIDDEN",
PayPalEnvironmentSandbox : @"HIDDEN"}
];
我已正确设置。是否需要在启动paypal ios sdk ui之前设置其他凭据?