当前位置: 首页>>代码示例>>PHP>>正文


PHP module_config::get_currency方法代码示例

本文整理汇总了PHP中module_config::get_currency方法的典型用法代码示例。如果您正苦于以下问题:PHP module_config::get_currency方法的具体用法?PHP module_config::get_currency怎么用?PHP module_config::get_currency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在module_config的用法示例。


在下文中一共展示了module_config::get_currency方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle_paypal_ipn

 function handle_paypal_ipn()
 {
     ob_end_clean();
     if (!isset($_REQUEST['custom'])) {
         return;
     }
     $paypal_bits = explode("|", $_REQUEST['custom']);
     $user_id = (int) $paypal_bits[0];
     $payment_id = (int) $paypal_bits[1];
     $invoice_id = (int) $paypal_bits[2];
     $invoice_payment_subscription_id = false;
     if (count($paypal_bits) == 4) {
         // normal IPN, single payment.
     } else {
         if (count($paypal_bits) == 5) {
             // subscription IPN, with subscription id.
             $invoice_payment_subscription_id = (int) $paypal_bits[3];
             $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
         }
     }
     //send_error('bad?');
     if ($payment_id && $invoice_id) {
         $hash = $this->paypal_custom($user_id, $payment_id, $invoice_id, $invoice_payment_subscription_id);
         if ($hash != $_REQUEST['custom']) {
             send_error("PayPal IPN Error (incorrect hash) it should be " . $hash);
             exit;
         }
         /*$sql = "SELECT * FROM `"._DB_PREFIX."user` WHERE user_id = '$user_id' LIMIT 1";
                     $res = qa($sql);
                     if($res){
         
                         $user = array_shift($res);
                         if($user && $user['user_id'] == $user_id){*/
         // check for payment exists
         $payment = module_invoice::get_invoice_payment($payment_id);
         $invoice = module_invoice::get_invoice($invoice_id);
         if ($payment && $invoice) {
             /*if(isset($_REQUEST['fakepay'])){
                                         if($invoice_payment_subscription_id){
                                             // we have a subscription payment. woo!
                                             // this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
                                             // if this invoice hasn't been generated yet then we have to generate it.
                                             // pass this back to the invoice class so we can reuse this feature in the future.
                                             $data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $payment_id, $invoice_payment_subscription_id);
                                             if($data && $data['invoice_id'] && $data['invoice_payment_id']){
             
                                                 $next_time = time();
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['days']).' days',$next_time);
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['months']).' months',$next_time);
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['years']).' years',$next_time);
                                                 update_insert('invoice_payment_subscription_id',$invoice_payment_subscription_id,'invoice_payment_subscription',array(
                                                     'date_last_pay' => date('Y-m-d'),
                                                     'date_next' => date('Y-m-d',$next_time),
                                                 ));
                                                 $new_payment_details = array(
                                                       'date_paid' => date('Y-m-d'),
                                                       'amount' => $_REQUEST['mc_gross'],
                                                       'method' => 'PayPal (Subscription)',
                                                       'invoice_payment_subscription_id' => $invoice_payment_subscription_id,
                                                  );
                                                 foreach(array('fee_percent','fee_amount','fee_description','fee_total') as $fee_field){
                                                     if(isset($payment[$fee_field])) {
                                                         $new_payment_details[ $fee_field ] = $payment[ $fee_field ];
                                                     }
                                                 }
                                                  update_insert("invoice_payment_id",$data['invoice_payment_id'],"invoice_payment",$new_payment_details);
             
                                                 module_invoice::save_invoice($data['invoice_id'],array());
             
                                                 echo "Successful Subscription Payment!";
             
                                             }else{
                                                 send_error("PayPal IPN Subscription Error (failed to generate new invoice!) ".var_export($result,true));
                                             }
             
                                         }else{
                                             // mark a normal payment as paid
             
                                             update_insert("invoice_payment_id",$payment_id,"invoice_payment",array(
                                                       'date_paid' => date('Y-m-d'),
                                                       'amount' => $_REQUEST['mc_gross'],
                                                       'method' => 'PayPal (IPN)',
                                              ));
             
                                             module_invoice::save_invoice($invoice_id,array());
             
                                             echo "Successful Payment!";
             
                                         }
                                         echo 'fakepay done';exit;
                                     }*/
             $invoice_currency = module_config::get_currency($invoice['currency_id']);
             $invoice_currency_code = $invoice_currency['code'];
             // check correct business
             if (!$_REQUEST['business'] && $_REQUEST['receiver_email']) {
                 $_REQUEST['business'] = $_REQUEST['receiver_email'];
             }
             if ($_REQUEST['business'] != module_config::c('payment_method_paypal_email', _ERROR_EMAIL)) {
                 send_error('PayPal error! Paid the wrong business name. ' . $_REQUEST['business'] . ' instead of ' . module_config::c('payment_method_paypal_email', _ERROR_EMAIL));
                 exit;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:paymethod_paypal.php

示例2: external_hook

 public function external_hook($hook)
 {
     switch ($hook) {
         case 'event_ipn':
             $body = @file_get_contents('php://input');
             $event_json = json_decode($body);
             ob_start();
             echo "UCM coinbase DEBUG:<br><br>JSON: <br>\n";
             print_r($event_json);
             echo "<br><br>\n";
             $success = false;
             $bits = explode(':', isset($event_json->order->custom) ? $event_json->order->custom : '');
             if (count($bits) == 4) {
                 // we have our custom bits, invoice_id, invoice_payment_id and hash
                 // check they are right
                 $invoice_id = (int) $bits[0];
                 $invoice_payment_id = (int) $bits[1];
                 $invoice_payment_subscription_id = (int) $bits[2];
                 $hash = $bits[3];
                 $correct_hash = self::get_payment_key($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id, true);
                 if ($invoice_id && $invoice_payment_id && $hash == $correct_hash) {
                     // This will send receipts on succesful invoices
                     // todo - coinbase doesnt sent this callback correctly just yet
                     if ($event_json && isset($event_json->recurring_payment) && $invoice_payment_subscription_id) {
                         // status changes on a recurring payment.
                         $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                         if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                             // no start date yet, set the start date now.
                             if ($event_json->recurring_payment->status == 'active') {
                                 update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                             }
                         }
                         if ($event_json->recurring_payment->status == 'paused' || $event_json->recurring_payment->status == 'canceled') {
                             update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_FAILED));
                         }
                     }
                     if ($event_json && isset($event_json->order->status) && $event_json->order->status == 'completed' && isset($event_json->order->total_native) && isset($event_json->order->custom)) {
                         // crab out the custom bits so we know what to deal with.
                         $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                         $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                         if ($invoice_payment_subscription_id) {
                             // this API result is for a subscription payment.
                             $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                             if ($invoice_payment_subscription && $invoice_payment_subscription['invoice_payment_subscription_id'] == $invoice_payment_subscription_id && $currency['code'] == $event_json->order->total_native->currency_iso) {
                                 if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                                     // no start date yet, set the start date now (this should really happen in the above callback, but coinbase isn't working right now)
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                                 }
                                 // we have a subscription payment. woo!
                                 // this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
                                 // if this invoice hasn't been generated yet then we have to generate it.
                                 // pass this back to the invoice class so we can reuse this feature in the future.
                                 $data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id);
                                 if ($data && $data['invoice_id'] && $data['invoice_payment_id']) {
                                     $next_time = time();
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['days']) . ' days', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['months']) . ' months', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['years']) . ' years', $next_time);
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('date_last_pay' => date('Y-m-d'), 'date_next' => date('Y-m-d', $next_time)));
                                     update_insert("invoice_payment_id", $data['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100, 'method' => self::get_payment_method_name() . ' (Subscription)', 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Invoice Payment Subscription Received!");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Destination Address: " . $event_json->order->receive_address);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Currency code matches, marking invoice as paid.");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Raw Event Data: \n" . json_encode($event_json));
                                     module_invoice::save_invoice($data['invoice_id'], array());
                                     echo "Successful Subscription Payment!";
                                 } else {
                                     send_error("Coinbase Subscription Error (failed to generate new invoice!) " . var_export($data, true));
                                 }
                             } else {
                                 send_error('Currency code missmatch on coinbase subscription payment');
                             }
                         } else {
                             // this is a normal once off payment.
                             self::add_payment_data($invoice_payment_id, 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
                             self::add_payment_data($invoice_payment_id, 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
                             self::add_payment_data($invoice_payment_id, 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
                             self::add_payment_data($invoice_payment_id, 'log', "Destination Address: " . $event_json->order->receive_address);
                             if ($currency['code'] == $event_json->order->total_native->currency_iso) {
                                 self::add_payment_data($invoice_payment_id, 'log', "Currency code matches, marking invoice as paid.");
                                 update_insert("invoice_payment_id", $invoice_payment_id, "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100));
                                 module_invoice::save_invoice($invoice_id, array());
                                 echo "Successful Payment!";
                                 $success = true;
                             } else {
                                 self::add_payment_data($invoice_payment_id, 'log', "Currency code missmatch, please check settings!");
                             }
                             self::add_payment_data($invoice_payment_id, 'log', "Raw Event Data: \n" . json_encode($event_json));
                         }
                     }
                 }
             }
             $debug = ob_get_clean();
             if (module_config::c('coinbase_payment_debug', 0)) {
                 send_error("Coinbase Debug: {$debug}");
             }
             exit;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:paymethod_coinbase.php

示例3: paynl_redirect

 public static function paynl_redirect($description, $amount, $user_id, $payment_id, $invoice_id, $currency_id)
 {
     $currency = module_config::get_currency($currency_id);
     # Setup API URL
     $strUrl = 'https://rest-api.pay.nl/v5/Transaction/start/json?';
     # Add arguments
     $arrArguments = array();
     $arrArguments['token'] = module_config::c('payment_method_paynl_token', '');
     $arrArguments['serviceId'] = module_config::c('payment_method_paynl_serviceid', '');
     $arrArguments['amount'] = $amount * 100;
     $arrArguments['finishUrl'] = module_invoice::link_public_payment_complete($invoice_id);
     $arrArguments['ipAddress'] = $_SERVER['REMOTE_ADDR'];
     $arrArguments['transactionl'] = array();
     $arrArguments['transaction']['description'] = $description;
     //$currency['code']
     # Prepare and call API URL
     $strUrl .= http_build_query($arrArguments);
     $ch = curl_init($strUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     $jsonResult = curl_exec($ch);
     //$jsonResult = file_get_contents($strUrl);
     $json = json_decode($jsonResult, true);
     if ($json && isset($json['transaction']) && isset($json['transaction']['paymentURL']) && isset($json['transaction']['transactionId'])) {
         module_paymethod_paynl::add_payment_data($payment_id, 'log', "Started PayNL Payment: \n " . var_export($json, true));
         update_insert('invoice_payment_id', $payment_id, 'invoice_payment', array('other_id' => $json['transaction']['transactionId']));
         redirect_browser($json['transaction']['paymentURL']);
     } else {
         module_paymethod_paynl::add_payment_data($payment_id, 'log', "PayNL ERROR: \n " . $jsonResult);
         echo 'Sorry an error occured during payment processing. Please try again.';
         echo $jsonResult;
         exit;
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:34,代码来源:paymethod_paynl.php

示例4: google_redirect

 public static function google_redirect($description, $amount, $user_id, $invoice_payment_id, $invoice_id, $currency_id)
 {
     chdir(dirname(__FILE__));
     //'includes/plugin_paymethod_google/');
     require_once 'library/googlecart.php';
     require_once 'library/googleitem.php';
     $server_type = self::is_sandbox() ? "sandbox" : '';
     $currency = module_config::get_currency($currency_id);
     self::add_payment_data($invoice_payment_id, 'log', 'Starting payment of ' . $server_type . ' in currency ' . $currency['code']);
     $cart = new GoogleCart(self::get_merchant_id(), self::get_merchant_key(), $server_type, $currency['code']);
     $total_count = 1;
     //  Check this URL for more info about the two types of digital Delivery
     //  http://code.google.com/apis/checkout/developer/Google_Checkout_Digital_Delivery.html
     //  Key/URL delivery
     self::add_payment_data($invoice_payment_id, 'log', 'Adding ' . $total_count . 'x ' . $description . ' (' . $amount . ' ' . $currency['code'] . ')');
     $item_1 = new GoogleItem($description, "", $total_count, $amount);
     // Unit price
     //$item_1->SetURLDigitalContent(module_invoice::link_receipt($invoice_payment_id),
     $item_1->SetURLDigitalContent(module_invoice::link_public_print($invoice_id), '', _l("Payment Receipt"));
     $cart->AddItem($item_1);
     $private_data = new MerchantPrivateData(array('invoice_id' => $invoice_id, 'amount' => $amount, 'currency_id' => $currency_id, 'invoice_payment_id' => $invoice_payment_id));
     $cart->SetMerchantPrivateData($private_data);
     // Specify <edit-cart-url>
     $cart->SetEditCartUrl(module_invoice::link_public($invoice_id));
     // Specify "Return to xyz" link
     $cart->SetContinueShoppingUrl(module_invoice::link_public($invoice_id));
     // Request buyer's phone number
     //$cart->SetRequestBuyerPhone(true);
     // This will do a server-2-server cart post and send an HTTP 302 redirect status
     // This is the best way to do it if implementing digital delivery
     // More info http://code.google.com/apis/checkout/developer/index.html#alternate_technique
     list($status, $error) = $cart->CheckoutServer2Server();
     // if i reach this point, something was wrong
     echo "An error had ocurred: <br />HTTP Status: " . $status . ":";
     echo "<br />Error message:<br />";
     echo $error;
     exit;
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:38,代码来源:paymethod_google.php

示例5: external_hook


//.........这里部分代码省略.........
                 $error = "Sorry: Webhook failed. <br><br>\n\n";
                 $error .= $err['message'];
                 $error .= "\n\n\n" . var_export($e, true);
                 echo $error;
             }
             $debug = ob_get_clean();
             //mail('dtbaker@gmail.com','Stripe Webhook debug',$debug);
             if (module_config::c('stripe_payment_debug', 0)) {
                 echo $debug;
             }
             echo "Thanks! (set stripe_payment_debug to 1 in UCM to see more data here)";
             exit;
             break;
         case 'pay_subscription':
             $invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
             $invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
             $invoice_payment_subscription_id = isset($_REQUEST['invoice_payment_subscription_id']) ? $_REQUEST['invoice_payment_subscription_id'] : false;
             $stripe_plan_id = isset($_REQUEST['stripe_plan_id']) ? $_REQUEST['stripe_plan_id'] : false;
             $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : false;
             if ($invoice_id && $invoice_payment_id && $stripe_plan_id && $invoice_payment_subscription_id && $user_id && isset($_POST['stripeToken'])) {
                 $user_data = module_user::get_user($user_id);
                 $email = isset($_REQUEST['stripeEmail']) && strlen($_REQUEST['stripeEmail']) ? $_REQUEST['stripeEmail'] : $user_data['email'];
                 if (!$email || !strpos($email, '@')) {
                     die('Please ensure your user account has a valid email address before paying with stripe');
                 }
                 $invoice_payment = get_single('invoice_payment', 'invoice_payment_id', $invoice_payment_id);
                 $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                 if (!$invoice_payment || !$invoice_payment_subscription || $invoice_payment['invoice_id'] != $invoice_id || $invoice_payment['invoice_payment_subscription_id'] != $invoice_payment_subscription_id) {
                     die('Invalid invoice payment subscription id');
                 }
                 $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                 $invoice_data = module_invoice::get_invoice($invoice_id);
                 if ($invoice_payment_data && $invoice_data && $invoice_id == $invoice_data['invoice_id'] && $invoice_payment_data['invoice_id'] == $invoice_data['invoice_id']) {
                     $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                     $currency_code = $currency['code'];
                     $description = isset($_REQUEST['description']) ? $_REQUEST['description'] : 'N/A';
                     $template = new module_template();
                     ob_start();
                     require_once 'includes/plugin_paymethod_stripe/stripe-php/lib/Stripe.php';
                     $stripe = array("secret_key" => module_config::c('payment_method_stripe_secret_key'), "publishable_key" => module_config::c('payment_method_stripe_publishable_key'));
                     Stripe::setApiKey($stripe['secret_key']);
                     try {
                         // todo- search for existing customer based on email address???
                         // todo: check if adding new plan to existing customer work??
                         $stripe_customer = Stripe_Customer::create(array("card" => $_POST['stripeToken'], "email" => $email, 'metadata' => array('user_id' => $user_id)));
                         if ($stripe_customer && $stripe_customer->id) {
                             //} && $stripe_customer->subscriptions){
                             $stripe_subscription = $stripe_customer->subscriptions->create(array('plan' => $stripe_plan_id));
                             if ($stripe_subscription && $stripe_subscription->id) {
                                 update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d'), 'stripe_customer' => $stripe_customer->id, 'stripe_subscription' => $stripe_subscription->id));
                                 module_paymethod_stripe::add_payment_data($invoice_payment_id, 'log', "Started Stripe Subscription: " . var_export(array('customer.id' => $stripe_customer->id, 'plan.id' => $stripe_plan_id, 'subscription.id' => $stripe_subscription->id), true));
                                 // success!
                                 // redirect to receipt page.
                                 redirect_browser(module_invoice::link_public_payment_complete($invoice_id));
                             } else {
                                 echo 'Failed to create subscription with stripe';
                             }
                         }
                         $error = "Something went wrong during stripe payment. Please confirm invoice payment went through: " . htmlspecialchars($description);
                         send_error($error);
                         echo $error;
                     } catch (Stripe_CardError $e) {
                         // The card has been declined
                         $body = $e->getJsonBody();
                         $err = $body['error'];
                         $error = "Sorry: Payment failed. <br><br>\n\n" . htmlspecialchars($description) . ". <br><br>\n\n";
开发者ID:sgh1986915,项目名称:php-crm,代码行数:67,代码来源:paymethod_stripe.php

示例6: handle_multisafepay_ipn


//.........这里部分代码省略.........
                 break;
             default:
         }
         if ($initial) {
             // displayed at the last page of the transaction proces (if no redirect_url is set)
             echo '<a href="' . module_invoice::link_public($invoice_id) . '">Return to Invoice</a>';
         } else {
             // link to notify.php for MultiSafepay back-end (for delayed payment notifications)
             // backend expects an "ok" if no error occurred
             echo "ok";
         }
     } else {
         send_error('No bits in transaction id');
     }
     exit;
     $multisafepay_bits = explode("|", $_REQUEST['custom']);
     $user_id = (int) $multisafepay_bits[0];
     $payment_id = (int) $multisafepay_bits[1];
     $invoice_id = (int) $multisafepay_bits[2];
     //send_error('bad?');
     if ($user_id && $payment_id && $invoice_id) {
         $hash = $this->multisafepay_custom($user_id, $payment_id, $invoice_id);
         if ($hash != $_REQUEST['custom']) {
             send_error("Multisafepay IPN Error (incorrect hash)");
             exit;
         }
         $sql = "SELECT * FROM `" . _DB_PREFIX . "user` WHERE user_id = '{$user_id}' LIMIT 1";
         $res = qa($sql);
         if ($res) {
             $user = array_shift($res);
             if ($user && $user['user_id'] == $user_id) {
                 // check for payment exists
                 $payment = module_invoice::get_invoice_payment($payment_id);
                 $invoice = module_invoice::get_invoice($invoice_id);
                 if ($payment && $invoice) {
                     $invoice_currency = module_config::get_currency($invoice['currency_id']);
                     $invoice_currency_code = $invoice_currency['code'];
                     // check correct business
                     if (!$_REQUEST['business'] && $_REQUEST['receiver_email']) {
                         $_REQUEST['business'] = $_REQUEST['receiver_email'];
                     }
                     if ($_REQUEST['business'] != module_config::c('payment_method_multisafepay_email', _ERROR_EMAIL)) {
                         send_error('Multisafepay error! Paid the wrong business name. ' . $_REQUEST['business'] . ' instead of ' . module_config::c('payment_method_multisafepay_email', _ERROR_EMAIL));
                         exit;
                     }
                     // check correct currency
                     if ($invoice_currency_code && $_REQUEST['mc_currency'] != $invoice_currency_code) {
                         send_error('Multisafepay error! Paid the wrong currency code. ' . $_REQUEST['mc_currency'] . ' instead of ' . $invoice_currency_code);
                         exit;
                     }
                     if ($_REQUEST['payment_status'] == "Canceled_Reversal" || $_REQUEST['payment_status'] == "Refunded") {
                         // funky refund!! oh noes!!
                         // TODO: store this in the database as a negative payment... should be easy.
                         // populate $_REQUEST vars then do something like $payment_history_id = update_insert("payment_history_id","new","payment_history");
                         send_error("Multisafepay Error! The payment {$payment_id} has been refunded or reversed! BAD BAD! You have to follup up customer for money manually now.");
                     } else {
                         if ($_REQUEST['payment_status'] == "Completed") {
                             // payment is completed! yeye getting closer...
                             switch ($_REQUEST['txn_type']) {
                                 case "web_accept":
                                     // running in multisafepay sandbox or not?
                                     //$sandbox = (self::is_sandbox())?"sandbox.":'';
                                     // quick check we're not getting a fake payment request.
                                     $url = 'https://www.' . (self::is_sandbox() ? 'sandbox.' : '') . 'multisafepay.com/cgi-bin/webscr';
                                     $result = self::fsockPost($url, $_POST);
                                     //send_error('multisafepay sock post: '.$url."\n\n".var_export($result,true));
                                     if (eregi("VERIFIED", $result)) {
                                         // finally have everything.
                                         // mark the payment as completed.
                                         update_insert("invoice_payment_id", $payment_id, "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $_REQUEST['mc_gross'], 'method' => 'Multisafepay (IPN)'));
                                         module_invoice::save_invoice($invoice_id, array());
                                         echo "Successful Payment!";
                                     } else {
                                         send_error("Multisafepay IPN Error (multisafepay rejected the payment!) " . var_export($result, true));
                                     }
                                     break;
                                 case "subscr_signup":
                                 default:
                                     // TODO: support different payment methods later? like a monthly hosting fee..
                                     send_error("Multisafepay IPN Error (we dont currently support this payment method: " . $_REQUEST['txn_type'] . ")");
                                     break;
                             }
                         } else {
                             send_error("Multisafepay info: This payment is not yet completed, this usually means it's an e-cheque, follow it up in a few days if you dont hear anything. This also means you may have to login to multisafepay and 'Accept' the payment. So check there first.");
                         }
                     }
                 } else {
                     send_error("Multisafepay IPN Error (no payment found in database!)");
                 }
             } else {
                 send_error("Multisafepay IPN Error (error with user that was found in database..)");
             }
         } else {
             send_error("Multisafepay IPN Error (no user found in database #1)");
         }
     } else {
         send_error("Multisafepay IPN Error (no user id found)");
     }
     exit;
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:paymethod_multisafepay.php

示例7: external_hook

 public function external_hook($hook)
 {
     switch ($hook) {
         case 'pay':
             // result is retured via ajax and displayed on the page.
             $invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
             $invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
             if ($invoice_id && $invoice_payment_id) {
                 $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                 $invoice_data = module_invoice::get_invoice($invoice_id);
                 if ($invoice_payment_data && $invoice_data && $invoice_id == $invoice_data['invoice_id'] && $invoice_payment_data['invoice_id'] == $invoice_data['invoice_id']) {
                     $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                     $currency_code = $currency['code'];
                     $description = _l('Payment for invoice %s', $invoice_data['name']);
                     require_once 'includes/plugin_paymethod_authorize/anet_php_1.1.8/AuthorizeNet.php';
                     $transaction = new AuthorizeNetAIM(module_config::c('payment_method_authorize_api_login_id', ''), module_config::c('payment_method_authorize_transaction_key', ''));
                     $transaction->setSandbox(module_config::c('payment_method_authorize_sandbox', 0));
                     $transaction->VERIFY_PEER = module_config::c('payment_method_authorize_ssl_verify', 1);
                     $transaction->amount = $invoice_payment_data['amount'];
                     // USD ONLY
                     foreach (array("address", "allow_partial_auth", "amount", "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name", "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name", "card_code", "card_num", "cardholder_authentication_value", "city", "company", "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description", "duplicate_window", "duty", "echeck_type", "email", "email_customer", "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt", "freight", "header_email_receipt", "invoice_num", "last_name", "line_item", "login", "method", "phone", "po_num", "recurring_billing", "relay_response", "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country", "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip", "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key", "trans_id", "type", "version", "zip") as $possible_value) {
                         if (isset($_POST[$possible_value])) {
                             $transaction->setField($possible_value, $_POST[$possible_value]);
                         }
                     }
                     $transaction->setField('card_num', isset($_POST['number']) ? $_POST['number'] : '');
                     $transaction->setField('exp_date', $_POST['month'] . '/' . $_POST['year']);
                     $transaction->setField('card_code', $_POST['cvv']);
                     //$transaction->card_num = isset($_POST['number']) ? $_POST['number'] : '';
                     //$transaction->exp_date = $_POST['month'].'/'.$_POST['year'];
                     //$transaction->card_code = $_POST['cvv'];
                     $response = $transaction->authorizeAndCapture();
                     if ($response->approved) {
                         //                          echo "<h1>Success! The test credit card has been charged!</h1>";
                         //                          echo "Transaction ID: " . $response->transaction_id;
                         update_insert("invoice_payment_id", $invoice_payment_id, "invoice_payment", array('date_paid' => date('Y-m-d')));
                         module_paymethod_stripe::add_payment_data($invoice_payment_id, 'log', "Successfully paid: " . var_export($response, true));
                         module_invoice::save_invoice($invoice_id, array());
                         // success!
                         // redirect to receipt page.
                         redirect_browser(module_invoice::link_receipt($invoice_payment_id));
                     } else {
                         echo isset($response->error_message) ? $response->error_message : (isset($response->response_reason_text) ? $response->response_reason_text : var_export($response, true));
                     }
                     exit;
                 }
             }
             echo 'Error paying via Authorize';
             exit;
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:51,代码来源:paymethod_authorize.php


注:本文中的module_config::get_currency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。