# Wordpress Stripe Integration
### Install Stripe via composer
Into the root of the wordpress install with
`composer require stripe/stripe-php`
### In functions.php
```
/ Payment
function make_charge( $post_id ) {
require_once('vendor/autoload.php');
if( is_admin() ) {
return $post_id;
}
Stripe::setApiKey('STRIPE SECRET KEY');
// Get the ACF field(s)
$cost = $_POST['acf']['REPEATER HEY IF IN A REPEATER']['THE FIELD KEY'];
$token = $_POST['stripeToken'];
$charge = Charge::create([
'amount' => '$cost',
'currency' => 'cad',
'source' => $token,
'description' => 'CAN BE ANYTHING'
]);
// SENDING THE EMAIL
// Email vars
$to = 'EMAIL';
$subject = 'THE SUBJECT';
$body = 'THE BODY';
// Send email
wp_mail($to, $subject, $body);
return $post_id;
}
add_filter('acf/pre_save_post' , 'make_charge', 10, 1 );
```
### Add this to where you want the Stripe stuff to show up
```
<div id="card-element">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display form errors. -->
<div id="card-errors" role="alert"></div>
```