Payment Methods

Important

Your integration may be impacted by upcoming certificate changes. Visit our best practices guide to learn more.

A payment method represents transactable payment information such as credit card details or a customer's authorization to charge a PayPal or Venmo account. Payment methods belong to a customer, are securely stored in the Braintree Vault, and have a payment_method_token attribute that you can store on your servers with reduced PCI compliance burden and later use to create transactions.

CreateAnchorIcon

Use Payment Method: Create to create a payment method for an existing customer using a payment method single-object token received from the client:

  1. Ruby
result = gateway.payment_method.create(
  :customer_id => "131866",
  :payment_method_nonce => nonce_from_the_client
)

Alternatively, you can create a new customer with a payment method using Customer: Create with the payment_method_nonce parameter.

After the payment method is successfully created, you can use Transaction: Sale with the payment_method_token parameter to create a transaction.

Note

Braintree strongly recommends verifying all cards before they are stored in your Vault by enabling card verification for your entire account in the Control Panel.

UpdateAnchorIcon

Use Payment Method: Update to update an existing payment method.

Make defaultAnchorIcon

Use the make_default option to set a payment method as the default for its customer:

  1. Ruby
result = gateway.payment_method.update(
  "the_token",
  :options => { :make_default => true }
)

Billing addressAnchorIcon

Update the billing address:

  1. Ruby
result = gateway.payment_method.update(
  "the_token",
  :billing_address => {
    :street_address => "1 E Main St",
    :extended_address => "Suite 3",
    :locality => "Chicago",
    :region => "IL",
    :postal_code => "60622",
    :options => { :update_existing => true }
  }
)

You can also omit the update_existing option to create a new billing address for the payment method.

See the reference and more examples of updating a payment method. If you want to update both payment method and customer information together, use Customer: Update.

FindAnchorIcon

Use Payment Method: Find to find a payment method:

  1. Ruby
payment_method = gateway.payment_method.find("token")

The return value of the Payment Method: Find call will be a payment_method response object.

DeleteAnchorIcon

Use Payment Method: Delete to delete a payment method:

  1. Ruby
result = gateway.payment_method.delete("the_token")
result.success?
 # true

See also

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more