条纹iOS添加卡/设置默认问题

时间:2016-09-12 08:46:02

标签: ios objective-c stripe-connect stripe.net

我已将Stripe集成添加到我们的应用中,并且当用户首次添加卡时我遇到了问题。该卡已成功添加,但是当我尝试更新默认来源时,我收到错误No such source: card-xxxxxxxxxxxx,但如果我返回到视图,则添加卡片"并重新选择已添加的同一张卡,defaultSource更新有效,我可以付款。

我的attachSourceToCustomer如下:

  -(void)attachSourceToCustomer:(id<STPSource>)source completion:(STPErrorBlock)completion {
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    [manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
    [[SBCommon sharedInstance].currentAccount addAuthorization:manager.requestSerializer];

    NSString * sourceId = source.stripeID;
    NSDictionary * params =@{@"stripeSource": sourceId};

    [manager POST:[NSString stringWithFormat:kSBBaseAPIURL,@"StripeCustomerSource"] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"%@ success: %@",NSStringFromClass([self class]),operation.responseObject);
        completion(nil);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                  NSLog(@"%@ failed: %@",NSStringFromClass([self class]),operation.responseObject);
    completion(error);
    }];
}

和我的selectDefaultCustomer如下

-(void)selectDefaultCustomerSource:(id<STPSource>)source completion:(STPErrorBlock)completion {
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
    [[SBCommon sharedInstance].currentAccount addAuthorization:manager.requestSerializer];

    NSString * sourceId = source.stripeID;
    NSDictionary * params =@{@"stripeSource": sourceId};

    [manager POST:[NSString stringWithFormat:kSBBaseAPIURL,@"StripeCustomerDefaultSource"] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"%@ success: %@",NSStringFromClass([self class]),operation.responseObject);
        completion(nil);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@ failed: %@",NSStringFromClass([self class]),operation.responseObject);
        completion(error);
    }];
}

当用户添加卡片时,我必须遗漏一些我需要做的事情,但我无法从文档中看到任何我错过的内容

更新 如果您使用Connect,SDK似乎不起作用,返回到selectDefaultCustomer的card_id实际上与Connect Connect帐户所拥有的Customer上创建的card_id不匹配。 paymentContext无法更新,因此当使用不正确的card_id进行paymentRequest时它将失败

0 个答案:

没有答案