function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Charlie CoxCharlie Cox 

TestMethod do not support Web service callouts Help

This is my test class:

@isTest(seeAllData = true)
public with sharing class NUBSCartControllerTest{
    static testMethod void NUBSCartControllerTestMethod() {
       Contact c = new Contact();
       c.firstName = 'Charles';
       c.lastName = 'Cox'; = '';
       insert c;
       Event_Registration__c er = new Event_Registration__c (); = 'CharlesConference';
       er.hasPaid__c = false;
       er.Applicant_Name__c =;
       insert er;
       Id stnd = Test.getStandardPricebookId();
       Product2 p = new Product2(); = 'Thursday, March 26, Opening Reception';
       insert p;
       ConProd_Bridge__c cpb = new ConProd_Bridge__c();
       cpb.Product__c =;
       cpb.Contact__c =;
       insert cpb;
       PricebookEntry pbe= new PricebookEntry();
       pbe.Product2Id = p.Id;
       pbe.unitPrice = 30;
       pbe.Pricebook2Id = stnd;
       pbe.isActive = true;
       insert pbe;
       Opportunity o = new Opportunity();
       o.Name = 'thisOpp';
       o.Amount = 30;
       o.stageName = 'Prospecting';
       o.closeDate = Date.TODAY().addYears(1);
       o.Contact__c =;
       insert o;
       OpportunityLineItem ole = new OpportunityLineItem();
       ole.UnitPrice = 30;
       ole.OpportunityId =;
       ole.PriceBookEntryId =;
       ole.Quantity = 1;
       insert ole;
       Test.setCurrentPageReference(new PageReference('Page.myPage'));
       System.currentPageReference().getParameters().put('isConference', 'true');
       NUBSCartController contr = new NUBSCartController();
       contr.BillingFirst = 'Charles';
       contr.BillingLast = 'Cox';
       contr.BillingAddress = '26 West';
       contr.BillingCity = 'Austin';
       contr.BillingState = 'Texas';
       contr.BillingCountry  = 'United States';
       contr.BillingPostcode = '78681';
       contr.CardType = 'Visa';
       contr.CardNumber = '4111111111111111';
       contr.CardMonth = '12';
       contr.CardYear = '2038';
       contr.CardSecurity = '123';
       contr.isConference = 'false';

I get the error 'TestMethod do not support Web service callouts' when I run the test with seeAlldata = true but not when seeAllData = false. I need to have seeAllData = true so I need to figure this error out. I don't see where I am using a web service call...

Any help would be great,

Are you doing a webservice callout from your NUBSCartController , if so you need to do check if the code triggering the callout is from the actual class or test class 

Take a look at this post of Salesforce StackExchange :
Charlie CoxCharlie Cox
I do not think I am doing a webservice call though. Here is my class. I left off the send emails method because it was too long. It just sends emails out based on the Contacts ID, which is not a webservice call.

public class NUBSCartController {

    public String oppid {get;set;}
    public String isConference {get;set;}
    public list<Integer> tableSkew {get;set;}
    public Event_Registration__c application {get;set;}
    public String sponserName {get;set;}
    public String sponserEmail {get;set;}
    public Opportunity opp {get;set;}
    public Student_Application__c app {get;set;}
    public Boolean showConfirm {get;set;}
    public Boolean showThankYou {get;set;}
    public String BillingFirst {get;set;}
    public String BillingLast {get;set;}
    public String BillingAddress {get;set;}
    public String BillingCity {get;set;}
    public String BillingState {get;set;}
    public String BillingCountry {get;set;}
    public String BillingPostcode {get;set;}
    public String CardType {get;set;}
    public String CardNumber {get;set;}
    public String CardMonth {get;set;}
    public String CardYear {get;set;}
    public String CardSecurity {get;set;}
    public list<SelectOption> CardTypeList {get;set;}
    public list<SelectOption> CardMonthList {get;set;}
    public list<SelectOption> CardYearList {get;set;}
    public list<OpportunityLineItem> oli {get;set;}
    public NUBSCartController() {
        oppid = ApexPages.currentPage().getParameters().get('oppId');
        isConference = ApexPages.currentPage().getParameters().get('isConference');
        opp = [SELECT o.Amount,, o.contact__c, FROM Opportunity o WHERE =: oppid];
        if(isConference == 'true') {
            application = [SELECT name, id, hasPaid__c, Applicant_Name__c FROM Event_Registration__c WHERE Applicant_Name__c =: opp.contact__c AND name LIKE '%Conference%'];
            sponserName = 'Sabine Wimmer';
            sponserEmail= '';
        else if(isConference == 'false') {
            application = [SELECT name, id, hasPaid__c, Applicant_Name__c FROM Event_Registration__c WHERE Applicant_Name__c =: opp.contact__c AND name LIKE '%CareerServices%'];
            sponserName = 'Megan Fortson';
            sponserEmail = '';
        oli = [SELECT,,, o.unitprice FROM OpportunityLineItem o WHERE o.OpportunityId =:]; 
        showConfirm = false;
        showThankYou = false;
        tableSkew = new list<Integer>();
    public void populatePicklists() {
        list<Schema.PicklistEntry> ple; // Declare variable
        /* Instansiate picklists */
        CardTypeList = new list<SelectOption>();
        CardMonthList = new list<SelectOption>();
        CardYearList = new list<SelectOption>();
        /* Get values from chargent card type and add to card type picklist */
        ple = Opportunity.ChargentSFA__Card_Type__c.getDescribe().getPicklistValues();
        for (Schema.PicklistEntry p:ple) {
            CardTypeList.add(new SelectOption(p.getValue(), p.getValue()));
        /* Add values to expiration month picklist */
        CardMonthList.add(new SelectOption('01', '01'));
        CardMonthList.add(new SelectOption('02', '02'));
        CardMonthList.add(new SelectOption('03', '03'));
        CardMonthList.add(new SelectOption('04', '04'));
        CardMonthList.add(new SelectOption('05', '05'));
        CardMonthList.add(new SelectOption('06', '06'));
        CardMonthList.add(new SelectOption('07', '07'));
        CardMonthList.add(new SelectOption('08', '08'));
        CardMonthList.add(new SelectOption('09', '09'));
        CardMonthList.add(new SelectOption('10', '10'));
        CardMonthList.add(new SelectOption('11', '11'));
        CardMonthList.add(new SelectOption('12', '12'));
        /* Add 2014 + 50 more years to expiration year picklist */
        Integer startYear = System.TODAY().year();
        for (Integer i = 0; i < 50; i++) {
            CardYearList.add(new SelectOption(string.valueOf(startYear + i), string.valueOf(startYear + i)));
    public void preCharge() {
        showConfirm = true;
        assignVariables(); // Port over variables from page to opportunity fields
        update opp; // Save opportunity record
    public void cancel() {
        showConfirm = false;
    public PageReference printable() { 
        pageReference reRend = new PageReference('/apex/NUBSSummary?Oppid=' +;
        return reRend;
    public void processPayment() {
       application.hasPaid__c = true;      
       Contact c = [SELECT name, id, email, firstName FROM Contact WHERE id in (select o.contact__c from opportunity o where =: oppid)];
       ChargentSFA.TChargentOperations.TChargentResult result = ChargentSFA.TChargentOperations.ChargeOpportunity_Click(opp.Id);
        Opportunity opp2 = [SELECT Id, ChargentSFA__Balance_Due__c FROM Opportunity WHERE Id = :opp.Id];
        if (opp2.ChargentSFA__Balance_Due__c == 0) {       

            opp.StageName = 'Closed Won';
            update opp;
            showConfirm = false;
            showThankYou = true;            
            list<ConProd_Bridge__c> cpbs = [SELECT name, id, Status__c, Remaining_Payment__c, Product__c, Contact__c FROM ConProd_Bridge__c 
                                       WHERE Product__r.pertains_To__c = 'NUBS2015' AND ( LIKE '%Thursday, March 26, Opening Reception%' OR 
                              LIKE '%Thursday, March 26, Dinner with Keynote Speaker%' OR LIKE '%Friday, March 27, Lunch at the Alumni Center%'
                                       OR LIKE '%Friday, March 27, Closing Dinner at the Rattle Inn%') AND Contact__c =:];
            if(cpbs != null) {
                for(ConProd_Bridge__c cpb : cpbs) {
                    cpb.Remaining_Payment__c = 0;
                    cpb.Status__c = 'Paid';
            update cpbs;                           
            update application;
        } else {
            showConfirm = false;

            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'There was an error processing your payment. Make sure all fields are filled in correctly.'));
    public void assignVariables() {
        opp.ChargentSFA__Billing_First__c = BillingFirst;
        opp.ChargentSFA__Billing_Last__c = BillingLast;
        opp.ChargentSFA__Billing_Address__c = BillingAddress;
        opp.ChargentSFA__Billing_City__c = BillingCity;
        opp.ChargentSFA__Billing_State__c = BillingState;
        opp.ChargentSFA__Billing_Country__c = BillingCountry;
        opp.ChargentSFA__Billing_Postcode__c = BillingPostcode;
        opp.ChargentSFA__Card_Type__c = CardType;
        opp.ChargentSFA__Card_Number__c = CardNumber;
        opp.ChargentSFA__Card_Month__c = CardMonth;
        opp.ChargentSFA__Card_Year__c = CardYear;
        opp.ChargentSFA__Card_Security__c = CardSecurity;
        opp.ChargentSFA__Payment_Method__c = 'Credit Card';
Charlie try to debug when you run the test class, the only time this error could come up is when your controller / other classes reference by your controller is making a callout. If you look at the debug logs you should easily be able to search for "Callout" and see where the callout is happening.
Charlie CoxCharlie Cox
Thanks, I'll give it a go!
Charlie CoxCharlie Cox
I see this in my debug logs: 

FATAL_ERROR|System.TypeException: Methods defined as TestMethod do not support Web service callouts, test skipped (ChargentBase)

This however does not make sense because the Chargent package is already installed. My org has written other test classes using Chargent so I know it can be done.
Chidanand MChidanand M
Hey guys,

Anybody got the solution for this. Please update it.
Even i am facing the same problem. Its already more than 20 hours i spent on it.
Please update the solution.