Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active August 29, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancameron/47c1a983ef6487831b9b8bb9b3d855c8 to your computer and use it in GitHub Desktop.
Save dancameron/47c1a983ef6487831b9b8bb9b3d855c8 to your computer and use it in GitHub Desktop.
<?php
/**
* Updated the method to make sure the vars are being passed.
*/
public static function setAppInfo( $appName, $appVersion = null, $appUrl = null, $appPartnerId = null ) {
error_log( 'vars: ' . print_r( get_defined_vars(), true ) );
self::$appInfo = self::$appInfo ?: [];
self::$appInfo['name'] = $appName;
self::$appInfo['partner_id'] = $appPartnerId;
self::$appInfo['url'] = $appUrl;
self::$appInfo['version'] = $appVersion;
error_log( 'appinfo: ' . print_r( self::$appInfo, true ) );
}
[29-Aug-2019 16:07:38 UTC] vars: Array
(
[appName] => WordPress Sprout Invoices
[appVersion] => 19.9
[appUrl] => https://sproutinvoices.com/
[appPartnerId] => pp_partner_DL3bDXVUCYCNPQ
)
[29-Aug-2019 16:07:38 UTC] appinfo: Array
(
[name] => WordPress Sprout Invoices
[partner_id] => pp_partner_DL3bDXVUCYCNPQ
[url] => https://sproutinvoices.com/
[version] => 19.9
)
<?php
/**
* Exact code to load SDK
*/
private static function load_sdk() {
if ( ! class_exists( 'Stripe' ) ) {
require_once 'inc/sdk/init.php';
} else {
do_action( 'si_error', __CLASS__ . '::' . __FUNCTION__ . ' - the Stripe class is already included.', null );
}
try {
// Setup the API
$key = ( self::is_test() ) ? self::$api_secret_key_test : self::$api_secret_key;
\Stripe\Stripe::setAppInfo(
'Sprout Invoices',
self::SI_VERSION,
'https://sproutinvoices.com/sprout-invoices/',
'pp_partner_DL3bDXVUCYCNPQ'
);
\Stripe\Stripe::setApiKey( $key );
} catch ( Exception $e ) {
self::set_error_messages( $e->getMessage() );
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment