GFStripeDescriptiongf_stripe()get_payment_feed()cancel()get_amount_export()get_amount_import()insert_feed()add_note()log_debug()log_error()include_stripe_api()
Description
GFStripe is the class which houses the main functionality of the Gravity Forms Stripe Add-on; it extends the GFPaymentAddOn class which is part of the add-on framework. Below are a few functions which you may find useful when working on your own custom code.
gf_stripe()
The gf_stripe() function is used to return an instance of the GFStripe class.
get_payment_feed()
Retrieves the feed used to process the entry object. If the Form Object is supplied and an Entry Object isn』t then the first active feed which matches conditional logic will be returned.
1$feed = gf_stripe()->get_payment_feed( $entry );
$entry Entry Object | boolean
The Entry Object to be checked.
$form Form Object | boolean
The Form Object to be used when evaluating feed conditional logic. Defaults to false.
Returns Feed Object | boolean
The feed for this entry or false.
cancel()
Cancel the Stripe subscription for the customer who was created from the supplied Entry Object.
1$result = gf_stripe()->cancel( $entry, $feed );
$entry Entry Object
The Entry Object the subscription/customer was created from.
$feed Feed Object
The Feed Object. Not currently used so you could pass false instead.
Returns boolean
True or false. Indicates if the subscription cancellation was successful.
get_amount_export()
Removes currency symbol and if required converts the amount to the smallest unit required by the gateway (e.g. dollars to cents).
1$amount = gf_stripe()->get_amount_export( $amount, $currency_code );
$amount integer | float
The value to be formatted.
$currency_code string
The currency code.
Returns integer | float
The value which can be safely passed to Stripe.
get_amount_import()
If necessary convert the amount back from the smallest unit required by the gateway, e.g. cents to dollars.
1$amount = gf_stripe()->get_amount_import( $amount, $currency_code );
$amount integer | float
The value to be formatted.
$currency_code string
The currency code.
Returns integer | float
The formatted value.
insert_feed()
The insert_feed() method can be used to add Stripe feeds.
1$feed_id = gf_stripe()->insert_feed( $form_id, $is_active, $meta );
$form_id integer
The ID of the form this feed will be used with.
$is_active boolean
Is this feed active or inactive.
$meta Stripe Feed Meta
An associative array containing the properties which determine the type of transaction which will occur when the feed is processed.
Returns integer
The ID of the new feed.
add_note()
Add a note to the specified Entry.
1gf_stripe()->add_note( $entry_id, $note, $note_type );
$entry_id integer
The ID of the Entry this note should be added to.
$note string
The note to be added.
$note_type string
The type of note to be added. Example values: note, success, or error.
log_debug()
Writes a debug message to the log file for the Stripe Add-On. Requires the Logging Add-On.
1gf_stripe()->log_debug( $message );
$message string
The message to be written to the Stripe log.
log_error()
Writes an error message to the log file for the Stripe Add-On. Requires the Logging Add-On.
1gf_stripe()->log_error( $message );
$message string
The message to be written to the Stripe log.
include_stripe_api()
Include the Stripe API.
1gf_stripe()->include_stripe_api();