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

Update the total amount #2

Open
ghost opened this issue Jun 11, 2020 · 0 comments
Open

Update the total amount #2

ghost opened this issue Jun 11, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 11, 2020

Feature Request

Hey. Excellent script. I would like to use it in an Online Shop for Checkout.
I kinda hacked it in a way that now I remove and regenerate the DOM object of the button each time the value changes by calling this custom function:

var extCurrency = 'EUR';

function addMetaMask() {
  if ($('#metamask-checkout').length) $('#metamask-checkout').remove();
  // create div
  $('<div/>')
    .addClass('eth-commerce-button')
    .attr('id', 'metamask-checkout')
    .appendTo("div.widget");

  // turn it into an ETHCommerce button
  var ethCommerce = new EthCommerce();
  ethCommerce.render(
  {
      targetElement: 'metamask-checkout',
      type: 'PAY',
      amount: $('span.ct-cart-total').text().replace(/\D/g,''),
      currency: extCurrency,
      address: '0x11A7Ca870700f284e4647E55DeD9040f0F86D4D4'
  }, (e)=>{
      console.log('error callback', e);
  },(tx)=>{
      console.log('success callback', tx);
  });
}

It would be cool if your class had a function to update the amount in a more elegant way.

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

0 participants