Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error callback always called when removing payment #27

Open
bogdanmarin opened this issue Feb 27, 2016 · 0 comments
Open

Error callback always called when removing payment #27

bogdanmarin opened this issue Feb 27, 2016 · 0 comments

Comments

@bogdanmarin
Copy link

I have a weird issue. I'm calling payments.remove to delete a payment. The payment id is correct, the payment is removed (checking with the Merchant Centre website) as it should but the promise is rejected. Error callback is called with the error:

PMError: API Error:{
    "data":null,
    "mode":"test"
   }

I'm using "paymill-wrapper": "^2.2.0"
This is my code:

function createOrUpdatePaymentForClient(clientId, token, paymentId) {
    var deferred = when.defer();
    var promise = deferred.promise;

    var removeResult = pm.payments.remove(paymentId).then(function (payment) {
        ///this is never called, WHY ?
        console.log('Payment with id removed {' + payment.id + '} for client {' + clientId + '}');

        pm.payments.create(token, clientId).then(function (payment) {
            deferred.resolve(payment);
        }, function (error) {
            deferred.reject(error);
        });

    }, function (err) {
       //this is always called and payment got deleted, BUG ? 
        console.log(arguments);
        console.log('........\n')
        console.log('Could not delete payment :');
        console.log(err);

        pm.payments.create(token, clientId).then(function (payment) {
            deferred.resolve(payment);
        }, function (error) {
            deferred.reject(error);
        });
    });

    console.log('Remove result: ');
    console.log(removeResult);

    return promise;
}
@bogdanmarin bogdanmarin changed the title Cannot remove payment successfully Error callback always called when removing payment Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant