Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active September 21, 2016 22:53
Show Gist options
  • Save adamjstevenson/ca87f7b7cf20e14610c02960d7fb0a6c to your computer and use it in GitHub Desktop.
Save adamjstevenson/ca87f7b7cf20e14610c02960d7fb0a6c to your computer and use it in GitHub Desktop.
Add Stripe's processing fee and your platform application fee as metadata
<?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,
// The remainder of your application fee is the commission for your platform
"application fee" => $application_fee - (($db->amount/100 * .029 + .30) * 100)
)
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment