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 Code:
<?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.
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?
Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases
Quote:
Originally Posted by
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?
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)
Code:
// 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.
Re: PayPal Express Checkout - Prevent Unverified Accounts from making purchases
Quote:
Originally Posted by
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)
Code:
// 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! =)