Calculate Surcharges for Online Payments
Preliminary
A gateway-neutral version of the online surcharge flow. Swap
generic_gatewayand the placeholder gateway calls for your processor's equivalents.
Use this guide if you are a direct merchant collecting card-not-present payments through a payment gateway that supports surcharge line items.
Before you begin
- Enable gateway surcharging. Contact your Yeeld representative with your payment gateway Merchant ID. Yeeld coordinates with your processor to enable surcharging compliance on your account.
- Review your gateway's documentation on surcharging and line items before integrating.
- Keep the Yeeld API Reference handy for endpoint schemas and error codes.
Step 1: Client side, initialize payment
Use your gateway's secure input fields (hosted fields or drop-in UI) to collect payment details. When the customer selects or updates a card, call your server to calculate the surcharge from the card attributes.
Step 2: Server side, create session and calculate surcharge
A. Create or update the gateway payment session
Create a transaction session for the base amount (pre-surcharge). Look up the token details to retrieve the card metadata Yeeld needs (brand and funding type).
B. Request the surcharge from Yeeld
Use the card metadata to call Yeeld. For the best accuracy and compliance, provide the BIN (first 6 to 8 digits) when available.
Replacevendor: "generic_gateway"with your actual gateway. See the Yeeld API Reference for the supported values.
Parameter notes
- cardBrand: card transactions only (visa, mastercard, and so on); omit for other types.
- cardFunding: credit or debit.
- bin (optional): improves accuracy and is required in some jurisdictions. Supersedes cardBrand and cardFunding when provided.
- paymentMethodType: the category of payment (card, ach, and so on).
- country: the cardholder's billing country.
- stateProvince or postalCode: the customer's location, used for regional eligibility and caps.
- issuerCountry: the country where the card was issued.
Step 3: Apply the surcharge to your gateway
If Yeeld returns a surcharge greater than 0 and your gateway session allows it, update the session with the surcharge amount.
Tip: store theyeeldTransactionIdin your gateway's metadata. It makes reconciliation and refunds much easier.
Step 4: Confirm and capture
Once the customer reviews the updated total (including the surcharge) and pays, run your gateway's confirmation flow.
Final step: record the capture to Yeeld
After the payment succeeds (tracked via your gateway's success webhooks), record the capture in Yeeld. This is required for audit trails, compliance, and refunds.
- amount: the total charged to the customer (base + taxes + surcharge).
- capturedSurchargeAmount: if the surcharge actually collected was capped lower than Yeeld calculated, pass the real collected amount here.