Calculate Surcharges for Online Payments
Confirm your account structure
Use this guide if you are not a Connect platform, or if you are a platform using destination charges without the
on_behalf_offlag*.
Before you begin, confirm your environment is ready:
- Review Stripe Documentation - Familiarize yourself with Stripe's Surcharging Guide before integrating.
- Keep the Yeeld API Reference handy - You’ll need it for endpoint schemas and error codes throughout this guide.
Step 1: Client-Side, Initialize Payment
Use the Stripe Payment Element to collect payment details. When the user selects a payment method or updates their card info, you must trigger a call to your server to calculate the surcharge.
JavaScript Client Example
This handler captures the payment method details and sends them to your backend to sync with Yeeld.
Step 2: Server-Side, Create Intent & Calculate Surcharge
Your server acts as the orchestrator between Stripe and Yeeld.
A. Create or Update Stripe Payment Intent
Create an intent for the base amount (pre-surcharge). Expand the payment_method to retrieve the card details Yeeld needs (like brand and funding type).
Stripe Parameter Mapping:
amount: The base transaction total (without surcharge).payment_method: The ID created client-side.customer(Optional): Passing this automatically saves the payment method to the customer record upon confirmation.setup_future_usage(Optional): Set tooff_sessionif you intend to charge this card again when the customer is not present.expand[]: Necessary to access card brand, funding type, and BIN data for the next step.
B. Request Surcharge from Yeeld
Use the expanded data from Stripe to call the Yeeld API. For the highest accuracy and compliance, provide the BIN (first 6–8 digits) if available.
Yeeld Parameter Mapping:
cardBrand(payment_method.card.brand): Available for card transactions; omit for other types.cardFunding(payment_method.card.funding): Indicates if the card is credit or debit.Bin(Optional,payment_method.card.iin): Improves accuracy and is required in specific jurisdictions. SupersedescardBrand/cardFundingif provided.paymentMethodType(payment_method.type): The category of payment (e.g.,card).country(payment_method.billing_details.address.country): The cardholder's country.stateProvinceorpostalCode: The patron's location used to determine regional eligibility.issuerCountry(payment_method.card.country): The country where the card was issued.
Step 3: Apply Surcharge to Stripe
If Yeeld returns a surcharge > 0 and the Stripe Payment Intent allows it (check payment_method_options.card.surcharge.status == 'available'), update the Stripe intent with the surcharge amount.
Pro Tip: Use Stripe Metadata to link the yeeldTransactionId. This makes future reconciliation and refunds significantly easier.
Step 4: Confirm and Capture
Once the user reviews the surcharge in your UI and clicks "Pay," confirm the payment client-side.
Final Step: Capture to Yeeld
After the payment succeeds (tracked via a payment_intent.succeeded webhook), record the capture in Yeeld. This is required for audit trails and to enable refund functionality.
Capture Details:
amount: The total amount charged to the customer (Base + Taxes + Surcharge).capturedSurchargeAmount: If the surcharge that was charged to the customer is less than the surcharge that was calculated for the transaction, then it should be passed in here.- Importance: The capture must be recorded to use Yeeld’s
refund/calculateendpoints later.