PHPackages                             elefant/app-stripe - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. elefant/app-stripe

ActiveElefant-app[Payment Processing](/categories/payments)

elefant/app-stripe
==================

Stripe payments integration for the Elefant CMS

1.0.0(12y ago)29621MITJavaScript

Since Jun 20Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jbroadway/stripe)[ Packagist](https://packagist.org/packages/elefant/app-stripe)[ RSS](/packages/elefant-app-stripe/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

Stripe payments app for the Elefant CMS
=======================================

[](#stripe-payments-app-for-the-elefant-cms)

This app provides everything you need to integrate [Stripe payments](https://stripe.com/)into your Elefant site, including a simple payment button you can embed through the page editor, and helpers for implementing subscriptions and payments into custom applications.

Note that this app is not a shopping cart, but could easily be the basis for building one.

#### To do:

[](#to-do)

- Additional helpers or examples:
    - Cancel subscription
    - Metered billing, one-time charges, and per-user pricing
    - Responding to failed payments

Installation
------------

[](#installation)

First, you will need to register for [Stripe](https://stripe.com/). This takes less than half an hour, including the banking setup.

Once you're signed up, the easiest way to install the app is:

1. Log into Elefant as a site admin
2. Go to Tools &gt; Designer &gt; Install App/Theme
3. Paste in the following link and click Install:

```
https://github.com/jbroadway/stripe/archive/master.zip

```

Alternately, you can run the following from the command line:

```
cd /path/to/your/site
./elefant install https://github.com/jbroadway/stripe/archive/master.zip
```

Usage
-----

[](#usage)

### Configuring the app

[](#configuring-the-app)

In the Elefant admin area, go to Tools &gt; Stripe Payments &gt; Settings and enter your publishable and secret keys that Stripe will provide for you. This is where you also set your currency, subscription plans, and other settings.

### Embedding a payment button into a page

[](#embedding-a-payment-button-into-a-page)

Log in and edit the page you wish to add the payment button to. In the WYSIWYG editor, click on the [Dynamic Objects](http://www.elefantcms.com/wiki/Dynamic-Objects)icon. In the list of Dynamic Objects, you will also find a new "Stripe: Button" option.

### Using the Stripe API

[](#using-the-stripe-api)

You can access the Stripe API, pre-initialized with your Stripe credentials, by first calling the `stripe/init` handler:

```
$stripe = $this->run ('stripe/init');

```

You now have access to the full Stripe PHP library in your Elefant applications.

### Embedding a payment button in a template

[](#embedding-a-payment-button-in-a-template)

From a view template, you can include a payment button via the following tag:

```
{! stripe/button
	?amount=10.00
	&description=Item+description
	&button=Pay
	&address=no
	&redirect=/thanks
!}

```

> Adding `%d` to the redirect value will insert the payment ID into the URL at that place.

### Creating a member payment or subscription form

[](#creating-a-member-payment-or-subscription-form)

To create a payment form for site members, run the `stripe/payment`handler like this:

```

```

To create a subscription form, run the `stripe/payment` handler like this:

```

```

The plan name should correspond to a plan you've created in your Stripe dashboard and in your Stripe settings.

### Creating a custom charge handler

[](#creating-a-custom-charge-handler)

After creating the charge via the `stripe/button` handler, the app can call a custom charge handler script that you set in the Stripe Payments settings form. This script will receive a `$data['charge']` parameter which is the `Stripe\Charge`object returned from calling `$stripe->charges->create()`, which you can then use to take action on new payments in your app, such as offering a digital file download.

The script will also receive a `$data['payment']` parameter which is the `stripe\Payment` object for the transaction.

To ensure your charge handler is secure, here is a sample script outline:

```
