Mangopay / cardregistration-android-kit

MIT License
5 stars 2 forks source link

Callback sends an error when register a card twice #19

Closed suiko1984 closed 8 years ago

suiko1984 commented 8 years ago

Hi,

I get an error after registering a card more than one time. MangoError{id='105203', message='Invalid card expiration date.', type='sdk-validation', date=1468596987098}

I think this is due to the instance of MangoPay that is not cleared after starting a first registration process.

To be able able to register another card, I need to kill the app and restart again.

Is there any way to clear the instance after the first registration?

With thanks.

gabriellupu commented 8 years ago

Thanks for reporting this @suiko1984 we are currently looking over your issue. Could you also provide the code sample from your implementation of card registration ? Thanks !

suiko1984 commented 8 years ago

Thank you for your quick answer @lupugabriel1. Here is my code:

MangoPay.with(this)
                            .baseURL(Constants.MANGOPAY_BASE_URL)
                            .clientId(Constants.MANGOPAY_CLIENT_ID)
                            .accessKey(cardRegistration.AccessKey)
                            .cardRegistrationURL(cardRegistration.CardRegistrationURL)
                            .preregistrationData(cardRegistration.PreregistrationData)
                            .cardPreregistrationId(cardRegistration.Id) 
                            .cardNumber(value.getNumero())
                            .cardExpirationMonth(Integer.parseInt(value.getMonth()))
                            .cardExpirationYear(Integer.parseInt(value.getYear()))
                            .logLevel(LogLevel.FULL)
                            .cardCvx(value.getCvx())
                            .callback(new com.mangopay.android.sdk.Callback() {
                                @Override
                                public void success(CardRegistration jsonResponse) {
                                    // First registration succeeds.
                                }

                                @Override
                                public void failure(MangoError error) {
                                    // Second registration within the same activity fails here.
                                }
                            })
                            .start();   
octa-george commented 8 years ago

Hello @suiko1984.

Thank you again for reporting this issue. A new version will be deployed soon with the fix.

Best regards.