付款后发送邮件 paypal 联系表 7

sending mail after payment paypal contact form 7

我在 WordPress 站点中有一个带有联系表 7 的表单。 当您点击 "submit" 时,您将被重定向到 Paypal 并乐于付款 :)。一切正常,但我想要更多。 我想发送邮件,只有当访问者使用 Paypal 付款时。 我在 google 上搜索过,但我没有找到执行此操作的方法。

有什么想法吗?

谢谢!

内森

您可以非常轻松地使用 PayPal IPN to get this done. There is a free plugin available to get PayPal IPN setup in WordPress,但是您需要从 functions.php 文件(或您自己的插件)中创建一个基本的钩子,以便根据需要触发电子邮件已发送。

您可以根据不同的 PayPal 交易类型或付款状态触发您想要的任何操作。

这里是一个非常基本的示例,它从扩展程序向 IPN 插件发送电子邮件。这是一个完整的插件文件,只有一个插件挂钩。在这种情况下,我使用 paypal_ipn_for_wordpress_txn_type_cart 挂钩。

<?php
/**
 * @package PayPal IPN for WordPress - Hook Template
 * @version 1.0.0
 */
/*
Plugin Name: PayPal IPN for WordPress - Hook Template
Plugin URI: http://www.angelleye.com/
Description: Hook tester for PayPal IPN for WordPress plugin.
Author: angelleye
Version: 1.0.0
*/


add_action('paypal_ipn_for_wordpress_txn_type_cart', 'paypal_ipn_for_wordpress_txn_type_cart', 10, 1);
function paypal_ipn_for_wordpress_txn_type_cart($posted) {

    // Parse data from IPN $posted array

    $payment_status = isset($posted['payment_status']) ? $posted['payment_status'] : '';
    $mc_gross = isset($posted['mc_gross']) ? $posted['mc_gross'] : '';
    $first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
    $last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
    $cart_items = isset($posted['cart_items']) ? $posted['cart_items'] : '';

    /**
     * At this point you can use the data to generate email notifications,
     * update your local database, hit 3rd party web services, or anything
     * else you might want to automate based on this type of IPN.
     */
    $to = 'email@domain.com';
    $subject = 'Email from PayPal IPN';
    $message = 'Order Total: ' . $mc_gross . "\n";
    $message .= 'Payment Status: ' . $payment_status . "\n";
    $message .= 'Name: ' . $first_name . ' ' . $last_name . "\n";
    $message .= 'Cart Items: ' . print_r($cart_items, true);
    wp_mail( $to, $subject, $message );
}

因此,在您的站点上同时安装了 IPN 插件和此插件后,只要您的 PayPal 帐户进行了购物车交易,就会相应地发送一封电子邮件。这是我在 运行 PayPal 上激活此插件的测试交易时收到的电子邮件示例。

Order Total: 90.27
Payment Status: Completed
Name: Tester Testerson
Cart Items: Array
(
    [0] => Array
        (
            [item_number] =>
            [item_name] => Woo Album #2
            [quantity] => 1
            [mc_gross] => 75.27
            [mc_handling] => 0.00
            [mc_shipping] => 0.00
            [custom] =>
            [option_name1] =>
            [option_selection1] =>
            [option_name2] =>
            [option_selection2] =>
            [btn_id] =>
            [tax] => 0.00
        )

)

当然,您可以花时间使电子邮件更漂亮,然后将其发送到您需要的任何电子邮件地址。

同样,您可以使用lots of different hooks根据不同的IPN类型或付款状态来触发您自己的插件功能。

此处的示例仅包括 IPN 提供的一些数据参数,但 WordPress 中的 IPN 记录将为您提供一个模板,您可以轻松地 copy/paste 将其插入到您自己的插件文件中,其中包括每个可用的 IPN 参数IPN 类型。

列出的 PayPal IPN plugin 目前不可用,是否有其他活动插件代替?