backdrop-contrib / stripe

This module provides a simple abstraction to use the Stripe PHP SDK.
GNU General Public License v2.0
2 stars 2 forks source link

Stripe

This module provides a simple abstraction to use the Stripe PHP SDK. This module is designed to be required by other contrib/custom modules.

Features

Installation

Usage

The main way to make Stripe API calls is using the stripe_api_call function.

/**
 * Makes a call to the Stripe API.
 *
 * @param string $obj
 *   Stripe object. Can be a Charge, Refund, Customer, Subscription, Card, Plan,
 *   Coupon, Discount, Invoice, InvoiceItem, Dispute, Transfer, TransferReversal,
 *   Recipient, BankAccount, ApplicationFee, FeeRefund, Account, Balance, Event,
 *   Token, BitcoinReceiver, FileUpload.
 *
 * @param string $method
 *   Stripe object method. Common operations include retrieve, all, create,
 *
 * @param mixed $params
 *   Additional params to pass to the method. Can be an array, string.
 *
 * @return Stripe\ApiResource
 *   Returns the ApiResource or NULL on error.
 */
stripe_api_call($obj, $method = NULL, $params = NULL) { ... }

// Examples.

// Get a customer object.
$customer = stripe_api_call('customer', 'retrieve', 'cus_id123123123');
$customer->email = NEW_EMAIL;
$customer->save();

// Create a customer object.
$customer = stripe_api_call('customer', 'create', array(
  'email' => $user->mail,
));

// Delete a customer.
$customer = stripe_api_call('customer', 'retrieve', 'cus_id123123123');
$customer->delete();

// List customers.
$list = stripe_api_call('customer', 'all', array('limit' => 5));

This module provides a secure Stripe webhook (events are validated) and provides two hooks for you to implement in your custom module. See stripe.api.php for API documentation.

This is an unofficial Stripe module and is not associated with Stripe.

Issues

Bugs and Feature requests should be reported in this module's Issue Queue.

Current Maintainers

Credits

Stripe Bindings

License

This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.