GFStripe

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.

$feed = gf_stripe()->get_payment_feed( $entry );

cancel()

Cancel the Stripe subscription for the customer who was created from the supplied Entry Object.

$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).

$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.

$amount = gf_stripe()->get_amount_import( $amount, $currency_code );

insert_feed()

The insert_feed() method can be used to add Stripe feeds.

$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.

gf_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 logging to be enabled.

gf_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 logging to be enabled.

gf_stripe()->log_error( $message );
  • $message string

    The message to be written to the Stripe log.

include_stripe_api()

Include the Stripe API.

gf_stripe()->include_stripe_api();