【发布时间】:2014-12-24 18:17:16
【问题描述】:
我尝试通过 Stripe 使用 Apple Pay,但它有一些问题。 这是我的代码:
- (void)hasToken:(STPToken *)token {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSDictionary *chargeParams = @{
@"token": token.tokenId,
@"currency": @"usd",
@"amount": @"1000", // this is in cents (i.e. $10)
};
NSLog(@"Token ID: %@", token.tokenId);
if (!ParseApplicationId || !ParseClientKey) {
UIAlertView *message =
[[UIAlertView alloc] initWithTitle:@"Todo: Submit this token to your backend"
message:[NSString stringWithFormat:@"Good news! Stripe turned your credit card into a token: %@ \nYou can follow the "
@"instructions in the README to set up Parse as an example backend, or use this "
@"token to manually create charges at dashboard.stripe.com .",
token.tokenId]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
otherButtonTitles:nil];
[message show];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
return;
}
// This passes the token off to our payment backend, which will then actually complete charging the card using your account's
[PFCloud callFunctionInBackground:@"charge"
withParameters:chargeParams
block:^(id object, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (error) {
[self hasError:error];
return;
}
[self.presentingViewController dismissViewControllerAnimated:YES
completion:^{
[[[UIAlertView alloc] initWithTitle:@"Payment Succeeded"
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil] show];
}];
}];
}
输入卡号后,点击“支付”按钮,跳转到功能:
// This passes the token off to our payment backend, which will then actually complete charging the card using your account's
[PFCloud callFunctionInBackground:@"charge"
withParameters:chargeParams
block:^(id object, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (error) {
[self hasError:error];
return;
}
[self.presentingViewController dismissViewControllerAnimated:YES
completion:^{
[[[UIAlertView alloc] initWithTitle:@"Payment Succeeded"
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil] show];
}];
}];
但它是跳转到功能:
- (void)hasError:(NSError *)error {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error")
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
otherButtonTitles:nil];
[message show];
}
并显示错误信息: 错误:找不到函数(代码:141,版本:1.2.20)
请帮我解决这个问题。 谢谢大家。
【问题讨论】:
标签: ios payment stripe-payments