Payment Method
Payment Method: Update
See also the Payment Method response object.
- 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
}
}
)
Arguments
token
required, StringAdditional Parameters
:company
String:country_code_alpha2
StringThe ISO 3166-1 alpha-2 country code specified in an address. The gateway only accepts specific alpha-2 values.
:country_code_alpha3
StringThe ISO 3166-1 alpha-3 country code specified in an address. The gateway only accepts specific alpha-3 values.
:country_code_numeric
StringThe ISO 3166-1 numeric country code specified in an address. The gateway only accepts specific numeric values.
:country_name
StringThe country name specified in an address. Braintree only accepts specific country names.
:extended_address
String:first_name
String:country_code
String:national_number
String:last_name
String:locality
String:update_existing
bool:phone_number
StringDeprecated.
We recommend using international_phone
. This functionality still exists in the gateway but is no longer documented. This parameter will be removed in the future.
:postal_code
String:region
String:street_address
String:billing_address_id
String:cardholder_name
String:cvv
StringTypically requires PCI SAQ D compliance
We recommend using payment_method_nonce
to avoid any PCI concerns with raw credit card data being present on your server.
A 3 or 4 digit card verification value assigned to credit cards. The CVV will never be stored in the gateway, but it can be provided with one-time requests to verify the card.
:device_data
StringCustomer device information. Pass this value only if you have Premium Fraud Management Tools enabled and are adding credit card data to your Vault. Be sure to provide the full string received from the Braintree client SDK.
:expiration_date
StringWhile we recommend using payment_method_nonce
when updating raw credit card data, the expiration date can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.
The expiration date, formatted MM/YY
or MM/YYYY
. May be used instead of expiration_month and expiration_year.
:expiration_month
StringWhile we recommend using payment_method_nonce
when updating raw credit card data, the expiration month can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.
The expiration month of a credit card, formatted MM
. May be used with expiration_year, and instead of expiration_date.
:expiration_year
StringWhile we recommend using payment_method_nonce
when updating raw credit card data, the expiration year can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.
The two or four digit year associated with a credit card, formatted YYYY
or YY
. May be used with expiration_month, and instead of expiration_date.
:number
StringTypically requires PCI SAQ D compliance
We recommend using payment_method_nonce
to avoid any PCI concerns with raw credit card data being present on your server.
The 12-19 digit value consisting of a bank identification number (BIN) and primary account number (PAN).
:make_default
boolIf the payment method is a Credit Card
or Paypal Account
, this option makes the specified payment method the default for the customer. See example below.
Prevents the verification from being evaluated as part of Premium Fraud Management Tools checks. Use with caution – once you've skipped checks for a verification, it is not possible to run them retroactively.
:venmo_sdk_session
String:verification_add_ons
multipleType of verification add ons for network check. Possible values:
customer_verification
:verification_amount
StringSpecify the merchant account ID that you want to use to verify a card. See the merchant_account_id
on Transaction: Sale
to learn more. The merchant account can't be a marketplace sub-merchant account. See the Braintree Marketplace Guide to learn more.
:verify_card
boolIf the payment method is a credit card, this option prompts the gateway to verify the card's number and expiration date. It also verifies the AVS and CVV information if you've enabled AVS and CVV rules.
In some cases, cardholders may see a temporary authorization on their account after their card has been verified. The authorization will fall off the cardholder's account within a few days and will never settle.
Only returns a Credit Card Verification
result if verification runs and is unsuccessful.
:payment_method_nonce
StringResults of a merchant-performed 3D Secure authentication. You will only need to use these fields if you've performed your own integration with a 3D Secure MPI provider (e.g. Cardinal Centinel). Otherwise, Braintree's SDKs handle this for you in our standard 3D Secure integration.
:cavv
StringCardholder authentication verification value or CAVV. The main encrypted message issuers and card networks use to verify authentication has occurred. Mastercard uses an AVV message and American Express uses an AEVV message, each of which should also be passed in the cavv parameter.
:ds_transaction_id
StringTransaction identifier resulting from 3D Secure 2 authentication. This field must be supplied for Mastercard Identity Check.
:eci_flag
StringThe value of the electronic commerce indicator (ECI) flag, which indicates the outcome of the 3DS authentication.
Accepted values for Mastercard:
00
= Failed or not attempted01
= Attempted02
= Success04
= Data-Only (Applies to limited processors)
Accepted values for all other card brands:
07
= Failed or not attempted06
= Attempted05
= Success
:three_d_secure_version
StringThe version of 3D Secure authentication used for the transaction. Required
on Visa and Mastercard authentications. Must be composed of digits separated
by periods (e.g. 1.0.2
).
:xid
StringTransaction identifier resulting from 3D Secure authentication. Uniquely identifies the transaction and sometimes required in the authorization message. Must be base64-encoded. This field will no longer be used in 3D Secure 2 authentications.
:token
StringExamples
Update billing address
To update the existing billing address when updating a payment method use the update_existing option. If any other payment methods are associated with the same billing address, this will also update the billing address for those payment methods.
- 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
}
}
)
If the payment method can't be found, it will raise a Braintree::NotFoundError
.
New billing address
If you don't use the update_existing option, a new address will be created. The existing billing address will remain in the Vault associated with the customer.
- 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",
}
)
Update with existing billing address
If a customer already has an address you'd like to use, you can update the payment method with that address.
- Ruby
result = gateway.payment_method.update(
"the_token",
:billing_address_id => "the_billing_address_id"
)
Updating a PayPal account token
The only fields that may be updated on a PayPal account are the token associated with that account, and setting the account as the default payment method for a customer.
- Ruby
updated_result = gateway.paypal_account.update(original_token,
:token => new_token
)
Make default
If the payment method is a credit card or PayPal account, you can use this call to set the payment method as the customer's default. For all other payment method types, use default_payment_method_token on Customer: Update
instead.
- Ruby
result = gateway.payment_method.update(
"the_token",
:options => {
:make_default => true
}
)
Card verification
By default we will run credit card validations but not perform verification. 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. If you choose to manually verify cards, set verify_card to true .
If you have AVS/CVV checks enabled, they will be performed when you call the payment method update. To skip these checks, set verify_card to false.
- Ruby
result = gateway.payment_method.update("the_payment_method_token",
:payment_method_nonce => nonce_from_the_client,
:options => {
:verify_card => true
}
)
Updating with a nonce and additional parameters
When updating the credit card information with a nonce, you may pass additional parameters to update as well. Here is an example of updating a payment method and explicitly verifying the card.
- Ruby
result = gateway.payment_method.update(
"the_token",
:payment_method_nonce => nonce_from_the_client,
:billing_address => {
:street_address => "1 E Main St",
:extended_address => "Suite 3",
:locality => "Chicago",
:region => "IL",
}
)
To verify the AVS information of an existing payment method, pass the update request with verify_card
set to "true". Note that an update will create a transaction, so if your processing options are set to reject transactions without CVV, you will need to include CVV as a parameter, or disable this rule (see below).
To disable the CVV requirement:
- Log into the Control Panel
- Click on the gear icon in the top right corner
- Click Fraud Management from the drop-down menu
- Next to CVV, click the Options link
- Under the Reject Transactions & Verifications If section, uncheck the CVV Not Provided (I) box
Payment method nonces vs. raw card data
While it is possible to pass both raw card data and a payment method nonce in the same call, we recommend passing only a payment method nonce.
Passing both will result in a payment method that has a mix of their attributes, with precedence given to the fields individually, then to the attributes of the payment method nonce. For example, if you pass both a card number and a payment method nonce, the payment method will have the number you passed explicitly, but the rest of the attributes will be obtained through the nonce.