Download the PHP package craft-unit/craft-stripe-express-checkout without Composer

On this page you can find all versions of the php package craft-unit/craft-stripe-express-checkout. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-stripe-express-checkout

Stripe Express Checkout

Adding the Stripe Express Checkout Element to Commerce-Stripe.

Table of Contents

Features

Showcase

TODO: Add gif/webm of the express checkout; Maybe a YouTube Video showcasing the plugin would be neat

Requirements

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

e Go to the Plugin Store in your project’s Control Panel and search for “Stripe Express Checkout”. Then press “Install”.

With Composer

Open your terminal and run the following commands:

Setup

  1. Create a Stripe Account or use an existing one.
  2. Install Craft Commerce and the Stripe Gateway Plugin.
  3. Follow the setup instruction for the Stripe Gateway Plugin.
  4. Go to the plugin settings in the sidebar and select the gateway you just created.
  5. Render the buttons on your products and cart page.
  6. Be sure to handle the order complete event. You can use the fetch API to ask for the order and return it to the success page. See the Order complete section for more information.

Products page

products/_product.twig

Product Page

Cart page

cart.twig

Cart Page

Order complete

After the order is completed, the user will be redirected to the success_url you set in the options. At this point in time your order might not be completed in Craft Commerce hence why you won't see the completed order. You can use fetch to ask for the order and return it to the success page. Use the number query parameter to get the order number.

Configuration

Configuration can be done globally in the plugin settings or locally by passing settings to the craft.expressCheckout.buttons function. Passing the settings to the function will override the global settings. You can find all the options in the Stripe documentation.

Setting Name Description
items List of item object with and id and qty.
itemId ID of the variant to sell.
gatewayId Select the gateway through which payments will be processed.
shippingAddressRequired Checking this will prompt the user for their shipping address.
phoneNumberRequired Checking this box will prompt the user for their phone number.
restrictCountries Checking this will restrict the Stripe 'allowedCountries' to your country list in Commerce -> Store Settings -> Store -> Country List.
successUrl The URL that Stripe redirects to after a successful transaction. The 'successUrl' gets a query parameter called 'number' that contains the order number.
loaderTemplate The path to the loader template.
buttonHeight The height of the buttons.
applePayTheme The theme of the Apple Pay button.
googlePayTheme The theme of the GooglePay button.
paypalTheme The theme of the PayPal button.
applePayType The type of the Apple Pay button.
googlePayType The type of the GooglePay button.
paypalType The type of the PayPal button.
maxColumns The maximum number of columns.
maxRows The maximum number of rows.
overflow Choose how the overflow should be handled.
paymentMethodOrder The order of the payment methods.
showApplePay Show the Apple Pay button.
showGooglePay Show the GooglePay button.
phoneField Map the phone number to plain text on the order field layout. This will only take effect if you enable 'Phone Number Required'.

Global Settings

Stripe Express Checkout Settings Page

Local settings

Extending and Customizing

Event Hooks

Class Event
Variable EVENT_MODIFY_BUTTON_OPTIONS
StripeController EVENT_BEFORE_UPDATE_SHIPPING_RATE
StripeController EVENT_AFTER_UPDATE_SHIPPING_RATE
StripeController EVENT_UPDATE_SHIPPING_ADDRESS_ORDER_BEFORE_SAVE
StripeController EVENT_UPDATE_SHIPPING_ADDRESS_ORDER_AFTER_SAVE
ProcessStripeWebhook EVENT_MODIFY_ORDER_DETAILS
ProcessStripeWebhook EVENT_BEFORE_SAVE_SHIPPING_ADDRESS
ProcessStripeWebhook EVENT_AFTER_SAVE_SHIPPING_ADDRESS
ProcessStripeWebhook EVENT_BEFORE_SAVE_BILLING_ADDRESS
ProcessStripeWebhook EVENT_AFTER_SAVE_BILLING_ADDRESS
ProcessStripeWebhook EVENT_BEFORE_SET_ORDER_CUSTOMER
ProcessStripeWebhook EVENT_WEBHOOK_FAILED
ProcessStripeWebhook EVENT_RECEIVED_WEBHOOK
ProcessStripeWebhook EVENT_BEFORE_UPDATE_ORDER_WITH_ORDER_DETAILS

Variable::EVENT_MODIFY_BUTTON_OPTIONS

Fired right before the buttons are rendered. Modify $event->options to override the options passed to the client side StripeExpressCheckout.init() call. Setting paymentMethodConfiguration lets you control which payment methods the Express Checkout Element displays (e.g. a different set than the regular onsite checkout):

Frontend JS

Each button uses the StripeExpressCheckout class. This class is responsible for creating the Stripe Element and handling the payment intent. The instance gets added to the window.stripeExpressCheckouts object. You can give your express checkout buttons a custom name by passing the name option to the craft.expressCheckout.buttons function. You can then access the instance by calling window.stripeExpressCheckouts['your-custom-name'] or StripeExpressCheckout.getByName('your-custom-name').

Take a look at the StripeExpressCheckout class to see all the available events and methods.

Events

Event Description
stripe-express-checkout:init Called after instance was created and added to window object
stripe-express-checkout:success Called after successful onConfirm
stripe-express-checkout:error Called after failure in onConfirm

All Events get dispatched on the window object. You can listen to them by adding an event listener to the window object.

Public Methods

Method Name Parameters Description
setItemQty qty: number, id?: number Set the quantity of an item. If id is omitted, the first item is used.

Example

Below is a example showing how to manipulate the quantity of a product in the cart using the setItemQty method.


All versions of craft-stripe-express-checkout with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^5.0.0
craftcms/commerce Version ^5.0.0
craftcms/commerce-stripe Version ^5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package craft-unit/craft-stripe-express-checkout contains the following files

Loading the files please wait ...