Added card fields eligibility types#860
Conversation
🦋 Changeset detectedLatest commit: fd4d818 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| type CardFieldsEligibleVendorDetails = { | ||
| network: string; | ||
| eligible: boolean; | ||
| can_be_vaulted: boolean; |
There was a problem hiding this comment.
This snake_case is b/c the eligibility API returns in that fashion, correct?
There was a problem hiding this comment.
Yes, that is correct
There was a problem hiding this comment.
No longer snake_case. Now all values in CardFieldsEligibleVendorDetails are cammelCAse
| type CardFieldsEligiblePaymentMethodDetails = { | ||
| supportsInstallments: boolean; | ||
| cobrandedEnabled: boolean; | ||
| vendors: CardFieldsEligibleVendorDetails[]; | ||
| }; |
There was a problem hiding this comment.
I see can_be_vaulted below, does this type require something similar?
There was a problem hiding this comment.
can_be_vaulted is only part of the vendors array.
There was a problem hiding this comment.
Do we want to add advanced_cards string to union type?
| }; | ||
|
|
||
| type CardFieldsEligibleVendorDetails = { | ||
| network: string; |
There was a problem hiding this comment.
Can we make this a string literal union to be more accurate?
type CardNetwork = "AMEX" | "CUP" | "DINERS" | "DISCOVER" | "JCB" | "MAESTRO" | "MASTERCARD" | "VISA";
network: CardNetwork;There was a problem hiding this comment.
Updated to be a literal union with these values
| console.error(error); | ||
| } | ||
| }); | ||
| } |
There was a problem hiding this comment.
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);
}There was a problem hiding this comment.
Great callout. Added this tests!
gregjopa
left a comment
There was a problem hiding this comment.
Nice work @AleGastelum! 💯
|
@AleGastelum can you rebase this PR to fix the merge conflict? |
This PR adds types for the
advanced_cards(card fields) object in thefind-eligible-methodsAPI 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_cardsobject looks: