function edd_process_paymentwall_purchase($purchase_data)
{
    global $edd_options;
    // Collect payment data
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'paymentwall', 'status' => 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to Paymentwall. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // Problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        edd_initialize_paymentwall_lib();
        $widget = new Paymentwall_Widget($purchase_data['user_email'], $edd_options['paymentwall_widget_code'], array(new Paymentwall_Product($payment, $purchase_data['price'], edd_get_currency(), stripslashes(html_entity_decode(wp_strip_all_tags(edd_get_purchase_summary($purchase_data, false)), ENT_COMPAT, 'UTF-8')))), array('success_url' => add_query_arg('payment-confirmation', 'paymentwall', get_permalink($edd_options['success_page'])), 'email' => $purchase_data['user_email'], 'sign_version' => Paymentwall_Signature_Abstract::VERSION_THREE, 'integration_module' => 'easy_digital_downloads'));
        // Get rid of cart contents
        edd_empty_cart();
        if (!empty($edd_options['paymentwall_widget_mode']) && $edd_options['paymentwall_widget_mode'] == 'iframe') {
            echo $htmlCode = $widget->getHtmlCode(array('width' => '100%', 'allowtransparency' => 'true'));
        } else {
            wp_redirect($widget->getUrl());
        }
        exit;
    }
}
function paymentwall_link($params)
{
    init_paymentwall_config($params);
    $shippingParams = getShippingParams($params);
    $extraParams = array_merge($shippingParams, array('integration_module' => 'whmcs', 'is_test' => isset($params['isTest']) && $params['isTest'] != '' ? 1 : 0));
    $widget = new Paymentwall_Widget($params['clientdetails']['email'], $params['widget'], array(new Paymentwall_Product((int) $params['invoiceid'], $params['amount'], $params['currency'], $params["description"], Paymentwall_Product::TYPE_FIXED)), $extraParams);
    $widgetUrl = $widget->getUrl();
    $code = '<form method=POST action="' . $widgetUrl . '"><a href="' . $widgetUrl . '"><img src="' . $params['systemurl'] . '/images/paymentwall/button_buy_white_yellow.png" alt="Paymentwall logo" height="34" width="153" /></a></form>';
    return $code;
}
Exemple #3
0
 /**
  * [get_html description]
  * @param  [type] $order_sn      [description]
  * @param  [type] $merchant_info [description]
  * @return [type]                [description]
  */
 public function get_url($appkey, $secretkey, $order)
 {
     Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
     Paymentwall_Base::setAppKey($appkey);
     // available in your Paymentwall merchant area
     Paymentwall_Base::setSecretKey($secretkey);
     // available in your Paymentwall merchant area
     $currency = $this->pay_order->get_currency_description_ZH_by_id($order['currency']);
     $currency = $currency[0]->description_ZH;
     $widget = new Paymentwall_Widget($order['pay_user_id'], 'p1_1', array(new Paymentwall_Product($order['order_sn'], $order['pay_amount'], $currency, 'Game Gold', Paymentwall_Product::TYPE_FIXED)), array());
     $url = $widget->getUrl();
     $result = array('res' => 1, 'msg' => $url);
     echo json_encode($result);
 }
    public function generateFormData($amount, $currency, $itemName, $itemId, $recurringInterval = false, $recurringUnit = false, array $extraData = array())
    {
        initPaymentwallConfigs($this->options->get('Paymentwall_appKey'), $this->options->get('Paymentwall_appSecret'));
        $itemParts = explode('|', $itemId, 4);
        $upgradeId = $itemParts[3];
        $validationType = $itemParts[0];
        $validation = XenForo_Visitor::getInstance()->get('csrf_token_page');
        $this->_assertAmount($amount);
        $this->_assertCurrency($currency);
        $this->_assertItem($itemName, $itemId);
        $this->_assertRecurring($recurringInterval, $recurringUnit);
        $userid = XenForo_Visitor::getInstance()->get('user_id');
        $custom = $userid . '|' . $upgradeId . '|' . $validationType . '|' . $validation;
        $widget = new Paymentwall_Widget($userid, $this->options->get('Paymentwall_widgetCode'), array(new Paymentwall_Product($itemId, $amount, $currency, $itemName)), array('email' => XenForo_Visitor::getInstance()->get('email'), 'integration_module' => 'xenforo', 'test_mode' => $this->options->get('Paymentwall_testMode'), 'success_url' => $this->_generateReturnUrl($extraData), 'custom' => $custom));
        $callToAction = new XenForo_Phrase('Paymentwall_call_to_action');
        $form = <<<EOF
    <form action="{$widget->getUrl()}" method="POST">
    <input type="submit" value="{$callToAction}" class="button" />
    </form>
EOF;
        return $form;
    }
 /**
  * Submit a payment through the PaymentWall Library.
  *
  * @param mixed $data
  *
  * @return Response
  */
 public function sendData($data)
 {
     // Initialise the PaymentWall configuration
     $this->setPaymentWallObject();
     $widget = new \Paymentwall_Widget($this->getAccountId(), $this->getWidgetKey(), array(new \Paymentwall_Product($this->getPackageId(), $this->getAmount(), $this->getCurrency(), $this->getDescription(), \Paymentwall_Product::TYPE_FIXED)), array('email' => $this->getEmail(), 'browser_ip' => $this->getClientIp(), 'browser_domain' => $this->getBrowserDomain(), 'success_url' => $this->getReturnUrl(), 'pingback_url' => $this->getNotifyUrl(), 'country_code' => $this->getCountry()));
     try {
         // $widget->getHtmlCode(); //will redirect user to widget page
         return new WidgetPurchaseResponse($this, $widget->getUrl());
     } catch (\Exception $e) {
         return $this->returnError('Cannot process payment', 231, $e->getMessage());
     }
 }