Reading from Charge Properties

    Learn how to migrate an existing integration to read from payment_method_details and billing_details.

    Migrating code that reads from charges

    If you have an application with multiple payment flows and incrementally migrating each one from the Charges API to to the Payment Intents API, you should first update any code that reads from the Charge object. To help with this, the charge object has two new properties, payment_method_details and billing_details, which provide a consistent interface for reading the details of the payment method used for the charge.

    These fields are available on all API versions and on charge objects created with both the Charges API and the Payment Intents API.

    The following table shows commonly used properties on a charge and how the same information can be accessed using the new properties:

    Description Before After
    Details about the payment method used to create a charge

    charge.source

    charge.payment_method_details

    ID of the payment method used for the charge

    charge.source.id

    charge.payment_method

    Type of payment method used

    charge.source.object
    (e.g. card or bank_account)

    charge.payment_method_details.type

    Billing information for the charge (e.g. billing postal code)

    charge.source.address_zip

    charge.billing_details.address.postal_code

    Name of the cardholder

    charge.source.name

    charge.billing_details.name

    Last 4 digits of the card used

    charge.source.last4

    charge.payment_method_details.card.last4

    Fingerprint of the card

    charge.source.fingerprint

    charge.payment_method_details.card.fingerprint

    CVC verification status for the charge

    charge.source.cvc_check

    charge.payment_method_details.card.checks.cvc_check

    Card brand values

    charge.source.brand can be one of:
    Visa, MasterCard, Discover, JCB, UnionPay, Diners Club, American Express

    charge.payment_method_details.card.brand can be one of:
    visa, mastercard, discover, jcb, unionpay, diners, amex

    Google Pay enum value

    charge.source.tokenization_method is android_pay

    card.wallet.type within charge.payment_method_details is google_pay

    Description Before After
    Details about the payment method used to create a charge

    charge.source

    charge.payment_method_details

    ID of the payment method used for the charge

    charge.source.id
    charge.source.three_d_secure.card if 3D Secure source used

    charge.payment_method

    Type of payment method used

    charge.source.object == 'source' && charge.source.type
    Unless charge.source.type is three_d_secure

    charge.payment_method_details.type

    Billing information for the charge (e.g. billing postal code)

    charge.source.owner.address.postal_code

    charge.billing_details.address.postal_code

    Name of the cardholder

    charge.source.owner.name

    charge.billing_details.name

    Last 4 digits of the card used

    charge.source.card.last4
    charge.source.three_d_secure.last4

    charge.payment_method_details.card.last4

    Whether or not 3D Secure was successful

    charge.source.object == 'source' && charge.source.type == 'three_d_secure'

    charge.payment_method_details.card.three_d_secure&.succeeded

    Fingerprint of the card

    charge.source.card.fingerprint

    charge.payment_method_details.card.fingerprint

    CVC verification status for the charge

    charge.source.card.cvc_check

    charge.payment_method_details.card.checks.cvc_check

    Card brand values

    charge.source.card.brand can be one of:
    Visa, MasterCard, Discover, JCB, UnionPay, Diners Club, American Express

    charge.payment_method_details.card.brand can be one of:
    visa, mastercard, discover, jcb, unionpay, diners, amex

    Google Pay enum value

    charge.source.card.tokenization_method is android_pay

    card.wallet.type within charge.payment_method_details is google_pay

    Next steps

    Now you have migrated code that reads from Charges, you can continue migrating your integration.

    Was this page helpful? Yes No

    Send

    Thank you for helping improve Stripe's documentation. If you need help or have any questions, please consider contacting support.

    Questions?

    We're always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team. You can also chat live with other developers in #stripe on freenode.

    On this page