2014-12-02 9 views
6

Ho seguito la documentazione di Stripe e l'app di esempio sull'integrazione di Apple Pay.Problema con l'integrazione Apple Pay/Stripe

Nel metodo handlePaymentAuthorizationWithPayment, sotto createTokenWithPayment, sto ottenendo l'errore:

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 .}

Qualcuno sa come risolvere questo? Sto usando l'ultima libreria Stripe.

Grazie.

risposta

3

Penso di sapere cosa è successo qui. Lasciando da parte nel caso in cui aiuti qualcuno.

Quando ho impostato inizialmente Stripe/Apple Pay nella mia app, ho continuato a ricevere numerosi errori quando ho tentato di implementare STPTestPaymentAuthorizationController. Ho trovato il problema esatto descritto qui (Stripe payment library and undefined symbols for x86_64).

Ho replicato la soluzione sopra definita commentando parte del codice di Stripe, che forse (?) Ha prodotto l'errore Error Domain=com.stripe.lib Code=50.

Ho risolto questo problema evitando di utilizzare STPTestPaymentAuthorizationController, sostituendolo con nella modalità #DEBUG.

tl: dr Non completamente sicuro del motivo per cui STPTestPaymentAuthorization non ha funzionato; evitato completamente la situazione eseguendo PKPaymentAuthorizationViewController con il mio dashboard iPhone e Stripe in modalità test.

+0

Hi May, se pago con Apple Pay con il mio Touch ID con Stripe in modalità Test, non ha intenzione di ricaricare la mia carta? –

+3

@SaiJithendra Corretto, non addebiterà la tua carta, anche se la transazione apparirà sul tuo telefono. –

+0

Grazie per la risposta :) –

5

Questo piccolo pezzo di RnD mi ha aiutato. Scavando nella CustomSampleProject fornito da banda stessi, ApplePayStubs funziona abbastanza bene quando il STPCard è riconosciuto quando il delegato

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

di PKPaymentAuthorizationViewControllerDelegate si chiama. Il codice di esempio qui controllato se il codice è stato eseguito in di debug che è per ApplePayStubs, il (PKPayment *) il pagamento nel delegato viene convertito in un STPCard e viene lanciato al STPAPIClient per STPToken generazione. Di seguito è il corpo del delegato di cui sopra:

#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 

Questo ha funzionato per me. Con ApplePayStubs (su Simulator) e senza di loro (su Dispositivo) Spero che questo sia d'aiuto :)