This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check for a POSTed stripeToken | |
if (isset($_POST['stripeToken'])){ | |
// Retrieve the customer id from your database/app, e.g. | |
// $customer_id = $user->customer_id; | |
try { | |
$customer = \Stripe\Customer::retrieve($customer_id); | |
$customer->source = $_POST['stripeToken']; // The token submitted from Stripe.js | |
$customer->save(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
Stripe.api_key = "YOUR-API-KEY" | |
# Authenticate as the connected account and retrieve the first 100 charges | |
charges = Stripe::Charge.all({limit: 100},{stripe_account: "acct_YourConnectedAccountID"}) | |
# Iterate through charges using auto-pagination | |
charges.auto_paging_each do |charge| | |
# Output the charge ID, amount, currency, refund, and dispute status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
Stripe.api_key = "YOUR-API-KEY" | |
# Authenticate as the connected account and retrieve the first 100 transactions | |
transactions = Stripe::BalanceTransaction.list({limit: 100},{stripe_account: "acct_YourConnectedAcctID"}) | |
total_volume = 0 | |
net_volume = 0 | |
# Iterate through transactions using auto-pagination |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
Stripe.api_key = "YOUR-API-KEY" | |
account = "acct_YourConnectedAccountID" | |
# Retrieve available balance for the connected account | |
balance = Stripe::Balance.retrieve(stripe_account: account) | |
puts "Available balance: #{balance.available[0].amount}" | |
puts "Pending balance: #{balance.pending[0].amount}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
# Your platform's secret key | |
Stripe.api_key = "YOUR-API-KEY" | |
# List `transfer.created` events on the connected account | |
events = Stripe::Event.list({type: "transfer.created", limit: 100},{stripe_account: "acct_YourConnectedAccountID"}) | |
# Iterate through each event | |
events.each do | event | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
# Your platform API key | |
Stripe.api_key = "YOUR-API-KEY" | |
# The ID of the connected account | |
account = "acct_YourConnectedAccountID" | |
# Retrieve the last 10 transfers on the connected account | |
transfers = Stripe::Transfer.list({limit:10},{stripe_account: account}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Including the library instead of using Composer | |
// Read more about installing this library here: https://github.com/stripe/stripe-php | |
require_once('stripe-php/init.php'); | |
// Replace with your API keys | |
$stripe = array( | |
"secret_key" => "YOUR-SECRET-API-KEY", | |
"publishable_key" => "YOUR-PUBLISHABLE-API-KEY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Include Stripe's library and set your API key. | |
require('./config.php'); | |
// Retrieve the amount and application fee details from your own database... | |
// Ex: $db is an object containing the attributes you retrieve from your database. | |
// Calculate the application fee to charge, in cents | |
$application_fee = ($db->amount/100 * $db->percent_fee + $db->flat_fee) * 100; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Include Stripe's library and set your API key. | |
require('./config.php'); | |
// Retrieve the account ID and application fee tier details from your own database... | |
// In this example $db is an object containing the attributes you retrieve from your database. | |
// Calculate the app fee to charge based on the pricing tier | |
if ($db->pricing_tier == 1){ | |
// Charge 2.9% + $.30 per charge (passing Stripe's default processing fees) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$charge = \Stripe\Charge::create(array( | |
"amount" => $db->amount, // The total amount to charge the customer, in cents | |
"currency" => "usd", | |
"source" => $token, // The token submitted from Checkout or Stripe.js | |
"application_fee" => $application_fee, | |
"destination" => $db->connected_account_id, // The account ID, retrieved from your database | |
"metadata" => array( | |
// Calculate Stripe's processing fee based on the total charge amount | |
"stripe fee" => ($db->amount/100 * .029 + .30) * 100, |