2014-12-02 6 views
6

Я следил за документацией Stripe и примером приложения для интеграции Apple Pay.Проблема с интеграцией Apple Pay/Stripe

В методе handlePaymentAuthorizationWithPayment под createTokenWithPayment, я получаю сообщение об ошибке:

Error Domain=com.stripe.lib Code=50 "Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios ." UserInfo=0x170261b40 {com.stripe.lib:ErrorMessageKey=Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios ., NSLocalizedDescription=Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios .}

Любой знает, как решить эту проблему? Я использую последнюю библиотеку Stripe.

Спасибо.

ответ

3

Я думаю, что знаю, что здесь произошло. Оставляя это на случай, если это поможет кому угодно.

Когда я изначально настроил Stripe/Apple Pay в свое приложение, я продолжал получать многочисленные ошибки, когда пытался реализовать STPTestPaymentAuthorizationController. Я нашел конкретную проблему, описанную здесь (Stripe payment library and undefined symbols for x86_64).

Я воспроизвел решение, определенное выше, прокомментировав часть кода Stripe, которая, возможно, (?) Вызвала ошибку Error Domain=com.stripe.lib Code=50.

Я исправил это, не используя STPTestPaymentAuthorizationController, просто заменив его на PKPaymentAuthorizationViewController в #DEBUG режиме.

tl: dr Не совсем уверен, почему STPTestPaymentAuthorization не работает; полностью избежать ситуации, запустив PKPaymentAuthorizationViewController с моей панелью iPhone и Stripe в тестовом режиме.

+0

Привет, май, если я заплачу с помощью Apple Pay с помощью своего сенсорного ID с полосой в тестовом режиме, не собирается ли взимать плату с моей карты? –

+3

@SaiJithendra Правильно, он не будет взимать плату с вашей карты, даже если транзакция будет успешной на вашем телефоне. –

+0

Спасибо за ваш ответ :) –

5

Этот немного RnD помог мне. Копание в CustomSampleProject предоставленной самими Stripe, ApplePayStubs работает довольно хорошо, когда STPCard признается, когда делегат

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller 
        didAuthorizePayment:(PKPayment *)payment 
          completion:(void (^)(PKPaymentAuthorizationStatus))completion 

из PKPaymentAuthorizationViewControllerDelegate называется. Пример кода здесь проверяется, если код был запущен в отладке, который для ApplePayStubs, то (PKPayment *) оплата в делегат преобразуется в STPCard и запущен в STPAPIClient для STPToken поколения. Ниже представлен орган вышеупомянутого делегата:

#if DEBUG // This is to handle a test result from ApplePayStubs 
if (payment.stp_testCardNumber) 
{ 
    STPCard *card = [STPCard new]; 
    card.number = payment.stp_testCardNumber; 
    card.expMonth = 12; 
    card.expYear = 2020; 
    card.cvc = @"123"; 
    [[STPAPIClient sharedClient] createTokenWithCard:card 
              completion:^(STPToken *token, NSError *error) 
    { 
     if (error) 
     { 
      completion(PKPaymentAuthorizationStatusFailure); 
      [[[UIAlertView alloc] initWithTitle:@"Error" 
             message:@"Payment Unsuccessful! \n Please Try Again" 
             delegate:self 
           cancelButtonTitle:@"OK" 
           otherButtonTitles:nil] show]; 
      return; 
     } 
    /* 
    Handle Token here 
    */ 
              }]; 
} 
#else 
[[STPAPIClient sharedClient] createTokenWithPayment:payment 
             completion:^(STPToken *token, NSError *error) 
{ 
    if (error) 
    { 
     completion(PKPaymentAuthorizationStatusFailure); 
     [[[UIAlertView alloc] initWithTitle:@"Error" 
            message:@"Payment Unsuccessful!" 
            delegate:self 
          cancelButtonTitle:@"OK" 
          otherButtonTitles:nil] show]; 
     return; 
    } 
    /* 
    Handle Token here 
    */ 
}]; 
#endif 

Это сработало для меня. С ApplePayStubs (на Simulator) и без них (на устройстве) Надеюсь, что это поможет :)

Смежные вопросы