Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stripe example #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,34 @@ Here's a PHP Report:
//INCLUDE: /stripe.php
//VARIABLE: {"name": "count", "display": "Number to Display"}

if($count > 100 || $count < 1) throw new Exception("Count must be between 1 and 100");
if ($count > 100 || $count < 1) {
throw new Exception("Count must be between 1 and 100");
}


$charges = Stripe_Charge::all(array("count" => $count));
// Retrieve a list of charges based on count
$charges = \Stripe\Charge::all(array("limit" => $count));

// Create an array of the above charge information
$rows = array();
foreach($charges as $charge) {

// Loop through each charge
foreach ($charges->data as $charge) {

// Get the required charge information and assign to variables
$rows[] = array(
'Charge Id'=>$charge->id,
'Amount'=>number_format($charge->amount/100,2),
'Date'=>date('Y-m-d',$charge->created)
);

'ID' => $charge->id,
'Description' => $charge->description,
'Created' => gmdate('Y-m-d H:i', $charge->created), // Format the time
'Amount' => $charge->amount/100, // Convert amount from cents to dollars
'Currency' => $charge->currency
);

}

echo json_encode($rows);
?>

```
Again, the header format is very similar.

Expand All @@ -117,7 +130,7 @@ The INCLUDE header includes another report within the running one. Below is exa
require_once('lib/Stripe/Stripe.php');

//set the Stripe api key
Stripe::setApiKey("123456");
\Stripe\Stripe::setApiKey("123456");
?>
```

Expand Down