PHP code example of hypejunction / hypestripepayments

1. Go to this page and download the library: Download hypejunction/hypestripepayments 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/ */

    

hypejunction / hypestripepayments example snippets


elgg_register_plugin_hook_handler('customer.subscription.deleted', 'stripe', HandleExpiredSubscription::class);

class HandleExpiredSubscription {
	public function __invoke(\Elgg\Hook $hook) {
		$stripe_event = $hook->getParam('event');
		/* @var $stripe_event \Stripe\Event */
		
		$subscription = $stripe_event->data->object;
		
		// ... do stuff
		
		return $result; // Result will be reported back to stripe
	}
}


// Card number, expiry and CVC
echo elgg_view_field([
	'#type' => 'stripe/card',
	'#label' => 'Credit or Debit Card',
	'=> true,
]);

// Billing address
// Requires hypeCountries plugin
echo elgg_view_field([
	'#type' => 'stripe/address',
	'#label' => 'Billing address',
	'

$payment_method = get_input('payment_method');
list($gateway, $source_id) = explode('::', $payment_method);

if ($gateway == 'stripe' && $source_id) {
    // Use $source_id to create a charge
    
} else {
   $token = get_input('stripe_token');
   $address = get_input('address');
   $name = get_input('cardholder');
   
   // Use stripe API to create a new card object
   // or use the token as the source of the payment
}