If this is your first visit, check our documentation. To post, register or login.
Forums / PayPal Express Checkout support / PayPal Express Checkout - Prevent Unverified Accounts from making purchases

PayPal Express Checkout - Prevent Unverified Accounts from making purchases

Locked

Started by mvstudio on 30 Jan 2021, 4:01 PM · Views: 1,372

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
30 Jan 2021, 4:01 PM
#1
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

PayPal Express Checkout - Prevent Unverified Accounts from making purchases

Hello everyone. I'm trying to figure out if it would be possible to have a code that would check for the Payer Status and if it's verified accept the order, and if not throw an error message and not charge the paypal account, maybe on the checkout_success page?

I use a combination of codes to display different messages/hide checkout button depending on my store's needs. This below is the code currently on the page:

<?php
if (!IS_ADMIN_FLAG) { 
    global $order, $db;
      if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0)) { 
  
	echo '<div style="border: 3px solid #777777; padding: 10px 0;"><p style="text-align: center;"><strong>Your order no longer qualifies for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>The total for your order is below the minimum qualifying for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>Please head back to the - <a href="index.php?main_page=shopping_cart">SHOPPING BAG</a> - to increase the quantity of products in your bag, add more products or select 
	a different shipping option.</strong></p>'; 
    echo'<span id="opc-order-confirm"></span>';  
  } else {
?>


<?php
if ($_SESSION['payment'] == 'paypalwpp') {
  // do something
	echo '<div class="buttonRow">' . TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</div>';
  
} else {
  // do not do something
} ?>
<div class="buttonRow"><?php echo TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></div>
<div class="buttonRow confirm-order"><?php echo zen_image_submit(BUTTON_IMAGE_CONFIRM_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"') ;?></div>

<?php } } ?>

The first block hides the checkout button and displays a message if the order total is below the free shipping threshold. The second displays a message if paypal is selected as a method of payment, instructing them we do not accept paypal payments if account is unverified, which has been an issue.

I thought I could add a code to the paypal portion to establish if the paypal account is verified or not, but that wouldn't work, since the login to the customer's paypal account isn't established until they actually click the checkout button.

So I thought perhaps a piece of code in the checkout_success might work instead(?) but then the issue is the paypal account at that point is already charged and not much we can do.

So far what we've been doing is cancelling the orders from unverified accounts, which is a pain.

I guess my question is, is it possible for orders paid with paypal, to get pre-verified before reaching paypal and charging the account, and if the user's account is unverified, throw an error message and not charge the paypal account?

Thank you for the help.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

30 Jan 2021, 5:19 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases

While not exactly the same thing as what you're asking, since a confirmed address is a form of verification, do you have Express Checkout: Require Confirmed Address set to true already in the Express Checkout module?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

30 Jan 2021, 5:31 PM
#3
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases

DrByte:

While not exactly the same thing as what you're asking, since a confirmed address is a form of verification, do you have Express Checkout: Require Confirmed Address set to true already in the Express Checkout module?

Yes, it's set to true. Could it be possible to use that code as the platform to do what I'm looking for?

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

30 Jan 2021, 5:36 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases

Try adding the following. (I've not tested it with a live purchase, but it seems right according to the docs.)

/includes/modules/payment/paypalwpp.php (around line 1860 in v156c)

// get the payer_id from the customer's info as returned from PayPal
$_SESSION['paypal_ec_payer_id'] = $response['PAYERID'];
$this->notify('NOTIFY_PAYPAL_EXPRESS_CHECKOUT_PAYERID_DETERMINED', $response['PAYERID']);


// Block unverified PayPal accounts
if (!empty($response['PAYERSTATUS']) && $response['PAYERSTATUS'] !== 'verified') {
  $this->terminateEC('Sorry, your PayPal account is unverified. Please go to PayPal and verify your account before resuming checkout.', true, FILENAME_SHOPPING_CART);
}


// More optional response elements; initialize them to prevent follow-on PHP notices.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

30 Jan 2021, 7:03 PM
#5
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases

DrByte:

Try adding the following. (I've not tested it with a live purchase, but it seems right according to the docs.)

/includes/modules/payment/paypalwpp.php (around line 1860 in v156c)

// get the payer_id from the customer's info as returned from PayPal
$_SESSION['paypal_ec_payer_id'] = $response['PAYERID'];
$this->notify('NOTIFY_PAYPAL_EXPRESS_CHECKOUT_PAYERID_DETERMINED', $response['PAYERID']);

// Block unverified PayPal accounts
if (!empty($response['PAYERSTATUS']) && $response['PAYERSTATUS'] !== 'verified') {
$this->terminateEC('Sorry, your PayPal account is unverified. Please go to PayPal and verify your account before resuming checkout.', true, FILENAME_SHOPPING_CART);
}


// More optional response elements; initialize them to prevent follow-on PHP notices.



It seems to be working, but yet again my PP account is verified. I'm creating a new PP account just for testing, and report back. Thank you! =)

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com