question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allowing customer to choose previously saved default payment method when using hosted fields

See original GitHub issue

This is not strictly a bug report, but more of the question. I’m trying to figure out how to show previously stored payment methods for the customer in the web app that’s using v3 JS SDK. While that’s easy with the drop-in UI, I was not able to find anything in the documentation for the hosted fields approach.

There are two ways that I found:

  1. Send a list of payment methods associated with the customer from the server.
  • I’m not sure this is secure, as CreditCard object on the server-side returns reusable token and not a nonce.
  1. Upon reading the drop-in v3 plugin source code, I found this:
    this._client.request({
      endpoint: 'payment_methods',
      method: 'get',
      data: {
        defaultFirst: 1
      }
    }, function (err, paymentMethodsPayload) {
      ...
    });
  • Why there’s no public method in the client object (or elsewhere) that does exactly this?
  • Is it OK to use the snippet above as-is?
  • Any potential compliancy issues if this snippet is used without the braintree-web-drop-in?

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
crookedneighborcommented, Mar 14, 2017

We just released a vault-manager component to assist with this:

<script src="https://js.braintreegateway.com/web/3.11.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.11.0/js/vault-manager.min.js"></script>
<script>
braintree.client.create({authorization: 'your-client-token-with-customer-id'}, function (err, client) {
  braintree.vaultManager.create({client: client}, function (err, vm) {
    vm.fetchPaymentMethods(function (err, paymentMethods) {
       paymentMethods // an array of payment methods
    })
  })
})

See http://braintree.github.io/braintree-web/current/VaultManager.html for docs

1reaction
lilaconleecommented, Mar 7, 2017

At the moment we don’t have a public method just to retrieve payment methods, but it is something we’ve discussed. In the meantime, we recommend using a request from the client shown in this CodePen, which is the same method we use in Drop-in. There are not any compliance issues using the client to retrieve this data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permissions for the Hosted Card Payments Component
The Hosted Card Payments component requires default object permissions from the Hosted Payment User Permission set. It also requires non-default object ...
Read more >
braintree-web/hosted-fields - Documentation
A field for postal or region code. A field for the cardholder name on the customer's credit card.
Read more >
Save payment details during payment | Stripe Documentation
Use the Payment Intents API to save payment details from a purchase. There are several use cases: Charge a customer for an e-commerce...
Read more >
Hosted Payment Pages 2.0 Settings - Knowledge Center - Zuora
In Zuora Quotes, you can configure to allow your users to add a payment method, e.g., a credit card, while creating a quote....
Read more >
Hosted Fields - Braintree Developer Documentation
Data collected using Hosted Fields is sent directly from your client to Braintree, so your customers' raw payment information never touches your server....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found