- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 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)
请帮我解决这个问题。谢谢大家。
最佳答案
您的问题分为两部分。首先,您似乎已经在代码中达到了拥有 STPtoken 的地步,您只需要能够使用它进行收费即可。您的云代码似乎有错误。您需要确保您有一个名为“charge”的函数,否则它会返回错误。您可以执行类似以下操作(在 javascript 中)来创建客户并创建费用:
Parse.Cloud.define("charge", function(request, response) {
Stripe.Customers.create({
card: request.params.token,
description: request.params.description
},{
success: function(results) {
response.success(results);
},
error: function(httpResponse) {
response.error(httpResponse);
}
}).then(function(customer){
return Stripe.Charges.create({
amount: request.params.amount, // in cents
currency: request.params.currency,
customer: customer.id
},{
success: function(results) {
response.success(results);
},
error: function(httpResponse) {
response.error(httpResponse);
}
});
});
});
那么您问题的第二部分与使用 Apple Pay 有关。使用 Apple Pay,您可以创建一个 token ,而无需向用户询问他们的支付信息。为了实现 Apple Pay,您需要以下代码:
#import <PassKit/PassKit.h>
#import "Stripe.h" //Necessary as ApplePay category might be ignored if the preprocessor macro conditions are not met
#import "Stripe+ApplePay.h"
PKPaymentRequest *request = [Stripe
paymentRequestWithMerchantIdentifier:APPLE_MERCHANT_ID];
NSString *label = @"Text"; //This text will be displayed in the Apple Pay authentication view after the word "Pay"
NSDecimalNumber *amount = [NSDecimalNumber decimalNumberWithString:@"10.00"]; //Can change to any amount
request.paymentSummaryItems = @[
[PKPaymentSummaryItem summaryItemWithLabel:label
amount:amount]
];
if ([Stripe canSubmitPaymentRequest:request]) {
PKPaymentAuthorizationViewController *auth = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
auth.delegate = self;
[self presentViewController:auth animated:YES completion:nil];
}
此代码创建付款,测试付款是否可能被处理,如果是,则显示付款授权 View 。我将此代码放在 View Controller 中的 viewDidAppear
中,该 View Controller 包含收集用户付款信息的功能。如果支付能够被处理,那么支付授权 View Controller 将出现在当前 View Controller 之上,允许用户决定他们是想自己输入支付信息还是使用 apple pay。确保声明当前 View Controller 遵循 PKPaymentAuthorizationViewControllerDelegate。并在 viewDidLoad
中确保设置委托(delegate)。
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus))completion {
[self handlePaymentAuthorizationWithPayment:payment completion:completion];
}
如果用户决定使用他们的指纹并使用 Apple Pay,这将被调用
- (void)handlePaymentAuthorizationWithPayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus))completion {
[Stripe createTokenWithPayment:payment
completion:^(STPToken *token, NSError *error) {
if (error) {
completion(PKPaymentAuthorizationStatusFailure);
return;
}
//USE TOKEN HERE
}];
}
这将被调用以处理付款。它将创建您处理付款所需的 token 。您的其余代码可以与此 token 一起使用。
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller {
[self dismissViewControllerAnimated:YES completion:nil];
}
这将在处理完付款后调用。支付授权 View Controller 将被关闭。
关于ios - 如何使用 Stripe 的 Apple Pay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27640819/
我可以在不使用收款人信用卡号的情况下将资金从我的 Stripe 账户发送到另一个 Stripe 账户吗?在我的网站中,我希望管理员将资金从他的帐户转移到用户的条纹帐户(而不是用户的银行帐户)。用户的
我曾经有 Angular Stripe Checkout 表单,我正在尝试将表单更新为新的 Stripe Card Elements这是最近推出的。 删除表单输入字段并将其替换为条纹卡片元素后,我的表
我的目标是为产品创建一个简单的支付页面。 在官方文档中,它说在服务器端需要生成 token 才能创建交易,使用: stripe.paymentIntents.create({ amount: re
我是 strip 的新手,打算使用 strip token /收费 api,但 strip 文档说 paymentIntent api 是新的方法。我可以使用任何人吗或 PaymentIntent 是
我正在开发一个项目,我们正在为 Node 使用 Stripe 库。我们还想在这个项目上使用 TypeScript。 我发现 Stripe 没有提供官方 TypeScript 定义,但我找到了一些社区定
通常在使用 stripe 时我可以创建产品并添加税率、运费。付款后我可以创建发票。我想在使用连接帐户时做同样的事情。在我的应用程序中,我希望用户创建商店,并且该商店的产品将保存到他们连接的 Strip
假设我们已经设置了一个 Stripe 订阅计划。即 30 美元/月。 (注意:账单/账户信息存储在 Stripe 上。) 假设我们想为客户提供提前购买一年服务的选项,如果他们这样做,他们只需支付 25
我们知道 Stripe 支持多张信用卡。一个是 default_card。关于这张 Stripe 多张卡片,我需要知道一些答案。 假设我想向我的客户收费,他的 Stripe 个人资料中有 3 张信用卡
有没有办法根据为特定客户生成的最后一张发票过滤发票结果? 穿过 Stripe documentation我可以看到有可能获得即将到来的发票,但我找不到获得最后生成的发票的方法。 最佳答案 如果您使用
我正在使用 Stripe 为客户订阅月度计划。中途客户可能会减少计划数量。所以,在即将开出的发票有时会是负数。 带有负金额的发票行是否意味着客户将这些金额退还到他们的卡中? 谢谢 最佳答案 是的,负发
我正在使用定期计划和电子邮件地址在 Stripe(使用测试模式)中创建客户。到目前为止,一切都按我的预期工作:当客户创建并注册到定期计划时,他们会自动在计划的第一期收费。我所拥有的几乎是逐字逐句wha
我正在尝试使用 Stripe checkout.js 订阅,然后使用 PHP 订阅客户。我的问题是获取他们的电子邮件地址。在文档中找不到任何有用的东西。 文档在这里:https://stripe.co
我在两部分付款过程中使用 Stripe。 IE。 使用 capture = false 对调用 Charge 对象的卡进行预授权 做一些数据库工作 使用电荷捕获为卡充电 如果第 2 步失败(即数据库工
我们使用 Stripe 作为支付网关,我们有一个年度计划,即该计划的计费周期为 1 年。 在计费周期内,用户可以更新选择更多席位,这将导致增加订阅计划的数量。 Subscription subscri
我正在使用 PHP Stripe Payment 表单来收款。付款似乎通过 OK 并在成功完成后将用户带到确认页面。我处于测试模式,能够看到显示在仪表板“付款”部分的付款。但是,当我单击仪表板的“主页
我正在构建一个市场应用程序。我正在使用 Stripe 接受买家付款并将百分比转移给卖家。但是,stripe 只能让您从 Stripe 余额中转移。因此,如果我接受需要 2 个工作日才能显示在我的 st
正如我们所知,Stripe 每张信用卡收费 2.9% + 30 美分。因此,对于每 1 美元的交易,Stripe 大约需要 33 美分。有没有办法批量处理多个 1 美元的交易(由同一客户)并完全收费?
我有一个关于 Stripe 的订阅计划,并将其用于按座位定价。 具体用例是: 客户之前已付款,因此数据库中的客户 ID 和订阅 ID 他们在一个月内删除了所有用户 下个月他们又添加了一个用户 我希望结
在Stripe API文档中,它们显示您可以在客户上应用优惠券。 cust = Stripe::Customer.retrieve("cus_asdasdad") cust.coupon = "COU
我在订阅中添加发票项目时遇到问题,目前无法正常工作。 我已经在 strip 上创建了一个发票项目,并且希望该发票项目包含在定期付款中 这是我的代码,它在第一个发票上添加了一个发票项目,但在下一个发票上
我是一名优秀的程序员,十分优秀!