【发布时间】:2015-12-21 19:16:28
【问题描述】:
你好 stackoverflow 社区
我有来自 github 项目的以下代码: https://github.com/hybrdthry911/ELStripe 已在此处介绍: Store credit card using Stripe + Parse with cloud code
-(void)createCardFromToken:(NSString *)tokenId customerId:(NSString *)customerId completionHandler:(ELCardCompletionBlock)handler
{
[ELStripe executeStripeCloudCodeWithMethod:@"POST"
//I use post here because we are creating a card. POST would also be used for updating a customer/card or refunding a charge for example
prefix:@"customers" //If you look at the documentation and the example URL I use "customers" here as the prefix
suffix:customerId //The customerID is the suffix, this will be the customer you are going to add the card to
postfix:@"cards" //I believe this is "sources" now
secondPostfix:nil //Not needed for this URL
parameters:@{
@"card":tokenId //Only parameter is a tokenId, and I wrap this inside an NSDictionary
}
completionHandler:^(id jsonObject, NSError *error) {
if (error)
{
//Handle the error code here
handler(nil,error); //rejectError
return;
}
//If no error stripe returns a dictionary containing the card information. You can use this information to create a card object if so desired.
handler([ELCard cardFromDictionary:jsonObject],error);
}];
}
我现在的问题是我作为 Objective-C 中的 n00b,不知道如何使用这种方法:
[self createCardFromToken:<#(NSString *)#> customerId:<#(NSString *)#> completionHandler:<#^(ELCard *card, NSError *error)handler#>];
谁能指出我必须在之后输入的方向:completionHandler? 非常感谢!
【问题讨论】:
-
问题不清楚。请编辑问题。
-
既然这个问题已经有了答案,请考虑接受对你有帮助的那个。
标签: ios objective-c stripe-payments