The Charge Element
The charge object is available on your templates (either automatically populated, or retrieved with a tag). It has the following attributes, and functions available :
Attributes
customerName
customerEmail
- The customers details
stripeCustomerId
Added in 1.4
- The Stripe Customer Id for this customer
stripePaymentId
Added in 1.4
- The Stripe Payment Id for this payment, if a one-time payment
planType
- Either charge (one-off) or recurring
planAmount
- The raw amount for the plan, in cents or pennies. ie. $5 == 500. use .formatPlanAmount() to return a nicely formatted version of this
planInterval
planIntervalCount
- The plan interval and count
planCurrency
- The 3 letter code for the currency of the charge. ie. usd/gbp/eur
hash
- A unique string for this transaction. You can use this to uniquely identify a transaction safely
mode
- The stripe mode the transaction occurred under - live or test
sourceUrl
- The url the purchase was made from
timestamp
- A DateTime of the time of purchase. Use standard Twig functions you can localize this to the format of your choosing.
userId
- The userId of the customer (if they were logged in at the time of purchase)
cardLast4
- The last 4 digits of the card. Use the .formatCard() function to return a nicely formatted version of this
cardType
- The card type.
hasDiscount
Added in 1.3
- A true/false value to test against to see if the payment has any discount applied
planCoupon
Added in 1.3
- If used, the coupon code as the user entered during payment. Only valid codes will be recorded
planCouponStripeId
Added in 1.3
- The specific Stripe Id of the coupon code as it exists on Stripe. Not needed unless you're building a custom interface for admins, and want to link to the specific coupon in the Stripe dashboard.
planDiscount
Added in 1.3
- The discount amount in cents/pence applied to the payment. Use the .formatDiscountAmount() function to display a nicely version oc this
planFullAmount
Added in 1.3
- The full original amount for the payment, before any discounts were applied
description
Added in 1.3
- A description for the payment, as optionally set during payment
meta
Array Added in 1.4
- An array of meta data as passed during payment. Also passed to Stripe during processing
Functions
To help you make nicer looking pages, you can also use the following helper functions :
charge.formatPlanAmount()
- Formats the plan amount, turns a value like '500' into '$5.00'
charge.formatCard()
- Formats the card's last 4 digits with dots in the correct format for the cardType. So '4242' turns into similar to : ···· ···· ···· 4242
charge.formatDiscountAmount()
Added in 1.3
- Formats the charge's discount amount, if the there was a discount applied. Will turn '500' into '$5.00'
charge.formatPlanFullAmount()
Added in 1.3
- Behaves the same as formatPlanAmount(), but based on the original plan amount, before any discounts