How to use the braintree-web.api function in braintree-web

To help you get started, we’ve selected a few braintree-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / payments-ui / public / js / actions / pay-methods.js View on Github external
export function addCreditCard({braintreeToken, creditCard, fetch=api.fetch,
                               BraintreeClient=braintree.api.Client,
                               processingId}) {
  return (dispatch, getState) => {
    dispatch(processingActions.beginProcessing(processingId));
    var client = new BraintreeClient({
      clientToken: braintreeToken,
    });
    client.tokenizeCard({
      number: creditCard.number,
      expirationDate: creditCard.expiration,
      cvv: creditCard.cvv,
    }, function(err, nonce) {
      if (err) {
        console.error('Braintree tokenization error:', err);
        dispatch(notificationActions.showError(
          {errorCode: errorCodes.BRAINTREE_TOKENIZATION_ERROR}));
      } else {
github mozilla / payments-ui / static / public / js / actions / pay-methods.js View on Github external
export function addCreditCard({braintreeToken, creditCard, fetch=api.fetch,
                               BraintreeClient=braintree.api.Client,
                               processingId}) {
  return (dispatch, getState) => {
    dispatch(processingActions.beginProcessing(processingId));
    var client = new BraintreeClient({
      clientToken: braintreeToken,
    });
    client.tokenizeCard({
      number: creditCard.number,
      expirationDate: creditCard.expiration,
      cvv: creditCard.cvv,
    }, function(err, nonce) {
      if (err) {
        console.error('Braintree tokenization error:', err);
        dispatch(notificationActions.showError(
          {errorCode: errorCodes.BRAINTREE_TOKENIZATION_ERROR}));
      } else {
github mozilla / payments-ui / public / js / actions / transaction.js View on Github external
export function processPayment({productId, braintreeToken, creditCard,
                                payMethodUri, processingId,
                                BraintreeClient=braintree.api.Client,
                                createSubscription=defaultCreateSubscription,
                                payOnce=_processOneTimePayment,
                                ...args}) {
  return (dispatch, getState) => {
    dispatch(processingActions.beginProcessing(processingId));
    var product = products.get(productId);
    var payForProduct;

    if (product.recurrence === 'monthly') {
      console.log('calling _createSubscription for product',
                  product.id);
      payForProduct = createSubscription;
    } else {
      console.log('calling _processOneTimePayment for product',
                  product.id);
      payForProduct = payOnce;
github mozilla / payments-ui / public / js / actions / transaction.js View on Github external
export function processPayment({productId, braintreeToken, creditCard,
                                payMethodUri,
                                BraintreeClient=braintree.api.Client,
                                createSubscription=defaultCreateSubscription,
                                payOnce=processOneTimePayment,
                                ...args}) {
  return (dispatch, getState) => {
    var product = products.get(productId);
    var payForProduct;

    if (product.recurrence === 'monthly') {
      console.log('calling createSubscription for product',
                  product.id);
      payForProduct = createSubscription;
    } else {
      console.log('calling processOneTimePayment for product',
                  product.id);
      payForProduct = payOnce;
    }
github mozilla / payments-ui / static / public / js / actions / transaction.js View on Github external
export function processPayment({productId, braintreeToken, creditCard,
                                payMethodUri, processingId,
                                BraintreeClient=braintree.api.Client,
                                createSubscription=defaultCreateSubscription,
                                payOnce=_processOneTimePayment,
                                ...args}) {
  return (dispatch, getState) => {
    dispatch(processingActions.beginProcessing(processingId));
    var product = products.get(productId);
    var payForProduct;

    if (product.recurrence === 'monthly') {
      console.log('calling _createSubscription for product',
                  product.id);
      payForProduct = createSubscription;
    } else {
      console.log('calling _processOneTimePayment for product',
                  product.id);
      payForProduct = payOnce;