$this->_params['is_quick_config'] = 1;
}
$this->assign('priceSetID', $this->_priceSetId);
- $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, NULL, 'name');
- if ($this->_paymentProcessor &&
- $this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('Google_Checkout', $paymentProcessorType)
- && !$this->_params['is_pay_later'] && !($this->_amount == 0)
- ) {
- $this->_checkoutButtonName = $this->getButtonName('next', 'checkout');
- $this->add('image',
- $this->_checkoutButtonName,
- $this->_paymentProcessor['url_button'],
- array('class' => 'crm-form-submit')
- );
- $this->addButtons(array(
- array(
- 'type' => 'back',
- 'name' => ts('Go Back'),
- ),
- )
- );
+ // The concept of contributeMode is deprecated.
+ // the is_monetary concept probably should be too as it can be calculated from
+ // the existence of 'amount' & seems fragile.
+ if ($this->_contributeMode == 'notify' || !$this->_values['is_monetary'] ||
+ $this->_amount <= 0.0 || $this->_params['is_pay_later'] ||
+ ($this->_separateMembershipPayment && $this->_amount <= 0.0)
+ ) {
+ $contribButton = ts('Continue');
+ $this->assign('button', ts('Continue'));
}
else {
- // The concept of contributeMode is deprecated.
- // the is_monetary concept probably should be too as it can be calculated from
- // the existence of 'amount' & seems fragile.
- if ($this->_contributeMode == 'notify' || !$this->_values['is_monetary'] ||
- $this->_amount <= 0.0 || $this->_params['is_pay_later'] ||
- ($this->_separateMembershipPayment && $this->_amount <= 0.0)
- ) {
- $contribButton = ts('Continue');
- $this->assign('button', ts('Continue'));
- }
- else {
- $contribButton = ts('Make Contribution');
- $this->assign('button', ts('Make Contribution'));
- }
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => $contribButton,
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
- ),
- array(
- 'type' => 'back',
- 'name' => ts('Go Back'),
- ),
- )
- );
- }
+ $contribButton = ts('Make Contribution');
+ $this->assign('button', ts('Make Contribution'));
+ }
+ $this->addButtons(array(
+ array(
+ 'type' => 'next',
+ 'name' => $contribButton,
+ 'spacing' => ' ',
+ 'isDefault' => TRUE,
+ 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
+ ),
+ array(
+ 'type' => 'back',
+ 'name' => ts('Go Back'),
+ ),
+ )
+ );
$defaults = array();
$fields = array_fill_keys(array_keys($this->_fields), 1);
'payment_processor_type_id'
);
$paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, $paymentProcessorTypeId, 'name');
- if ($paymentProcessorType == 'Google_Checkout') {
- $errors['is_recur_interval'] = ts('Google Checkout does not support recurring intervals');
- break;
- }
}
}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-
-require_once 'Google/library/googlecart.php';
-require_once 'Google/library/googleitem.php';
-require_once 'Google/library/googlesubscription.php';
-require_once 'Google/library/googlerequest.php';
-
-/**
- * Class CRM_Core_Payment_Google.
- *
- * Possibly not functional.
- */
-class CRM_Core_Payment_Google extends CRM_Core_Payment {
-
- /**
- * Mode of operation: live or test
- *
- * @var object
- */
- protected $_mode = NULL;
-
- /**
- * We only need one instance of this object. So we use the singleton
- * pattern and cache the instance in this variable
- *
- * @var object
- */
- static private $_singleton = NULL;
-
- /**
- * Constructor.
- *
- * @param string $mode
- * The mode of operation: live or test.
- *
- * @param $paymentProcessor
- *
- * @return \CRM_Core_Payment_Google
- */
- public function __construct($mode, &$paymentProcessor) {
- $this->_mode = $mode;
- $this->_paymentProcessor = $paymentProcessor;
- $this->_processorName = ts('Google Checkout');
- }
-
- /**
- * This function checks to see if we have the right config values.
- *
- * @return string
- * the error message if any
- */
- public function checkConfig() {
- $config = CRM_Core_Config::singleton();
-
- $error = array();
-
- if (empty($this->_paymentProcessor['user_name'])) {
- $error[] = ts('User Name is not set in the Administer CiviCRM » System Settings » Payment Processors.');
- }
-
- if (empty($this->_paymentProcessor['password'])) {
- $error[] = ts('Password is not set in the Administer CiviCRM » System Settings » Payment Processors.');
- }
-
- if (!empty($error)) {
- return implode('<p>', $error);
- }
- else {
- return NULL;
- }
- }
-
- /**
- * Sets appropriate parameters for checking out to google.
- *
- * @param array $params
- * Name value pair of contribution data.
- *
- * @param string $component
- */
- public function doTransferCheckout(&$params, $component) {
- $component = strtolower($component);
-
- if (!empty($params['is_recur']) &&
- $params['contributionRecurID']
- ) {
- return $this->doRecurCheckout($params, $component);
- }
-
- //Create a new shopping cart object
- // Merchant ID
- $merchant_id = $this->_paymentProcessor['user_name'];
- // Merchant Key
- $merchant_key = $this->_paymentProcessor['password'];
- $server_type = ($this->_mode == 'test') ? 'sandbox' : '';
-
- $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $params['currencyID']);
- $item1 = new GoogleItem($params['item_name'], '', 1, $params['amount']);
- $cart->AddItem($item1);
-
- $this->submitPostParams($params, $component, $cart);
- }
-
- /**
- * @param array $params
- * @param $component
- */
- public function doRecurCheckout(&$params, $component) {
- $intervalUnit = CRM_Utils_Array::value('frequency_unit', $params);
- if ($intervalUnit == 'week') {
- $intervalUnit = 'WEEKLY';
- }
- elseif ($intervalUnit == 'year') {
- $intervalUnit = 'YEARLY';
- }
- elseif ($intervalUnit == 'day') {
- $intervalUnit = 'DAILY';
- }
- elseif ($intervalUnit == 'month') {
- $intervalUnit = 'MONTHLY';
- }
-
- // Merchant ID
- $merchant_id = $this->_paymentProcessor['user_name'];
- // Merchant Key
- $merchant_key = $this->_paymentProcessor['password'];
- $server_type = ($this->_mode == 'test') ? 'sandbox' : '';
-
- $itemName = CRM_Utils_Array::value('item_name', $params);
- $description = CRM_Utils_Array::value('description', $params);
- $amount = CRM_Utils_Array::value('amount', $params);
- $installments = CRM_Utils_Array::value('installments', $params);
-
- $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $params['currencyID']);
- $item = new GoogleItem($itemName, $description, 1, $amount);
- $subscription_item = new GoogleSubscription("merchant", $intervalUnit, $amount, $installments);
-
- $item->SetSubscription($subscription_item);
- $cart->AddItem($item);
-
- $this->submitPostParams($params, $component, $cart);
- }
-
- /**
- * Builds appropriate parameters for checking out to google and submits the post params.
- *
- * @param array $params
- * Name value pair of contribution data.
- * @param string $component
- * Event/contribution.
- * @param object $cart
- * Object of google cart.
- */
- public function submitPostParams($params, $component, $cart) {
- $url = rtrim($this->_paymentProcessor['url_site'], '/') . '/cws/v2/Merchant/' . $this->_paymentProcessor['user_name'] . '/checkout';
-
- if ($component == "event") {
- $privateData = "contactID={$params['contactID']},contributionID={$params['contributionID']},contributionTypeID={$params['contributionTypeID']},eventID={$params['eventID']},participantID={$params['participantID']},invoiceID={$params['invoiceID']}";
- }
- elseif ($component == "contribute") {
- $privateData = "contactID={$params['contactID']},contributionID={$params['contributionID']},contributionTypeID={$params['contributionTypeID']},invoiceID={$params['invoiceID']}";
-
- $contributionRecurID = CRM_Utils_Array::value('contributionRecurID', $params);
- if ($contributionRecurID) {
- $privateData .= ",contributionRecurID=$contributionRecurID";
- }
-
- $membershipID = CRM_Utils_Array::value('membershipID', $params);
- if ($membershipID) {
- $privateData .= ",membershipID=$membershipID";
- }
-
- $relatedContactID = CRM_Utils_Array::value('related_contact', $params);
- if ($relatedContactID) {
- $privateData .= ",relatedContactID=$relatedContactID";
-
- $onBehalfDupeAlert = CRM_Utils_Array::value('onbehalf_dupe_alert', $params);
- if ($onBehalfDupeAlert) {
- $privateData .= ",onBehalfDupeAlert=$onBehalfDupeAlert";
- }
- }
- }
-
- // Allow further manipulation of the arguments via custom hooks ..
- CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $privateData);
-
- $cart->SetMerchantPrivateData($privateData);
-
- if ($component == "event") {
- $returnURL = CRM_Utils_System::url('civicrm/event/register',
- "_qf_ThankYou_display=1&qfKey={$params['qfKey']}",
- TRUE, NULL, FALSE
- );
- }
- elseif ($component == "contribute") {
- $returnURL = CRM_Utils_System::url('civicrm/contribute/transact',
- "_qf_ThankYou_display=1&qfKey={$params['qfKey']}",
- TRUE, NULL, FALSE
- );
- }
- $cart->SetContinueShoppingUrl($returnURL);
-
- $cartVal = base64_encode($cart->GetXML());
- $signatureVal = base64_encode($cart->CalcHmacSha1($cart->GetXML()));
-
- $googleParams = array(
- 'cart' => $cartVal,
- 'signature' => $signatureVal,
- );
-
- require_once 'HTTP/Request.php';
- $params = array(
- 'method' => HTTP_REQUEST_METHOD_POST,
- 'allowRedirects' => FALSE,
- );
- $request = new HTTP_Request($url, $params);
- foreach ($googleParams as $key => $value) {
- $request->addPostData($key, $value);
- }
-
- $result = $request->sendRequest();
-
- if (PEAR::isError($result)) {
- CRM_Core_Error::fatal($result->getMessage());
- }
-
- if ($request->getResponseCode() != 302) {
- CRM_Core_Error::fatal(ts('Invalid response code received from Google Checkout: %1',
- array(1 => $request->getResponseCode())
- ));
- }
- CRM_Utils_System::redirect($request->getResponseHeader('location'));
- CRM_Utils_System::civiExit();
- }
-
- /**
- * Hash_call: Function to perform the API call to PayPal using API signature
- *
- * @paymentProcessor is the array of payment processor settings value.
- * @searchParamsnvpStr is the array of search params.
- * returns an associtive array containing the response from the server.
- *
- * @param $paymentProcessor
- * @param $searchParams
- *
- * @return array|object
- * @throws \Exception
- */
- public function invokeAPI($paymentProcessor, $searchParams) {
- $merchantID = $paymentProcessor['user_name'];
- $merchantKey = $paymentProcessor['password'];
- $siteURL = rtrim(str_replace('https://', '', $paymentProcessor['url_site']), '/');
-
- $url = "https://{$merchantID}:{$merchantKey}@{$siteURL}/api/checkout/v2/reports/Merchant/{$merchantID}";
- $xml = self::buildXMLQuery($searchParams);
-
- if (!function_exists('curl_init')) {
- CRM_Core_Error::fatal("curl functions NOT available.");
- }
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
-
- //turning off the server and peer verification(TrustManager Concept).
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, Civi::settings()->get('verifySSL'));
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, Civi::settings()->get('verifySSL') ? 2 : 0);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
-
- //setting the nvpreq as POST FIELD to curl
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
-
- //getting response from server
- $xmlResponse = curl_exec($ch);
-
- // strip slashes if needed
- if (get_magic_quotes_gpc()) {
- $xmlResponse = stripslashes($xmlResponse);
- }
-
- if (curl_errno($ch)) {
- $e = CRM_Core_Error::singleton();
- $e->push(curl_errno($ch),
- 0, NULL,
- curl_error($ch)
- );
- return $e;
- }
- else {
- curl_close($ch);
- }
-
- return self::getArrayFromXML($xmlResponse);
- }
-
- /**
- * @param array $searchParams
- *
- * @return string
- */
- public static function buildXMLQuery($searchParams) {
- $xml = '<?xml version="1.0" encoding="UTF-8"?>
-<notification-history-request xmlns="http://checkout.google.com/schema/2">';
-
- if (array_key_exists('next-page-token', $searchParams)) {
- $xml .= '
-<next-page-token>' . $searchParams['next-page-token'] . '</next-page-token>';
- }
- if (array_key_exists('start', $searchParams)) {
- $xml .= '
-<start-time>' . $searchParams['start'] . '</start-time>
-<end-time>' . $searchParams['end'] . '</end-time>';
- }
- if (array_key_exists('notification-types', $searchParams)) {
- $xml .= '
-<notification-types>
-<notification-type>' . implode($searchParams['notification-types'], '</notification-type>
-<notification-type>') . '</notification-type>
-</notification-types>';
- }
- if (array_key_exists('order-numbers', $searchParams)) {
- $xml .= '
-<order-numbers>
-<google-order-number>' . implode($searchParams['order-numbers'], '</google-order-number>
-<google-order-number>') . '</google-order-number>
-</order-numbers>';
- }
- $xml .= '
-</notification-history-request>';
-
- return $xml;
- }
-
- /**
- * @param $xmlData
- *
- * @return array
- */
- public static function getArrayFromXML($xmlData) {
- require_once 'Google/library/xml-processing/gc_xmlparser.php';
- $xmlParser = new gc_XmlParser($xmlData);
- $root = $xmlParser->GetRoot();
- $data = $xmlParser->GetData();
-
- return array($root, $data);
- }
-
- /**
- * @param null $errorCode
- * @param null $errorMessage
- *
- * @return object
- */
- public function &error($errorCode = NULL, $errorMessage = NULL) {
- $e = &CRM_Core_Error::singleton();
- if ($errorCode) {
- $e->push($errorCode, 0, NULL, $errorMessage);
- }
- else {
- $e->push(9001, 0, NULL, 'Unknown System Error.');
- }
- return $e;
- }
-
- /**
- * @return string
- */
- public function accountLoginURL() {
- return ($this->_mode == 'test') ? 'https://sandbox.google.com/checkout/sell' : 'https://checkout.google.com/';
- }
-
- /**
- * @param string $message
- * @param array $params
- *
- * @return bool|object
- */
- public function cancelSubscription(&$message = '', $params = array()) {
- $orderNo = CRM_Utils_Array::value('subscriptionId', $params);
-
- $merchant_id = $this->_paymentProcessor['user_name'];
- $merchant_key = $this->_paymentProcessor['password'];
- $server_type = ($this->_mode == 'test') ? 'sandbox' : '';
-
- $googleRequest = new GoogleRequest($merchant_id, $merchant_key, $server_type);
- $result = $googleRequest->SendCancelItems($orderNo, array(), 'Cancelled by admin', '');
- $message = "{$result[0]}: {$result[1]}";
-
- if ($result[0] != 200) {
- return self::error($result[0], $result[1]);
- }
- return TRUE;
- }
-
-}
+++ /dev/null
-<?php
-
-/**
- * Copyright (C) 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Response handler code.
- *
- * This will be invoked every time a notification or request is sent by the Google Server.
- *
- * To allow this code to receive responses, the url for this file
- * must be set on the seller page under Settings->Integration as the
- * "API Callback URL'
- * Order processing commands can be sent automatically by placing these
- * commands appropriately
- *
- * To use this code for merchant-calculated feedback, this url must be
- * set also as the merchant-calculations-url when the cart is posted
- * Depending on your calculations for shipping, taxes, coupons and gift
- * certificates update parts of the code as required.
- */
-
-define('GOOGLE_DEBUG_PP', 0);
-
-/**
- * Class CRM_Core_Payment_GoogleIPN.
- */
-class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
-
- /**
- * We only need one instance of this object. So we use the singleton
- * pattern and cache the instance in this variable
- *
- * @var object
- */
- static private $_singleton = NULL;
-
- /**
- * Mode of operation: live or test
- *
- * @var object
- */
- protected $_mode = NULL;
-
- /**
- * @param string $name
- * @param $type
- * @param $object
- * @param bool $abort
- *
- * @return mixed
- */
- public static function retrieve($name, $type, $object, $abort = TRUE) {
- $value = CRM_Utils_Array::value($name, $object);
- if ($abort && $value === NULL) {
- CRM_Core_Error::debug_log_message("Could not find an entry for $name");
- echo "Failure: Missing Parameter<p>";
- exit();
- }
-
- if ($value) {
- if (!CRM_Utils_Type::validate($value, $type)) {
- CRM_Core_Error::debug_log_message("Could not find a valid entry for $name");
- echo "Failure: Invalid Parameter<p>";
- exit();
- }
- }
-
- return $value;
- }
-
- /**
- * Constructor.
- *
- * @param string $mode
- * The mode of operation: live or test.
- *
- * @param $paymentProcessor
- *
- * @return \CRM_Core_Payment_GoogleIPN
- */
- public function __construct($mode, &$paymentProcessor) {
- parent::__construct();
-
- $this->_mode = $mode;
- $this->_paymentProcessor = $paymentProcessor;
- }
-
- /**
- * The function gets called when a new order takes place.
- *
- * @param xml $dataRoot
- * Response send by google in xml format.
- * @param array $privateData
- * Contains the name value pair of <merchant-private-data>.
- *
- * @param string $component
- *
- * @return bool
- */
- public function newOrderNotify($dataRoot, $privateData, $component) {
- $ids = $input = $params = array();
-
- $input['component'] = strtolower($component);
-
- $ids['contact'] = self::retrieve('contactID', 'Integer', $privateData, TRUE);
- $ids['contribution'] = self::retrieve('contributionID', 'Integer', $privateData, TRUE);
-
- $ids['contributionRecur'] = $ids['contributionPage'] = NULL;
- if ($input['component'] == "event") {
- $ids['event'] = self::retrieve('eventID', 'Integer', $privateData, TRUE);
- $ids['participant'] = self::retrieve('participantID', 'Integer', $privateData, TRUE);
- $ids['membership'] = NULL;
- }
- else {
- $ids['membership'] = self::retrieve('membershipID', 'Integer', $privateData, FALSE);
- $ids['related_contact'] = self::retrieve('relatedContactID', 'Integer', $privateData, FALSE);
- $ids['onbehalf_dupe_alert'] = self::retrieve('onBehalfDupeAlert', 'Integer', $privateData, FALSE);
- $ids['contributionRecur'] = self::retrieve('contributionRecurID', 'Integer', $privateData, FALSE);
- }
-
- $paymentProcessorID = CRM_Core_DAO::getFieldValue(
- 'CRM_Financial_DAO_PaymentProcessorType',
- 'Google_Checkout',
- 'id',
- 'payment_processor_type'
- );
-
- if (!$this->validateData($input, $ids, $objects, TRUE, $paymentProcessorID)) {
- return FALSE;
- }
-
- $input['invoice'] = $privateData['invoiceID'];
- $input['newInvoice'] = $dataRoot['google-order-number']['VALUE'];
-
- if ($ids['contributionRecur']) {
- if ($objects['contributionRecur']->invoice_id == $dataRoot['serial-number']) {
- CRM_Core_Error::debug_log_message("The new order notification already handled: {$dataRoot['serial-number']}.");
- return FALSE;
- }
- else {
- $transaction = new CRM_Core_Transaction();
-
- CRM_Core_Error::debug_log_message("New order for an installment received.");
- $recur = &$objects['contributionRecur'];
-
- // fix dates that already exist
- $dates = array('create', 'start', 'end', 'cancel', 'modified');
- foreach ($dates as $date) {
- $name = "{$date}_date";
- if ($recur->$name) {
- $recur->$name = CRM_Utils_Date::isoToMysql($recur->$name);
- }
- }
- $recur->invoice_id = $dataRoot['serial-number'];
- $recur->processor_id = $input['newInvoice'];
- $recur->save();
-
- if ($objects['contribution']->contribution_status_id == 1) {
- // create a contribution and then get it processed
- $contribution = new CRM_Contribute_DAO_Contribution();
- $contribution->contact_id = $ids['contact'];
- $contribution->financial_type_id = $objects['contributionType']->id;
- $contribution->contribution_page_id = $objects['contribution']->contribution_page_id;
- $contribution->contribution_recur_id = $ids['contributionRecur'];
- $contribution->receive_date = date('YmdHis');
- $contribution->currency = $objects['contribution']->currency;
- $contribution->payment_instrument_id = $objects['contribution']->payment_instrument_id;
- $contribution->amount_level = $objects['contribution']->amount_level;
- $contribution->address_id = $objects['contribution']->address_id;
- $contribution->invoice_id = $input['invoice'];
- $contribution->total_amount = $dataRoot['order-total']['VALUE'];
- $contribution->contribution_status_id = 2;
- $contribution->campaign_id = $objects['contribution']->campaign_id;
-
- $objects['contribution'] = $contribution;
- }
- $transaction->commit();
- }
- }
-
- // make sure the invoice is valid and matches what we have in the contribution record
- $contribution = &$objects['contribution'];
-
- if ($contribution->invoice_id != $input['invoice']) {
- CRM_Core_Error::debug_log_message("Invoice values don't match between database and IPN request");
- return FALSE;
- }
-
- // lets replace invoice-id with google-order-number because thats what is common and unique
- // in subsequent calls or notifications sent by google.
- $contribution->invoice_id = $input['newInvoice'];
-
- $input['amount'] = $dataRoot['order-total']['VALUE'];
-
- if ($contribution->total_amount != $input['amount']) {
- CRM_Core_Error::debug_log_message("Amount values dont match between database and IPN request");
- return FALSE;
- }
-
- if (!$this->getInput($input, $ids, $dataRoot)) {
- return FALSE;
- }
-
- $transaction = new CRM_Core_Transaction();
-
- // check if contribution is already completed, if so we ignore this ipn
- if ($contribution->contribution_status_id == 1) {
- CRM_Core_Error::debug_log_message("returning since contribution has already been handled");
- return FALSE;
- }
- else {
- /* Since trxn_id hasn't got any use here,
- * lets make use of it by passing the eventID/membershipTypeID to next level.
- * And change trxn_id to google-order-number before finishing db update */
-
- if (!empty($ids['event'])) {
- $contribution->trxn_id = $ids['event'] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['participant'];
- }
- elseif (!empty($ids['membership'])) {
- $contribution->trxn_id = $ids['membership'][0] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['related_contact'] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['onbehalf_dupe_alert'];
- }
- }
-
- $contribution->save();
- $transaction->commit();
-
- return TRUE;
- }
-
- /**
- * The function gets called when the state(CHARGED, CANCELLED..) changes for an order
- *
- * @param string $status
- * Status of the transaction send by google.
- * @param $dataRoot
- * @param array $privateData
- * Contains the name value pair of <merchant-private-data>.
- *
- * @param string $component
- *
- * @return bool
- */
- public function orderStateChange($status, $dataRoot, $privateData, $component) {
- $input = $objects = $ids = array();
- $input['component'] = strtolower($component);
-
- $ids['contributionRecur'] = self::retrieve('contributionRecurID', 'Integer', $privateData, FALSE);
- $serial = $dataRoot['serial-number'];
- $orderNo = $dataRoot['google-order-number']['VALUE'];
-
- $contribution = new CRM_Contribute_BAO_Contribution();
- $contribution->invoice_id = $orderNo;
-
- if (!$contribution->find(TRUE)) {
- CRM_Core_Error::debug_log_message("orderStateChange: Could not find contribution record with invoice id: $serial");
- return FALSE;
- }
-
- // Google sends the charged notification twice.
- // So to make sure, code is not executed again.
- if ($contribution->contribution_status_id == 1) {
- CRM_Core_Error::debug_log_message("Contribution already handled (ContributionID = {$contribution->id}).");
- return FALSE;
- }
-
- // make sure invoice is set to serial no for recurring payments, to avoid violating uniqueness
- $contribution->invoice_id = $ids['contributionRecur'] ? $serial : $orderNo;
-
- $objects['contribution'] = &$contribution;
- $ids['contribution'] = $contribution->id;
- $ids['contact'] = $contribution->contact_id;
-
- $ids['event'] = $ids['participant'] = $ids['membership'] = NULL;
- $ids['contributionPage'] = NULL;
-
- if ($input['component'] == "event") {
- list($ids['event'], $ids['participant']) = explode(CRM_Core_DAO::VALUE_SEPARATOR,
- $contribution->trxn_id
- );
- }
- else {
- $ids['related_contact'] = NULL;
- $ids['onbehalf_dupe_alert'] = NULL;
- if ($contribution->trxn_id) {
- list($ids['membership'], $ids['related_contact'], $ids['onbehalf_dupe_alert']) = explode(CRM_Core_DAO::VALUE_SEPARATOR,
- $contribution->trxn_id
- );
- }
- foreach (array(
- 'membership',
- 'related_contact',
- 'onbehalf_dupe_alert',
- ) as $fld) {
- if (!is_numeric($ids[$fld])) {
- unset($ids[$fld]);
- }
- }
- }
-
- $paymentProcessorID = CRM_Core_DAO::getFieldValue(
- 'CRM_Financial_DAO_PaymentProcessorType',
- 'Google_Checkout',
- 'id',
- 'payment_processor_type'
- );
-
- $this->loadObjects($input, $ids, $objects, TRUE, $paymentProcessorID);
-
- $transaction = new CRM_Core_Transaction();
-
- if ($status == 'PAYMENT_DECLINED' ||
- $status == 'CANCELLED_BY_GOOGLE' ||
- $status == 'CANCELLED'
- ) {
- return $this->failed($objects, $transaction);
- }
-
- $input['amount'] = $contribution->total_amount;
- $input['fee_amount'] = NULL;
- $input['net_amount'] = NULL;
- $input['trxn_id'] = $ids['contributionRecur'] ? $serial : $dataRoot['google-order-number']['VALUE'];
- $input['is_test'] = $contribution->is_test;
-
- $recur = NULL;
- if ($ids['contributionRecur']) {
- $recur = $objects['contributionRecur'];
- }
- $this->completeTransaction($input, $ids, $objects, $transaction, $recur);
-
- $this->completeRecur($input, $ids, $objects);
- }
-
- /**
- * @param $input
- * @param $ids
- * @param $objects
- */
- public function completeRecur($input, $ids, $objects) {
- if ($ids['contributionRecur']) {
- $recur = &$objects['contributionRecur'];
- $contributionCount = CRM_Core_DAO::singleValueQuery("
-SELECT count(*)
-FROM civicrm_contribution
-WHERE contribution_recur_id = {$ids['contributionRecur']}
-");
- $autoRenewMembership = FALSE;
- if ($recur->id &&
- isset($ids['membership']) &&
- $ids['membership']
- ) {
- $autoRenewMembership = TRUE;
- }
- if ($recur->installments && ($contributionCount >= $recur->installments)) {
- $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-
- $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
- $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
- $recur->cancel_date = CRM_Utils_Date::isoToMysql($recur->cancel_date);
- $recur->end_date = date('YmdHis');
- $recur->modified_date = date('YmdHis');
- $recur->contribution_status_id = array_search('Completed', $contributionStatus);
- $recur->trnx_id = $dataRoot['google-order-number']['VALUE'];
- $recur->save();
-
- //send recurring Notification email for user
- CRM_Contribute_BAO_ContributionPage::recurringNotify(
- CRM_Core_Payment::RECURRING_PAYMENT_END,
- $ids['contact'],
- $ids['contributionPage'],
- $recur,
- $autoRenewMembership
- );
- }
- elseif ($contributionCount == 1) {
- CRM_Contribute_BAO_ContributionPage::recurringNotify(
- CRM_Core_Payment::RECURRING_PAYMENT_START,
- $ids['contact'],
- $ids['contributionPage'],
- $recur,
- $autoRenewMembership
- );
- }
- }
- }
-
- /**
- * @deprecated
- * Payment processor singletons removed - this is an IPN so left but probably can go
- * Singleton function used to manage this object
- *
- * @param string $mode
- * The mode of operation: live or test.
- *
- * @param $component
- * @param $paymentProcessor
- *
- * @return object
- */
- public static function &singleton($mode, $component, &$paymentProcessor) {
- if (self::$_singleton === NULL) {
- self::$_singleton = new CRM_Core_Payment_GoogleIPN($mode, $paymentProcessor);
- }
- return self::$_singleton;
- }
-
- /**
- * The function retrieves the amount the contribution is for, based on the order-no google sends
- *
- * @param int $orderNo
- * <order-total> send by google.
- *
- * @return amount
- */
- public function getAmount($orderNo) {
- $contribution = new CRM_Contribute_DAO_Contribution();
- $contribution->invoice_id = $orderNo;
- if (!$contribution->find(TRUE)) {
- CRM_Core_Error::debug_log_message("getAmount: Could not find contribution record with invoice id: $orderNo");
- echo "Failure: Could not find contribution record with invoice id: $orderNo <p>";
- exit();
- }
- return $contribution->total_amount;
- }
-
- /**
- * The function returns the component(Event/Contribute..), given the google-order-no and merchant-private-data
- *
- * @param array $privateData
- * Contains the name value pair of <merchant-private-data>.
- * @param int $orderNo
- * <order-total> send by google.
- * @param string $root
- * Root of xml-response.
- *
- * @param $response
- * @param $serial
- * @internal param \xml $xml_response response send by google in xml format
- * @return array
- * context of this call (test, module, payment processor id)
- */
- public function getContext($privateData, $orderNo, $root, $response, $serial) {
- $contributionID = CRM_Utils_Array::value('contributionID', $privateData);
- $contribution = new CRM_Contribute_DAO_Contribution();
- if ($root == 'new-order-notification') {
- $contribution->id = $contributionID;
- }
- else {
- $contribution->invoice_id = $orderNo;
- }
- if (!$contribution->find(TRUE)) {
- CRM_Core_Error::debug_log_message("getContext: Could not find contribution record with invoice id: $orderNo");
- $response->SendAck($serial);
- }
-
- $module = 'Contribute';
- if (stristr($contribution->source, ts('Online Contribution'))) {
- $module = 'Contribute';
- }
- elseif (stristr($contribution->source, ts('Online Event Registration'))) {
- $module = 'Event';
- }
- $isTest = $contribution->is_test;
-
- $ids = $input = $objects = array();
- $objects['contribution'] = &$contribution;
- $ids['contributionRecur'] = self::retrieve('contributionRecurID', 'Integer', $privateData, FALSE);
- $input['component'] = strtolower($module);
-
- if (!$ids['contributionRecur'] && $contribution->contribution_status_id == 1) {
- CRM_Core_Error::debug_log_message("Contribution already handled (ContributionID = {$contribution->id}).");
- // There is no point in going further. Return ack so we don't receive the same ipn.
- $response->SendAck($serial);
- }
-
- if ($input['component'] == 'event') {
- if ($root == 'new-order-notification') {
- $ids['event'] = $privateData['eventID'];
- }
- else {
- list($ids['event'], $ids['participant']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
- }
- }
-
- $paymentProcessorID = CRM_Core_DAO::getFieldValue(
- 'CRM_Financial_DAO_PaymentProcessor',
- 'Google_Checkout',
- 'id',
- 'payment_processor_type'
- );
-
- $this->loadObjects($input, $ids, $objects, FALSE, $paymentProcessorID);
-
- if (!$ids['paymentProcessor']) {
- CRM_Core_Error::debug_log_message("Payment processor could not be retrieved.");
- // There is no point in going further. Return ack so we don't receive the same ipn.
- $response->SendAck($serial);
- }
-
- return array($isTest, $input['component'], $ids['paymentProcessor']);
- }
-
- /**
- * This method is handles the response that will be invoked (from extern/googleNotify) every time
- * a notification or request is sent by the Google Server.
- *
- * @param string $xml_response
- */
- public static function main($xml_response) {
- require_once 'Google/library/googleresponse.php';
- require_once 'Google/library/googlerequest.php';
- require_once 'Google/library/googlemerchantcalculations.php';
- require_once 'Google/library/googleresult.php';
- require_once 'Google/library/xml-processing/gc_xmlparser.php';
-
- $config = CRM_Core_Config::singleton();
-
- // Retrieve the XML sent in the HTTP POST request to the ResponseHandler
- if (get_magic_quotes_gpc()) {
- $xml_response = stripslashes($xml_response);
- }
-
- $headers = CRM_Utils_System::getAllHeaders();
-
- if (GOOGLE_DEBUG_PP) {
- CRM_Core_Error::debug_var('RESPONSE', $xml_response, TRUE, TRUE, 'Google');
- }
-
- // Retrieve the root and data from the xml response
- $response = new GoogleResponse();
- list($root, $data) = $response->GetParsedXML($xml_response);
- // lets retrieve the private-data & order-no
- $privateData = NULL;
- if (array_key_exists('shopping-cart', $data[$root])) {
- $privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE'];
- }
- if (empty($privateData) && array_key_exists('order-summary', $data[$root])
- && array_key_exists('shopping-cart', $data[$root]['order-summary'])
- ) {
- $privateData = $data[$root]['order-summary']['shopping-cart']['merchant-private-data']['VALUE'];
- }
- $privateData = $privateData ? self::stringToArray($privateData) : '';
- $orderNo = $data[$root]['google-order-number']['VALUE'];
- $serial = $data[$root]['serial-number'];
-
- // a dummy object to call get context and a parent function inside it.
- $ipn = new CRM_Core_Payment_GoogleIPN('live', $dummyProcessor);
- list($mode, $module, $paymentProcessorID) = $ipn->getContext($privateData, $orderNo, $root, $response, $serial);
- $mode = $mode ? 'test' : 'live';
-
- $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);
- $merchant_id = $paymentProcessor['user_name'];
- $merchant_key = $paymentProcessor['password'];
- $response->SetMerchantAuthentication($merchant_id, $merchant_key);
-
- $server_type = ($mode == 'test') ? 'sandbox' : 'production';
- $request = new GoogleRequest($merchant_id, $merchant_key, $server_type);
-
- $ipn = self::singleton($mode, $module, $paymentProcessor);
-
- if (GOOGLE_DEBUG_PP) {
- CRM_Core_Error::debug_var('RESPONSE-ROOT', $response->root, TRUE, TRUE, 'Google');
- }
-
- //Check status and take appropriate action
- $status = $response->HttpAuthentication($headers);
-
- switch ($root) {
- case "request-received":
- case "error":
- case "diagnosis":
- case "checkout-redirect":
- case "merchant-calculation-callback":
- break;
-
- case "new-order-notification":
- $response->SendAck($serial, FALSE);
- $ipn->newOrderNotify($data[$root], $privateData, $module);
- break;
-
- case "order-state-change-notification":
- $response->SendAck($serial, FALSE);
- $new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
- $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
-
- switch ($new_financial_state) {
- case 'CHARGEABLE':
- break;
-
- case 'CHARGED':
- case 'PAYMENT_DECLINED':
- case 'CANCELLED':
- case 'CANCELLED_BY_GOOGLE':
- $ipn->orderStateChange($new_financial_state, $data[$root], $privateData, $module);
- break;
-
- case 'REVIEWING':
- case 'CHARGING':
- break;
-
- default:
- break;
- }
- break;
-
- case "authorization-amount-notification":
- $response->SendAck($serial, FALSE);
- $new_financial_state = $data[$root]['order-summary']['financial-order-state']['VALUE'];
- $new_fulfillment_order = $data[$root]['order-summary']['fulfillment-order-state']['VALUE'];
-
- switch ($new_financial_state) {
- case 'CHARGEABLE':
- // For google-handled subscriptions chargeorder needn't be initiated,
- // assuming auto-charging is turned on.
- //$request->SendProcessOrder($data[$root]['google-order-number']['VALUE']);
- //$request->SendChargeOrder($data[$root]['google-order-number']['VALUE'],'');
- break;
-
- case 'CHARGED':
- case 'PAYMENT_DECLINED':
- case 'CANCELLED':
- break;
-
- case 'REVIEWING':
- case 'CHARGING':
- case 'CANCELLED_BY_GOOGLE':
- break;
-
- default:
- break;
- }
- break;
-
- case "charge-amount-notification":
- case "chargeback-amount-notification":
- case "refund-amount-notification":
- case "risk-information-notification":
- $response->SendAck($serial);
- break;
-
- default:
- break;
- }
- }
-
- /**
- * @param $input
- * @param $ids
- * @param $dataRoot
- *
- * @return bool
- */
- public function getInput(&$input, &$ids, $dataRoot) {
- if (!$this->getBillingID($ids)) {
- return FALSE;
- }
-
- $billingID = $ids['billing'];
- $lookup = array(
- "first_name" => 'contact-name',
- // "last-name" not available with google (every thing in contact-name)
- "last_name" => 'last_name',
- "street_address-{$billingID}" => 'address1',
- "city-{$billingID}" => 'city',
- "state-{$billingID}" => 'region',
- "postal_code-{$billingID}" => 'postal-code',
- "country-{$billingID}" => 'country-code',
- );
-
- foreach ($lookup as $name => $googleName) {
- if (array_key_exists($googleName, $dataRoot['buyer-billing-address'])) {
- $value = $dataRoot['buyer-billing-address'][$googleName]['VALUE'];
- }
- $input[$name] = $value ? $value : NULL;
- }
- return TRUE;
- }
-
- /**
- * Converts the comma separated name-value pairs in <merchant-private-data>
- * to an array of name-value pairs.
- *
- * @param string $str
- *
- * @return array
- */
- public static function stringToArray($str) {
- $vars = $labels = array();
- $labels = explode(',', $str);
- foreach ($labels as $label) {
- $terms = explode('=', $label);
- $vars[$terms[0]] = $terms[1];
- }
- return $vars;
- }
-
-}
//consider total amount.
$this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE);
- // @todo this needs to GO! We are getting rid of references to processor types in the code base in favour of
- // over-ride-able functions on them.
- // The processor effectively has a 'buildForm' hook it can use if it needs to.
- // The tricky thing is that we have no way of testing this code out - perhaps it hasn't worked for years!
- if ($this->_paymentProcessor['payment_processor_type'] == 'Google_Checkout' && empty($this->_params[0]['is_pay_later']) && !($this->_params[0]['amount'] == 0) &&
- !$this->_allowWaitlist && !$this->_requireApproval
- ) {
- $this->_checkoutButtonName = $this->getButtonName('next', 'checkout');
- $this->add('image',
- $this->_checkoutButtonName,
- $this->_paymentProcessor['url_button'],
- array('class' => 'crm-form-submit')
- );
-
- $this->addButtons(array(
- array(
- 'type' => 'back',
- 'name' => ts('Go Back'),
- ),
- )
- );
- }
- else {
- $contribButton = ts('Continue');
- $this->addButtons(array(
- array(
- 'type' => 'back',
- 'name' => ts('Go Back'),
- ),
- array(
- 'type' => 'next',
- 'name' => $contribButton,
- 'isDefault' => TRUE,
- 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
- ),
- )
- );
- }
+ $contribButton = ts('Continue');
+ $this->addButtons(array(
+ array(
+ 'type' => 'back',
+ 'name' => ts('Go Back'),
+ ),
+ array(
+ 'type' => 'next',
+ 'name' => $contribButton,
+ 'isDefault' => TRUE,
+ 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
+ ),
+ )
+ );
$defaults = array();
$fields = array();
),
);
- static $_googleParamsMapper = array(
- //category => array(google_param => civicrm_field);
- 'contact' => array(
- 'first-name' => 'first_name',
- 'last-name' => 'last_name',
- 'contact-name' => 'display_name',
- 'email' => 'email',
- ),
- 'location' => array(
- 'address1' => 'street_address',
- 'address2' => 'supplemental_address_1',
- 'city' => 'city',
- 'postal-code' => 'postal_code',
- 'country-code' => 'country',
- ),
- 'transaction' => array(
- 'total-charge-amount' => 'total_amount',
- 'google-order-number' => 'trxn_id',
- 'currency' => 'currency',
- 'item-name' => 'source',
- 'item-description' => 'note',
- 'timestamp' => 'receive_date',
- 'latest-charge-fee' => 'fee_amount',
- 'net-amount' => 'net_amount',
- 'times' => 'installments',
- 'period' => 'frequency_unit',
- 'frequency_interval' => 'frequency_interval',
- 'start_date' => 'start_date',
- 'modified_date' => 'modified_date',
- 'trxn_type' => 'trxn_type',
- 'amount' => 'amount',
- ),
- );
-
static $_csvParamsMapper = array(
// Note: if csv header is not present in the mapper, header itself
// is considered as a civicrm field.
} while ($result['l_errorcode0'] == '11002');
}
- /**
- * @param $paymentProcessor
- * @param $paymentMode
- * @param $start
- * @param $end
- */
- public static function google($paymentProcessor, $paymentMode, $start, $end) {
- require_once "CRM/Contribute/BAO/Contribution/Utils.php";
- require_once 'CRM/Core/Payment/Google.php';
- $nextPageToken = TRUE;
- $searchParams = array(
- 'start' => $start,
- 'end' => $end,
- 'notification-types' => array('charge-amount'),
- );
-
- $response = CRM_Core_Payment_Google::invokeAPI($paymentProcessor, $searchParams);
-
- while ($nextPageToken) {
- if ($response[0] == 'error') {
- CRM_Core_Error::debug_log_message("GOOGLE ERROR: " .
- $response[1]['error']['error-message']['VALUE'], TRUE
- );
- }
- $nextPageToken = isset($response[1][$response[0]]['next-page-token']['VALUE']) ? $response[1][$response[0]]['next-page-token']['VALUE'] : FALSE;
-
- if (is_array($response[1][$response[0]]['notifications']['charge-amount-notification'])) {
-
- if (array_key_exists('google-order-number',
- $response[1][$response[0]]['notifications']['charge-amount-notification']
- )) {
- // sometimes 'charge-amount-notification' itself is an absolute
- // array and not array of arrays. This is the case when there is only one
- // charge-amount-notification. Hack for this special case -
- $chrgAmt = $response[1][$response[0]]['notifications']['charge-amount-notification'];
- unset($response[1][$response[0]]['notifications']['charge-amount-notification']);
- $response[1][$response[0]]['notifications']['charge-amount-notification'][] = $chrgAmt;
- }
-
- foreach ($response[1][$response[0]]['notifications']['charge-amount-notification'] as $amtData) {
- $searchParams = array(
- 'order-numbers' => array($amtData['google-order-number']['VALUE']),
- 'notification-types' => array('risk-information', 'new-order', 'charge-amount'),
- );
- $response = CRM_Core_Payment_Google::invokeAPI($paymentProcessor,
- $searchParams
- );
- // append amount information as well
- $response[] = $amtData;
-
- $params = self::formatAPIParams($response,
- self::$_googleParamsMapper,
- 'google'
- );
- if ($paymentMode == 'test') {
- $params['transaction']['is_test'] = 1;
- }
- else {
- $params['transaction']['is_test'] = 0;
- }
- if (self::processAPIContribution($params)) {
- CRM_Core_Error::debug_log_message("Processed - {$params['email']}, {$amtData['total-charge-amount']['VALUE']}, {$amtData['google-order-number']['VALUE']} ..<p>", TRUE);
- }
- else {
- CRM_Core_Error::debug_log_message("Skipped - {$params['email']}, {$amtData['total-charge-amount']['VALUE']}, {$amtData['google-order-number']['VALUE']} ..<p>", TRUE);
- }
- }
-
- if ($nextPageToken) {
- $searchParams = array('next-page-token' => $nextPageToken);
- $response = CRM_Core_Payment_Google::invokeAPI($paymentProcessor, $searchParams);
- }
- }
- }
- }
-
public static function csv() {
$csvFile = '/home/deepak/Desktop/crm-4247.csv';
$delimiter = ";";
switch ($type) {
case 'paypal':
- case 'google':
$start = CRM_Utils_Request::retrieve('start', 'String',
CRM_Core_DAO::$_nullObject, FALSE, 31, 'REQUEST'
);
if (!in_array($type, array(
'paypal',
- 'google',
'csv',
))
) {
return $params;
}
- if ($type == 'google') {
- // return if response smell invalid
- if (!array_key_exists('risk-information-notification', $apiParams[1][$apiParams[0]]['notifications'])) {
- return FALSE;
- }
- $riskInfo = &$apiParams[1][$apiParams[0]]['notifications']['risk-information-notification'];
-
- if (array_key_exists('new-order-notification', $apiParams[1][$apiParams[0]]['notifications'])) {
- $newOrder = &$apiParams[1][$apiParams[0]]['notifications']['new-order-notification'];
- }
-
- if ($riskInfo['google-order-number']['VALUE'] == $apiParams[2]['google-order-number']['VALUE']) {
- foreach ($riskInfo['risk-information']['billing-address'] as $field => $info) {
- if (!empty($mapper['location'][$field])) {
- $params['address'][1][$mapper['location'][$field]] = $info['VALUE'];
- }
- elseif (!empty($mapper['contact'][$field])) {
- if ($newOrder && !empty($newOrder['buyer-billing-address']['structured-name'])) {
- foreach ($newOrder['buyer-billing-address']['structured-name'] as $namePart => $nameValue) {
- $params[$mapper['contact'][$namePart]] = $nameValue['VALUE'];
- }
- }
- else {
- $params[$mapper['contact'][$field]] = $info['VALUE'];
- }
- }
- elseif (!empty($mapper['transaction'][$field])) {
- $transaction[$mapper['transaction'][$field]] = $info['VALUE'];
- }
- }
-
- // Response is an huge array. Lets pickup only those which we ineterested in
- // using a local mapper, rather than traversing the entire array.
- $localMapper = array(
- 'google-order-number' => $riskInfo['google-order-number']['VALUE'],
- 'total-charge-amount' => $apiParams[2]['total-charge-amount']['VALUE'],
- 'currency' => $apiParams[2]['total-charge-amount']['currency'],
- 'item-name' => $newOrder['shopping-cart']['items']['item']['item-name']['VALUE'],
- 'timestamp' => $apiParams[2]['timestamp']['VALUE'],
- );
- if (array_key_exists('latest-charge-fee', $apiParams[2])) {
- $localMapper['latest-charge-fee'] = $apiParams[2]['latest-charge-fee']['total']['VALUE'];
- $localMapper['net-amount'] = $localMapper['total-charge-amount'] - $localMapper['latest-charge-fee'];
- }
-
- // This is a subscription (recurring) donation.
- if (array_key_exists('subscription', $newOrder['shopping-cart']['items']['item'])) {
- $subscription = $newOrder['shopping-cart']['items']['item']['subscription'];
- $localMapper['amount'] = $newOrder['order-total']['VALUE'];
- $localMapper['times'] = $subscription['payments']['subscription-payment']['times'];
- // Convert Google's period to one compatible with the CiviCRM db field.
- $freqUnits = array(
- 'DAILY' => 'day',
- 'WEEKLY' => 'week',
- 'MONHTLY' => 'month',
- 'YEARLY' => 'year',
- );
- $localMapper['period'] = $freqUnits[$subscription['period']];
- // Unlike PayPal, Google has no concept of freq. interval, it is always 1.
- $localMapper['frequency_interval'] = '1';
- // Google Checkout dates are in ISO-8601 format. We need a format that
- // MySQL likes
- $unix_timestamp = strtotime($localMapper['timestamp']);
- $mysql_date = date('YmdHis', $unix_timestamp);
- $localMapper['modified_date'] = $mysql_date;
- $localMapper['start_date'] = $mysql_date;
- // This is PayPal's nomenclature, but just use it for Google as well since
- // we act on the value of trxn_type in processAPIContribution().
- $localMapper['trxn_type'] = 'subscrpayment';
- }
-
- foreach ($localMapper as $localKey => $localVal) {
- if (!empty($mapper['transaction'][$localKey])) {
- $transaction[$mapper['transaction'][$localKey]] = $localVal;
- }
- }
-
- if (empty($params) && empty($transaction)) {
- continue;
- }
-
- if (!empty($transaction) && $category) {
- $params['transaction'] = $transaction;
- }
- else {
- $params += $transaction;
- }
-
- CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams($params, $type);
- }
- return $params;
- }
}
/**
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- */
-
-if (defined('PANTHEON_ENVIRONMENT')) {
- ini_set('session.save_handler', 'files');
-}
-session_start();
-
-require_once '../civicrm.config.php';
-
-$config = CRM_Core_Config::singleton();
-$log = new CRM_Utils_SystemLogger();
-$log->alert('payment_notification processor_name=Google_Checkout', $_REQUEST);
-
-$rawPostData = file_get_contents('php://input');
-CRM_Core_Payment_GoogleIPN::main($rawPostData);
<p>{ts}The Recurring Payments URL is not currently used.{/ts}</p>
{/htxt}
-{htxt id='Google_Checkout-live-user-name'}
-<p>{ts}Enter the Merchant ID from your Live account.{/ts}</p>
-<p><strong>{ts}How do I Find my Merchant-ID?{/ts}</strong></p>
-<p>{ts}After signing in to your account, click on the Settings tab. Then click on the Integration link on the left side of the page. Your 10- or 15-digit Merchant ID and your Merchant Key will both be listed under the Account information header.{/ts}</p>
-{/htxt}
-{htxt id='Google_Checkout-live-password'}
-<p>{ts}Enter the Merchant Key from your Live account.{/ts}</p>
-<p><strong>{ts}How do I Find my Merchant Key?{/ts}</strong></p>
-<p>{ts}After signing in to your account, click on the Settings tab. Then click on the Integration link on the left side of the page. Your 10- or 15-digit Merchant ID and your Merchant Key will both be listed under the Account information header.{/ts}</p>
-{/htxt}
-{htxt id='Google_Checkout-test-user-name'}
-<p>{ts}Enter the Merchant ID from your Sandbox account.{/ts}</p>
-<p><strong>{ts}How do I Find my Merchant-ID?{/ts}</strong></p>
-<p>{ts}After signing in to your account, click on the Settings tab. Then click on the Integration link on the left side of the page. Your 10- or 15-digit Merchant ID and your Merchant Key will both be listed under the Account information header.{/ts}</p>
-{/htxt}
-{htxt id='Google_Checkout-test-password'}
-<p>{ts}Enter the Merchant Key from your Sandbox account.{/ts}</p>
-<p><strong>{ts}How do I Find my Merchant Key?{/ts}</strong></p>
-<p>{ts}After signing in to your account, click on the Settings tab. Then click on the Integration link on the left side of the page. Your 10- or 15-digit Merchant ID and your Merchant Key will both be listed under the Account information header.{/ts}</p>
-{/htxt}
-{htxt id='Google_Checkout-test-url-site'}
-{ts}The URL for Google Checkout's TEST Payment server. Use the default value unless otherwise indicated by Google.{/ts}
-{/htxt}
-{htxt id='Google_Checkout-live-url-site'}
-{ts}The URL for Google Checkout's LIVE Payment server. Use the default value unless otherwise indicated by Google.{/ts}
-{/htxt}
-{htxt id='Google_Checkout-test-url-button'}
-<p>{ts 1=http://sandbox.google.com/checkout/buttons/checkout.gif}The base URL for the <strong>TEST - Image</strong> is: %1{/ts}</p>
-<p>{ts}To display an image, you must add several parameters to this URL as name=value pairs.{/ts}</p>
-<table>
-<tr><th>{ts}Parameters{/ts}</th><th>{ts}Values{/ts}</th><th>{ts}Description{/ts}</th></tr>
-<tr>
- <td>w</td>
- <td>180/168/160 ({ts}large/medium/small{/ts})</td>
- <td>{ts}width of the button in pixels{/ts}</td>
-</tr>
-<tr>
- <td>h</td>
- <td>46/44/43 ({ts}large/medium/small{/ts})</td>
- <td>{ts}height of the button in pixels{/ts}</td>
-</tr>
-<tr>
- <td>style</td>
- <td>white/trans..</td>
- <td>{ts}background color for the button{/ts}</td>
-</tr>
-<tr>
- <td>variant</td>
- <td>text/disabled</td>
- <td>{ts}whether the button is clickable or disabled{/ts}</td>
-</tr>
-<tr>
- <td>loc</td>
- <td>en_US</td>
- <td>{ts}a locale associated with the transaction (optional){/ts}</td>
-</tr>
-<tr>
- <td>merchant_id</td>
- <td>{ts 1=1234567890}(e.g %1){/ts}</td>
- <td>{ts}Merchant ID{/ts}</td>
-</tr>
-</table>
-
-<p><strong>{ts}Example of a large Google Checkout button on a white background (For TEST Account):{/ts}</strong></p>
-<p>http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=1234567890&w=180&h=46&style=white&variant=text&loc=en_US</p>
-{/htxt}
-
-{htxt id='Google_Checkout-live-url-button'}
-<p>{ts 1=http://checkout.google.com/buttons/checkout.gif}The base URL for the <strong>LIVE - Image</strong> is: %1{/ts}</p>
-<p>{ts}To display an image, you must add several parameters to this URL as name=value pairs.{/ts}</p>
-<table>
-<tr><th>{ts}Parameters{/ts}</th><th>{ts}Values{/ts}</th><th>{ts}Description{/ts}</th></tr>
-<tr>
- <td>w</td>
- <td>180/168/160 ({ts}large/medium/small{/ts})</td>
- <td>{ts}width of the button in pixels{/ts}</td>
-</tr>
-<tr>
- <td>h</td>
- <td>46/44/43 ({ts}large/medium/small{/ts})</td>
- <td>{ts}height of the button in pixels{/ts}</td>
-</tr>
-<tr>
- <td>style</td>
- <td>white/trans..</td>
- <td>{ts}background color for the button{/ts}</td>
-</tr>
-<tr>
- <td>variant</td>
- <td>text/disabled</td>
- <td>{ts}whether the button is clickable or disabled{/ts}</td>
-</tr>
-<tr>
- <td>loc</td>
- <td>en_US</td>
- <td>{ts}a locale associated with the transaction (optional){/ts}</td>
-</tr>
-<tr>
- <td>merchant_id</td>
- <td>{ts 1=1234567890}(e.g %1){/ts}</td>
- <td>{ts}Merchant ID{/ts}</td>
-</tr>
-</table>
-<p><strong>{ts}Example of a large Google Checkout button on a white background (For LIVE Account):{/ts}</strong></p>
-<p>http://checkout.google.com/buttons/checkout.gif?merchant_id=1234567890&w=180&h=46&style=white&variant=text&loc=en_US</p>
-{/htxt}
-
{htxt id='Dummy-live-user-name'}
{ts}Set up a 'Dummy' Processor if you want to test Online Contribution pages or Event Registration pages prior to selecting and configuring a real payment processor. You can enter any values for User Name and Site URL.{/ts}</p>
{/htxt}
<div class="help">
<p>{ts}Please verify the information below carefully. Click <strong>Go Back</strong> if you need to make changes.{/ts}
{if $contributeMode EQ 'notify' and ! $is_pay_later}
- {if $paymentProcessor.payment_processor_type EQ 'Google_Checkout'}
- {ts}Click the <strong>Google Checkout</strong> button to checkout to Google, where you will select your payment method and complete the contribution.{/ts}
- {else}
- {ts 1=$paymentProcessor.name 2=$button}Click the <strong>%2</strong> button to go to %1, where you will select your payment method and complete the contribution.{/ts}
- {/if}
+ {ts 1=$paymentProcessor.name 2=$button}Click the <strong>%2</strong> button to go to %1, where you will select your payment method and complete the contribution.{/ts}
{elseif ! $is_monetary or $amount LE 0.0 or $is_pay_later}
{ts 1=$button}To complete this transaction, click the <strong>%1</strong> button below.{/ts}
{else}
</div>
{/if}
- {if $paymentProcessor.payment_processor_type EQ 'Google_Checkout' and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) and ! $is_pay_later}
- <fieldset class="crm-group google_checkout-group"><legend>{ts}Checkout with Google{/ts}</legend>
- <table class="form-layout-compressed">
- <tr>
- <td class="description">{ts}Click the Google Checkout button to continue.{/ts}</td>
- </tr>
- <tr>
- <td>{$form._qf_Confirm_next_checkout.html} <span style="font-size:11px; font-family: Arial, Verdana;">{ts}Checkout securely. Pay without sharing your financial information.{/ts}</span></td>
- </tr>
- </table>
- </fieldset>
- {/if}
-
<div id="crm-submit-buttons" class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
</div>
{/if}
- {if $paymentProcessor.payment_processor_type EQ 'Google_Checkout' and $paidEvent and !$is_pay_later and ! $isAmountzero and !$isOnWaitlist and !$isRequireApproval}
- <fieldset><legend>{ts}Checkout with Google{/ts}</legend>
- <div class="crm-section google_checkout-section">
- <table class="form-layout-compressed">
- <tr>
- <td class="description">{ts}Click the Google Checkout button to continue.{/ts}</td>
- </tr>
- <tr>
- <td>{$form._qf_Confirm_next_checkout.html} <span style="font-size:11px; font-family: Arial, Verdana;">{ts}Checkout securely. Pay without sharing your financial information.{/ts}</span></td>
- </tr>
- </table>
- </div>
- </fieldset>
- {/if}
-
<div id="crm-submit-buttons" class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
<p>{ts}With this configuration, the membership fee is automatically charged, and users have an option to make an additional contribution (two separate payment transactions will be generated).{/ts}</p>
<p>{ts}The contribution amount covering the membership fee will use the financial type configured with the selected membership type (see the membership types configuration tool to review those settings). Any additional contribution will use the financial type configured for this online contribution page.{/ts}</p>
<p>{ts}If this option is NOT checked and you include a Contribution Amount section, then a single transaction is processed for their contribution amount which must at least cover the selected membership fee.{/ts}</p>
-<p><strong>{ts}NOTE: This option is NOT available for PayPal Website Payments Standard and Google Checkout.{/ts}</strong></p>
{/htxt}
{htxt id="id-display-fee-title"}
'test_password' => '7ARxW575w736eF5p',
);
}
- elseif ($processorType == 'Google_Checkout') {
- // FIXME: we 'll need to make a new separate account for testing
- $processorSettings = array(
- 'user_name' => '559999327053114',
- 'password' => 'R2zv2g60-A7GXKJYl0nR0g',
- );
- }
elseif ($processorType == 'PayPal') {
$processorSettings = array(
'test_user_name' => '559999327053114',
$contributionPageTitle = "Verify SSL ($hash)";
$this->names['PayPal'] = "PayPal Pro ($hash)";
$this->names['AuthNet'] = "AuthNet ($hash)";
- //$this->names['Google_Checkout'] = "Google Checkout ($hash)";
//$this->names['PayPal_Standard'] = "PayPal Standard ($hash)";
$processors = array();
$this->click("_qf_Confirm_next_checkout");
- // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
-
- // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
}
public function testOnlineAutoRenewMembershipAuthenticated() {
$this->click("_qf_Confirm_next_checkout");
- // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
-
- // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
- }
-
- /**
- * @return null
- */
- public function _configureMembershipPage() {
- static $pageId = NULL;
-
- if (!$pageId) {
- $this->webtestLogin();
-
- //add payment processor.
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $processorName = "Webtest Auto Renew Google Checkout" . $hash;
- $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout');
-
- // -- start updating membership types
- $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=1&reset=1');
-
- $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
- $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
-
- $this->type("duration_interval", "1");
- $this->select("duration_unit", "label=year");
-
- $this->click("_qf_MembershipType_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=2&reset=1');
-
- $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
- $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
-
- $this->type("duration_interval", "1");
- $this->select("duration_unit", "label=year");
-
- $this->click("_qf_MembershipType_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // create contribution page with randomized title and default params
- $amountSection = FALSE;
- $payLater = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = TRUE;
- $membershipTypes = array(
- array('id' => 1, 'auto_renew' => 1),
- array('id' => 2, 'auto_renew' => 1),
- );
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = TRUE;
- $widget = TRUE;
- $pcp = TRUE;
-
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'Google_Checkout'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $membershipTypes,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- FALSE
- );
-
- //make sure we do have required permissions.
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- // now logout and do membership test that way
- $this->webtestLogout();
- }
-
- return $pageId;
}
}
('PayPal_Standard', '{ts escape="sql"}PayPal - Website Payments Standard{/ts}', NULL,1,0,'{ts escape="sql"}Merchant Account Email{/ts}',NULL,NULL,NULL,'Payment_PayPalImpl','https://www.paypal.com/',NULL,'https://www.paypal.com/',NULL,'https://www.sandbox.paypal.com/',NULL,'https://www.sandbox.paypal.com/',NULL,4,1),
('PayPal', '{ts escape="sql"}PayPal - Website Payments Pro{/ts}', NULL,1,0,'{ts escape="sql"}User Name{/ts}','{ts escape="sql"}Password{/ts}','{ts escape="sql"}Signature{/ts}',NULL,'Payment_PayPalImpl','https://www.paypal.com/','https://api-3t.paypal.com/','https://www.paypal.com/','https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif','https://www.sandbox.paypal.com/','https://api-3t.sandbox.paypal.com/','https://www.sandbox.paypal.com/','https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',3, 1 ),
('PayPal_Express', '{ts escape="sql"}PayPal - Express{/ts}', NULL,1,0,'{ts escape="sql"}User Name{/ts}','{ts escape="sql"}Password{/ts}','{ts escape="sql"}Signature{/ts}',NULL,'Payment_PayPalImpl','https://www.paypal.com/','https://api-3t.paypal.com/',NULL,'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif','https://www.sandbox.paypal.com/','https://api-3t.sandbox.paypal.com/',NULL,'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',2, 1),
- ('Google_Checkout', '{ts escape="sql"}Google Checkout{/ts}', NULL,1,0,'{ts escape="sql"}Merchant ID{/ts}','{ts escape="sql"}Key{/ts}',NULL,NULL,'Payment_Google','https://checkout.google.com/',NULL,'https://checkout.google.com/','https://checkout.google.com/buttons/checkout.gif?merchant_id=YOURMERCHANTIDHERE&w=160&h=43&style=white&variant=text&loc=en_US','https://sandbox.google.com/checkout/',NULL,'https://sandbox.google.com/checkout/','https://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=YOURMERCHANTIDHERE&w=160&h=43&style=white&variant=text&loc=en_US',4,1),
('AuthNet', '{ts escape="sql"}Authorize.Net{/ts}', NULL,1,0,'{ts escape="sql"}API Login{/ts}','{ts escape="sql"}Payment Key{/ts}','{ts escape="sql"}MD5 Hash{/ts}',NULL,'Payment_AuthorizeNet','https://secure2.authorize.net/gateway/transact.dll',NULL,'https://api2.authorize.net/xml/v1/request.api',NULL,'https://test.authorize.net/gateway/transact.dll',NULL,'https://apitest.authorize.net/xml/v1/request.api',NULL,1,1),
('PayJunction', '{ts escape="sql"}PayJunction{/ts}', NULL,1,0,'User Name','Password',NULL,NULL,'Payment_PayJunction','https://payjunction.com/quick_link',NULL,NULL,NULL,'https://www.payjunctionlabs.com/quick_link',NULL,NULL,NULL,1,1),
('eWAY', '{ts escape="sql"}eWAY (Single Currency){/ts}', NULL,1,0,'Customer ID',NULL,NULL,NULL,'Payment_eWAY','https://www.eway.com.au/gateway_cvn/xmlpayment.asp',NULL,NULL,NULL,'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp',NULL,NULL,NULL,1,0),