Skip to content

Added card fields eligibility types#860

Merged
AleGastelum merged 8 commits intomainfrom
feature/4229-card-fields-eligibility-types
Apr 8, 2026
Merged

Added card fields eligibility types#860
AleGastelum merged 8 commits intomainfrom
feature/4229-card-fields-eligibility-types

Conversation

@AleGastelum
Copy link
Copy Markdown
Contributor

@AleGastelum AleGastelum commented Mar 17, 2026

This PR adds types for the advanced_cards (card fields) object in the find-eligible-methods API response. With this types the merchant will be able to get Card Fields eligibility values and details for a more complete integration.

Also added a types test files for card fields so it matches the other payment methods testing patterns.

This is an example of how advanced_cards object looks:

"advanced_cards": {
            "supports_installments": false,
            "vendors": [
                {
                    "network": "DISCOVER",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "DINERS",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "MASTERCARD",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "AMEX",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "CUP",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "JCB",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "VISA",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                },
                {
                    "network": "MAESTRO",
                    "eligible": true,
                    "can_be_vaulted": true,
                    "branded": false
                }
            ],
            "cobranded_enabled": false
        },

@AleGastelum AleGastelum requested a review from a team as a code owner March 17, 2026 20:32
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: fd4d818

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@paypal/paypal-js Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@AleGastelum AleGastelum changed the title Feature/4229 card fields eligibility types Added card fields eligibility types Mar 17, 2026
Comment thread .changeset/public-ears-stay.md Outdated
type CardFieldsEligibleVendorDetails = {
network: string;
eligible: boolean;
can_be_vaulted: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snake_case is b/c the eligibility API returns in that fashion, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer snake_case. Now all values in CardFieldsEligibleVendorDetails are cammelCAse

Comment on lines +47 to +51
type CardFieldsEligiblePaymentMethodDetails = {
supportsInstallments: boolean;
cobrandedEnabled: boolean;
vendors: CardFieldsEligibleVendorDetails[];
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see can_be_vaulted below, does this type require something similar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can_be_vaulted is only part of the vendors array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add advanced_cards string to union type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

};

type CardFieldsEligibleVendorDetails = {
network: string;
Copy link
Copy Markdown
Contributor

@HackTheW2d HackTheW2d Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a string literal union to be more accurate?

type CardNetwork = "AMEX" | "CUP" | "DINERS" | "DISCOVER" | "JCB" | "MAESTRO" | "MASTERCARD" | "VISA";

network: CardNetwork;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to be a literal union with these values

console.error(error);
}
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add more tests to confirm those added types are there? For eg

if (paymentMethods.isEligible("advanced_cards")) {
      const details = paymentMethods.getDetails("advanced_cards");
      console.log(details.supportsInstallments);
      console.log(details.cobrandedEnabled);
      console.log(details.vendors[0].network);
      console.log(details.vendors[0].eligible);
      console.log(details.vendors[0].can_be_vaulted);
      console.log(details.vendors[0].branded);
  }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great callout. Added this tests!

Copy link
Copy Markdown
Contributor

@gregjopa gregjopa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @AleGastelum! 💯

@gregjopa
Copy link
Copy Markdown
Contributor

gregjopa commented Apr 8, 2026

@AleGastelum can you rebase this PR to fix the merge conflict?

Copy link
Copy Markdown
Contributor

@HackTheW2d HackTheW2d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@AleGastelum AleGastelum merged commit f6f6316 into main Apr 8, 2026
5 of 6 checks passed
@AleGastelum AleGastelum deleted the feature/4229-card-fields-eligibility-types branch April 8, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants