Skip to content

Error callback always called when removing payment #27

@bogdanmarin

Description

@bogdanmarin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions