Coder Social home page Coder Social logo

paymill-js's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paymill-js's Issues

Error objects

Hey,

what's up with the error objects returned in the promise?
They are not really helpful in my case because 'message' as well as 'detailMessage' do not contain well-formed json.

{
"message": "API Error:{\n\t"exception":"subscription_already_connected",\n\t"error":"Subscription already connected"\n}",
"detailMessage": "http status code:400\nheaders:[object Object]\ndata:{\n\t"exception":"subscription_already_connected",\n\t"error":"Subscription already connected"\n}",
"type": "API Error"
}

Is this on purpose? Is there another way to identify which error I am dealing with?

Error callback always called when removing payment

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

Node - PayPal checksum creation function doesn't work

Hey guys,

I fixed a bug where you couldn't create a checksum using the paymill wrapper for nodejs.

In the "ChecksumService.prototype.create" function.

I'm wondering whether this thing had ever worked? Can't imagine that I'm the first ever noticing it?!
Anyway I'll provide a pull request so I don't need to monkey patch your wrapper.

Best,
Flo

SubscriptionService.prototype.unpause actually pauses a subscription

I'm currently trying to implement behavior that pauses/unpauses a subscription based on what internal plan the user chose. This is my code:

const pm = paymill.getContext(paymillPrivateKey);
if (plan.paymillOfferId) {
  // update old subscription
   const updatedSubscription = 
     await pm.subscriptions.changeOfferChangeCaptureDateAndRefund(
     subscriptionId,
     plan.paymillOfferId,
   );
   if (updatedSubscription.status === 'inactive') {
     await pm.subscriptions.unpause(updatedSubscription.id);
   }
} else {
  // Allow for free plans to be purchased
  await pm.subscriptions.pause(subscriptionId);
}

While that code can pause the subscription just fine, calling pm.subscriptions.unpause() never managed to set the status to 'active' again. I dug through the source code and found this piece here at line 3950:

SubscriptionService.prototype.unpause = function(obj, cb) {
    var map = { "pause" : true };
    return this._updateWithMap(obj, map, cb);
};

I guess it really should be

SubscriptionService.prototype.unpause = function(obj, cb) {
    var map = { "pause" : false };
    return this._updateWithMap(obj, map, cb);
};

What do you think?

Can't render multiple PayButtons

Hello
I can't create multiple payButtons via an Angular directive because all buttons will be append to the latest form and I can just buy the latest product. Do you know anything about it?

Directive template:

<form method="post" ng-submit="submit($event)">
    <script
        src="https://button.paymill.com/v1/"
        id="button-{{product.id}}"
        data-title="{{ product.title }}"
        data-description="{{ product.description }}"
        data-amount="{{ product.amount }}"

        data-elv="{{ config.elv }}"
        data-label="{{ config.label }}"
        data-submit-button="{{ config.submitBtnText }}"
        data-inline="{{ config.submitBtnInline }}"

        data-public-key="{{ paymill.publicKey }}"
        data-lang="{{ paymill.language }}"
        data-logo="{{ paymill.logoUrl }}"
        data-currency="{{ paymill.currency }}"
        >
    </script>
</form>

Node - No callback call on create transaction with payment and preauth

You have an error line 4367 and 4392:
return this._createTransaction(map, amount, currency, description, client, fee_amount, fee_payment, cb);
Should be:
return this._createTransaction(map, amount, currency, description, client, fee_amount, fee_payment, fee_currency, cb);
Otherwise callback isn't called!

Cant get checksume working Invalid arguments:currency is mandatory' in Testmode

First i try:

  const data = {
      amount: 100,
      currency: 'usd',
      checksum_type: 'paypal',
      description: 'Test Transaction',
      first_name: 'Paymill',
      last_name: 'Test',
      street_address: 'Test street 123',
      postal_code: 12345,
      country: 'DE', //
      city: 'Munich',
      email: '[email protected]',
      return_url: 'https://www.example.com/store/checkout/result',
      cancel_url: 'https://www.example.com/store/checkout/retry'
    }
    try {
      const result = await pm.checksums.forPaypal(data)
      response.send(result)
    } catch (error) {
      console.log(error) //  Invalid arguments:currency is mandatory' 
    }

Second try

  var pass = ''
    var header = paymillKey + ':' + (pass || '')

    try {
      const result = await axios.post(
        'https://api.paymill.com/v2.1/checksums',
        data,
        {
          headers: {
            Authorization: `Basic ${toBase64(header)}`
          }
        }
      )
      response.send(result)
    } catch (error) {
      console.log(error.response)  //Invalid arguments:checksum_type is mandatory'
      response.send('wtf')
    }
    function toBase64 (str) {
      return Buffer.from(str || '', 'utf8').toString('base64')
    } 

i have no plan what goes up

Add new parameter mandate_reference

A new optional parameter is available for both Transaction and Subscriptions
"mandate_reference" - non empty string.

For transactions:

Update the Transaction model ( add mandateReference String)
Update the create method(s) (as optional parameter)

For Subscriptions

Update the Subscription model ( add mandateReference String)
Update the create method(s) (as optional parameter)
Update the update method (make Subscrition.mandateReference @Updateable )

Template: paymill/paymill-php@51800d6

fee_currency missing

in transactions it is now possible to define a fee_currency if you do Unite transactions. This parameter has to be added

subscription.period_of_validity cannot be updated.

Hey,

I am trying to update a sub's period_of_validity

        paymillSdk.subscriptions.detail(subId)
    .then(function(sub) {
        //sub['period_of_validity'] = days + ' DAY'
        sub['period_of_validity'] = '2 MONTH'
        sub.name = 'i changed this one'

        log(colors.FgCyan, sub)

        return paymillSdk.subscriptions.update(sub)
    })
    .then(function(sub) {
        done(null, 'paymill', sub)
    },
    function(err) {
        done(err)
    });

This is the input json:

{ id: 'sub_bf336fe5883b5df76795',
  offer: 
   { id: 'offer_277bcb600c0a3ce7d974',
     name: 'Das Monatspaket',
     amount: 3000,
     currency: 'EUR',
     interval: 
      { length: 1,
        unit: 'MONTH',
        chargeday: undefined,
        originalJson: '1 MONTH' },
     trial_period_days: 0,
     created_at: Tue Oct 28 2014 18:17:34 GMT+0100 (CET),
     updated_at: Mon Nov 17 2014 12:20:20 GMT+0100 (CET),
     subscription_count: { active: '131', inactive: '8', originalJson: [Object] },
     app_id: null,
     originalJson: 
      { id: 'offer_277bcb600c0a3ce7d974',
        name: 'Das Monatspaket',
        amount: 3000,
        currency: 'EUR',
        interval: '1 MONTH',
        trial_period_days: 0,
        created_at: 1414516654,
        updated_at: 1416223220,
        subscription_count: [Object],
        app_id: null } },
  livemode: false,
  amount: 3000,
  temp_amount: null,
  currency: 'EUR',
  name: 'i changed this one',
  interval: 
   { length: 1,
     unit: 'MONTH',
     chargeday: undefined,
     originalJson: '1 MONTH' },
  trial_start: null,
  trial_end: null,
  period_of_validity: '2 MONTH',
  end_of_period: null,
  next_capture_at: Sat Dec 27 2014 11:20:00 GMT+0100 (CET),
  created_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
  updated_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
  canceled_at: null,
  payment: 
   { id: 'pay_f63fddd433460a370ee7414c',
     type: 'debit',
     client: 'client_c491d47a4b28fb38960a',
     holder: 'Chris Hansen',
     account: '*****9890',
     updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     app_id: null,
     originalJson: 
      { id: 'pay_f63fddd433460a370ee7414c',
        type: 'debit',
        client: 'client_c491d47a4b28fb38960a',
        code: '50010517',
        holder: 'Chris Hansen',
        account: '*****9890',
        iban: null,
        bic: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        app_id: null,
        is_recurring: true,
        is_usable_for_preauthorization: true } },
  app_id: null,
  is_canceled: false,
  is_deleted: false,
  status: 'active',
  client: 
   { id: 'client_c491d47a4b28fb38960a',
     email: '[email protected]',
     description: 'subscription customer',
     app_id: null,
     updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     payment: [ [Object] ],
     subscription: [ [Object] ],
     originalJson: 
      { id: 'client_c491d47a4b28fb38960a',
        email: '[email protected]',
        description: 'subscription customer',
        app_id: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        payment: [Object],
        subscription: [Object] } },
  originalJson: 
   { id: 'sub_bf336fe5883b5df76795',
     offer: 
      { id: 'offer_277bcb600c0a3ce7d974',
        name: 'Das Monatspaket',
        amount: 3000,
        currency: 'EUR',
        interval: '1 MONTH',
        trial_period_days: 0,
        created_at: 1414516654,
        updated_at: 1416223220,
        subscription_count: [Object],
        app_id: null },
     livemode: false,
     amount: 3000,
     temp_amount: null,
     currency: 'EUR',
     name: 'Box of Germany - Das Monatspaket',
     interval: '1 MONTH',
     trial_start: null,
     trial_end: null,
     period_of_validity: null,
     end_of_period: null,
     next_capture_at: 1419675600,
     created_at: 1417083600,
     updated_at: 1417083600,
     canceled_at: null,
     payment: 
      { id: 'pay_f63fddd433460a370ee7414c',
        type: 'debit',
        client: 'client_c491d47a4b28fb38960a',
        code: '50010517',
        holder: 'Chris Hansen',
        account: '*****9890',
        iban: null,
        bic: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        app_id: null,
        is_recurring: true,
        is_usable_for_preauthorization: true },
     app_id: null,
     is_canceled: false,
     is_deleted: false,
     status: 'active',
     client: 
      { id: 'client_c491d47a4b28fb38960a',
        email: '[email protected]',
        description: 'subscription customer',
        app_id: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        payment: [Object],
        subscription: [Object] } } }

This is the result aka. the updated sub:

{ id: 'sub_bf336fe5883b5df76795',
  offer: 
   { id: 'offer_277bcb600c0a3ce7d974',
     name: 'Das Monatspaket',
     amount: 3000,
     currency: 'EUR',
     interval: 
      { length: 1,
        unit: 'MONTH',
        chargeday: undefined,
        originalJson: '1 MONTH' },
     trial_period_days: 0,
     created_at: Tue Oct 28 2014 18:17:34 GMT+0100 (CET),
     updated_at: Mon Nov 17 2014 12:20:20 GMT+0100 (CET),
     subscription_count: { active: '131', inactive: '8', originalJson: [Object] },
     app_id: null,
     originalJson: 
      { id: 'offer_277bcb600c0a3ce7d974',
        name: 'Das Monatspaket',
        amount: 3000,
        currency: 'EUR',
        interval: '1 MONTH',
        trial_period_days: 0,
        created_at: 1414516654,
        updated_at: 1416223220,
        subscription_count: [Object],
        app_id: null } },
  livemode: false,
  amount: 3000,
  temp_amount: null,
  currency: 'EUR',
  name: 'i changed this one',
  interval: 
   { length: 1,
     unit: 'MONTH',
     chargeday: undefined,
     originalJson: '1 MONTH' },
  trial_start: null,
  trial_end: null,
  period_of_validity: null,
  end_of_period: null,
  next_capture_at: Sat Dec 27 2014 11:20:00 GMT+0100 (CET),
  created_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
  updated_at: Thu Nov 27 2014 11:29:50 GMT+0100 (CET),
  canceled_at: null,
  payment: 
   { id: 'pay_f63fddd433460a370ee7414c',
     type: 'debit',
     client: 'client_c491d47a4b28fb38960a',
     holder: 'Chris Hansen',
     account: '*****9890',
     updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     app_id: null,
     originalJson: 
      { id: 'pay_f63fddd433460a370ee7414c',
        type: 'debit',
        client: 'client_c491d47a4b28fb38960a',
        code: '50010517',
        holder: 'Chris Hansen',
        account: '*****9890',
        iban: null,
        bic: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        app_id: null,
        is_recurring: true,
        is_usable_for_preauthorization: true } },
  app_id: null,
  is_canceled: false,
  is_deleted: false,
  status: 'active',
  client: 
   { id: 'client_c491d47a4b28fb38960a',
     email: '[email protected]',
     description: 'subscription customer',
     app_id: null,
     updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
     payment: [ [Object] ],
     subscription: [ [Object] ],
     originalJson: 
      { id: 'client_c491d47a4b28fb38960a',
        email: '[email protected]',
        description: 'subscription customer',
        app_id: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        payment: [Object],
        subscription: [Object] } },
  originalJson: 
   { id: 'sub_bf336fe5883b5df76795',
     offer: 
      { id: 'offer_277bcb600c0a3ce7d974',
        name: 'Das Monatspaket',
        amount: 3000,
        currency: 'EUR',
        interval: '1 MONTH',
        trial_period_days: 0,
        created_at: 1414516654,
        updated_at: 1416223220,
        subscription_count: [Object],
        app_id: null },
     livemode: false,
     amount: 3000,
     temp_amount: null,
     currency: 'EUR',
     name: 'i changed this one',
     interval: '1 MONTH',
     trial_start: null,
     trial_end: null,
     period_of_validity: null,
     end_of_period: null,
     next_capture_at: 1419675600,
     created_at: 1417083600,
     updated_at: 1417084190,
     canceled_at: null,
     payment: 
      { id: 'pay_f63fddd433460a370ee7414c',
        type: 'debit',
        client: 'client_c491d47a4b28fb38960a',
        code: '50010517',
        holder: 'Chris Hansen',
        account: '*****9890',
        iban: null,
        bic: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        app_id: null,
        is_recurring: true,
        is_usable_for_preauthorization: true },
     app_id: null,
     is_canceled: false,
     is_deleted: false,
     status: 'active',
     client: 
      { id: 'client_c491d47a4b28fb38960a',
        email: '[email protected]',
        description: 'subscription customer',
        app_id: null,
        updated_at: 1417083599,
        created_at: 1417083599,
        payment: [Object],
        subscription: [Object] } } }

Or am I doing something wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.