Created
February 7, 2013 07:04
-
-
Save supercleanse/4729096 to your computer and use it in GitHub Desktop.
This is the Affiliate Royale integration for DigLabs Stripe Payment plugin for WordPress ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} | |
/** This is a controller that handles all of the DigLabs Stripe Payment | |
* specific public static functions for Affiliate Royale. | |
*/ | |
class WafpDigLabsStripePaymentsController { | |
public static function load_hooks() { | |
if(function_exists( 'stripe_register_payment_end_callback' )) | |
stripe_register_payment_end_callback( 'WafpDigLabsStripePaymentsController::track_transaction' ); | |
add_action( 'stripe_payment_notification', | |
'WafpDigLabsStripePaymentsController::track_subscription_transaction', 10, 1 ); | |
//TODO: There's no way to process refunds with DigLabs yet ... but perhaps soon | |
} | |
/* Tracks when a transaction completes */ | |
public static function track_transaction($data) | |
{ | |
if(isset($_COOKIE['wafp_click'])) | |
WafpSubscription::create($data['cust_id'], __('DigLabs Stripe Payment'), $_COOKIE['wafp_click'], __("Subscription"), $_SERVER['IP_ADDR']); | |
} | |
/* Tracks when a subscription transaction completes */ | |
public static function track_subscription_transaction($event) { | |
if(isset($event->type) and $event->type == 'charge.succeeded') { | |
WafpTransaction::track( WafpUtils::format_float($event->data->object->amount / 100.00), | |
$event->data->object->id, | |
$event->customer->description, | |
'', $event->customer->id, | |
MeprUtils::object_to_string($event), '', | |
'false', __('DigLabs Stripe Payment') ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment