Purchase Tools
List payment methods, buy with a saved card, or generate Stripe Checkout.
listSavedPaymentMethods
Returns saved cards: externalId, brand, last4, expiresAt, isDefault. If the user has no Stripe customer or no saved cards, returns an empty list with a message.
Parameters: none
purchaseLabTest
Purchases a lab test using a saved card. Use when listSavedPaymentMethods returned at least one card.
| Parameter | Required |
|---|---|
labTestObjectKey | yes (from listAvailableLabTests) |
paymentMethodExternalId | yes (from listSavedPaymentMethods) |
promotionCode | no |
Before calling:
getProfile()— verify gender, phone (with dial code), birth date, complete home address.updateProfileif needed.- Confirm test name, price, and selected card with the user. The purchase is charged immediately.
The order is created and auto-initialized in one call (when profile is complete).
purchaseLabTestWithCheckout
Generates a Stripe Checkout payment link when the user has no saved cards.
| Parameter | Required |
|---|---|
labTestObjectKey | yes |
successUrl | yes — where to redirect after payment |
cancelUrl | yes — where to redirect on cancel |
promotionCode | no |
Share the complete checkoutUrl with the user. Never truncate. The order is created via webhook after payment completes.
Common errors
| Error | Cause |
|---|---|
| Profile incomplete | Missing required fields — fix with updateProfile |
Invalid labTestObjectKey | Use the exact value from listAvailableLabTests |
| Promo code invalid / expired | Try without the promo or get an updated code |

