コード例 #1
0
function bizz_send_event_after_email($tracking_id = '')
{
    if (!empty($tracking_id)) {
        $args = array('post_type' => 'bizz_bookings', 'numberposts' => 1, 'fields' => 'ids', 'meta_key' => 'bizzthemes_bookings_track', 'meta_value' => $tracking_id);
        $booking_posts = get_posts($args);
        $booking_custom = get_post_custom($booking_posts[0]);
        foreach ($booking_custom as $key => $value) {
            $bookopts[$key] = $value[0];
        }
        booking_send_notification_email('after', $bookopts);
    }
}
コード例 #2
0
ファイル: booking-init.php プロジェクト: loevendahl/flexbil
function bizz_check_quickpay_response()
{
    global $booking_settings;
    // get booking settings
    $opt_s = $booking_settings->get_settings();
    if (isset($_GET['qplink'])) {
        //redirect to payment from cookie ajax redirect. preventing cross domain access error
        header("location: " . $_GET['qplink']);
    }
    if (isset($_GET['quickpay']) && $_GET['quickpay'] == 'cancel') {
        echo "<script> \n//alert('Transaktion afbrudt');\nloadStepFour(cookie_data); </script>";
    }
    if (isset($_GET['quickpay']) && $_GET['quickpay'] != 'cancel') {
        // variables
        $order_id = $_GET['quickpay'];
        $post_id = $_GET['post'];
        try {
            // Initialize
            require_once dirname(__FILE__) . "/quickpay-api/QuickpayApi.php";
            $qp = new QuickpayApi();
            //TODO change to seperate QP key
            $qp->setOptions($opt_s['pay_mollie_api']);
            $qp->mode = 'payments?order_id=';
            // Commit the status request, checking valid transaction id
            $str = $qp->status($order_id);
            $str["operations"][0] = array_reverse($str["operations"][0]);
            $qp_status = $str[0]["operations"][0]["qp_status_code"];
            $qp_status_msg = $str[0]["operations"][0]["qp_status_msg"];
            $qp_order_id = $str[0]["order_id"];
            $qp_aq_status_code = $str[0]["aq_status_code"];
            $qp_aq_status_msg = $str[0]["aq_status_msg"];
            $qp_cardtype = $str[0]["metadata"]["brand"];
            $qp_cardnumber = "xxxx-xxxxxx-" . $str[0]["metadata"]["last4"];
            $qp_amount = $str[0]["operations"][0]["amount"];
            $qp_currency = $str[0]["currency"];
            $qp_pending = $str[0]["pending"] == "true" ? " - pending " : "";
            $qp_expire = $str[0]["metadata"]["exp_month"] . "-" . $str[0]["metadata"]["exp_year"];
            /*
            20000	Approved
            40000	Rejected By Acquirer
            40001	Request Data Error
            50000	Gateway Error
            50300	Communications Error (with Acquirer)
            */
            add_post_meta($post_id, 'bizzthemes_bookings_qpcomments', '');
            switch ($qp_status) {
                case '20000':
                    update_post_meta($post_id, 'bizzthemes_bookings_status', 'approved');
                    $comments = "QuickPay Transaction: " . $str["id"] . $qp_pending . ' (' . $qp_cardtype . ' ' . $qp_amount / 100 . ' ' . $qp_currency . ') ' . $qp_status_msg;
                    update_post_meta($post_id, 'bizzthemes_bookings_qpcomments', $comments);
                    // get booking meta
                    $booking_custom = get_post_custom($post_id);
                    foreach ($booking_custom as $key => $value) {
                        $bookopts[$key] = $value[0];
                    }
                    $bookopts['bizzthemes_bookings_comm_que'] .= "\n\n" . $comments;
                    update_post_meta($post_id, 'bizzthemes_bookings_comm_que', $bookopts['bizzthemes_bookings_comm_que']);
                    //activate user account login
                    $bookuser = get_user_by('email', $bookopts['bizzthemes_bookings_email']);
                    $bookopts['post_ID'] = $post_id;
                    booking_send_notification_email('approved', $bookopts);
                    /*	add_user_meta($bookuser,'wp-approve-user','1');
                       update_user_meta($bookuser,'wp-approve-user-mail-sent','1');*/
                    break;
                default:
                    // Error in request data.
                    // write status message into order to retrieve it as error message
                    update_post_meta($post_id, 'bizzthemes_bookings_status', 'cancelled');
                    $comments = 'QuickPay Payment rejected [message:' . $qp_status_msg . ' - ' . $qp_aq_status_msg . ']';
                    update_post_meta($post_id, 'bizzthemes_bookings_qpcomments', $comments);
                    $bookopts['bizzthemes_bookings_comm_que'] .= "\n\n" . $comments;
                    update_post_meta($post_id, 'bizzthemes_bookings_comm_que', $bookopts['bizzthemes_bookings_comm_que']);
            }
        } catch (Exception $e) {
            mail("*****@*****.**", "API-problem", "API call failed: " . htmlspecialchars($e->getMessage()));
        }
    }
}