Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Hopefully fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfromthelc committed Oct 29, 2024
1 parent 239509d commit a9afb36
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/inc/abuse-decisions-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ function remove_user_licenses_and_product_keys( $user_id ) {
* Display the SGDC error to the user.
*
* @param string $message Override the default message to display to the user.
*
* @return void
*/
function display_sgdc_error( $message = '' ) {
$default_message = __( 'Your account has been blocked from making purchases. SGDC Error OYBPXRQ', 'sift-decisions' );
$message = $message ? $message : $default_message;
$message = $message ? $message : $default_message;
wc_add_notice( $message, 'error' );
}

/**
* Force user logout when they are blocked from making purchases.
*
* @param integer $user_id The ID of the user to log out.
*
* @return void
*/
function force_user_logout( $user_id ) {
Expand Down
71 changes: 57 additions & 14 deletions src/inc/abuse-decisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
/**
* Process the Sift decision received.
*
* @param mixed $return The return value.
* @param string $decision_id The ID of the Sift decision.
* @param integer $entity_id The ID of the entity the decision is for.
* @param mixed $return_value The return value.
* @param string $decision_id The ID of the Sift decision.
* @param int $entity_id The ID of the entity the decision is for.
*
* @return mixed
*/
function process_sift_decision_received( $return, $decision_id, $entity_id ) {
function process_sift_decision_received( $return_value, $decision_id, $entity_id ) {

switch( $decision_id ) {
switch ( $decision_id ) {
case 'trust_list_payment_abuse':
handle_trust_list_payment_abuse( $entity_id );
break;
Expand Down Expand Up @@ -57,52 +59,93 @@ function process_sift_decision_received( $return, $decision_id, $entity_id ) {
break;
}

return $return;
return $return_value;
}
add_filter( 'sift_decision_received', __NAMESPACE__ . '\process_sift_decision_received', 10, 5 );

// Case-specific handler functions
/**
* Handle the 'trust_list_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_trust_list_payment_abuse( $user_id ) {
unblock_user_from_purchases( $user_id );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'looks_good_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_looks_good_payment_abuse( $user_id ) {
unblock_user_from_purchases( $user_id );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'not_likely_fraud_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_not_likely_fraud_payment_abuse( $user_id ) {
unblock_user_from_purchases( $user_id );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'likely_fraud_refundno_renew_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_likely_fraud_refundno_renew_payment_abuse( $user_id ) {
update_user_meta( $user_id, 'is_blocked_from_purchases', true );
void_and_refund_user_orders( $user_id );
cancel_and_remove_user_subscriptions( $user_id );
remove_user_licenses_and_product_keys( $user_id );
display_sgdc_error( 'You are blocked from making purchases due to a recent fraud review. SGDC Error OYBPXRQ' );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'likely_fraud_keep_purchases_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_likely_fraud_keep_purchases_payment_abuse( $user_id ) {
update_user_meta( $user_id, 'is_blocked_from_purchases', true );
display_sgdc_error( 'You are blocked from making purchases due to a recent fraud review. SGDC Error OYBPXRQ' );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'fraud_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_fraud_payment_abuse( $user_id ) {
update_user_meta( $user_id, 'is_blocked_from_purchases', true );
void_and_refund_user_orders( $user_id );
cancel_and_remove_user_subscriptions( $user_id );
remove_user_licenses_and_product_keys( $user_id );
display_sgdc_error( 'You are blocked from making purchases due to fraudulent activity. SGDC Error OYBPXRQ' );
force_user_logout( $user_id );
// Apply the same Sift decision to the associated WordPress.com account.
}

/**
* Handle the 'block_wo_review_payment_abuse' decision.
*
* @param int $user_id The ID of the user.
*
* @return void
*/
function handle_block_wo_review_payment_abuse( $user_id ) {
update_user_meta( $user_id, 'is_blocked_from_purchases', true );
// Apply the same Sift decision to the associated WordPress.com account.
}

0 comments on commit a9afb36

Please sign in to comment.