PHP code example of nlybe / stripe

1. Go to this page and download the library: Download nlybe/stripe library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nlybe / stripe example snippets


$token = get_input('token'); // this would have been generated by stripe.js
$user = elgg_get_logged_in_user_entity();

$client = new StripeClient();
$client->createCard($user, $token);


$user_guid = elgg_get_logged_in_user_guid();

$charge = array(
	'amount' => 12545, // amount in cents
	'currency' => 'USD',
	'card' => $card_id, // optional if the customer has a card on file
	'metadata' => array(
		'cart_guid' => $cart_guid,
		'shop_guid' => $shop_guid,
	),
);

$client = new StripeClient();
$client->createCharge($user_guid, $charge);