• Mahesh Tandan 6
  • NEWBIE
  • 40 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
I have a visualforce page and a custom controller
vf page have a form and required fields and i'm validating it throught <apex:inputtext value="{!data}" required="true">

my question is do I need to validate it in my controller also?
like if
if(data == Null || data == ''){
   pexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'my error message'));
}
i'm really confused about it.

please help.


 
Hello Sr. developers

Can someone tell me how can I pass Id with visualforce page
I'm calling a visualforce page with constent source URL , I know I can choose the visualforce page but I want to pass the Id
below is my code

visualforce page
<apex:page standardController="Campaign" extensions="OnLoadController" action="{!open_Donation_Site}" />

Extension
 
public class OnLoadController {
    Site subdomain;
    public OnLoadController(apexPages.StandardController con){}
    public String open_Donation_Site(){
        subdomain = [SELECT Subdomain FROM Site limit 1];
        Organization apt = [SELECT InstanceName FROM Organization];
        return 'https://'+subdomain.Subdomain+'.'+apt.InstanceName+'.force.com/CampaignPayment?id=';
    }
}
Actully I'm creating a managed pack that's why I want to fetch dynamically site domain name from different orgs.

my button
User-added image

It's saving but when I click button it gives error that page not found, but if i remove {!Campaign.Id} it works

I want to give visualforce page name and then Campaign.Id
Hello guys

I have a custom checkbox field On Campaign object.
and a custom setting called ManageData__c with 4 fields.
While creating Campaign if this checkbox is checked I want to make sure custom setting ManageData__c 's fields are filled.

if ManageData__c 's fields is not filled then while creating campaign a form will appear where I can fill the ManageData__c's filleds

please help
thank you.
Hii developers.
I'm using google v2 captcha on my vf extensions class
Now problem is I'm not able to test the captcha

this is the extension coce
public class addContactExtension {

    @TestVisible private static String baseUrl = 'https://www.google.com/recaptcha/api/siteverify';//captcha API endpoint.
    @TestVisible private static String secret = '6LcaHdMAEqDE4TTL****';//captcha API secret key.

    public String sitekey { //Captcha site key
        get {
            return '6LcaHdMUAAAAAKNwNDoR0RD8SXffM3JlwBSGKy6p';//Here, use my site key.
        }set;
	}
    
    public String response  {
        get {
            return ApexPages.currentPage().getParameters().get('g-recaptcha-response');
        }set;
    }
    
   Public pageReference paymentSave(){

        String responseBody = makeRequest(baseUrl,'secret=' + secret +'&response='+ response);
        String success = getValueFromJson(responseBody, 'success');
        if(success.equalsIgnoreCase('true')) {
           //execute code.
         }
}

TestVisible private static String makeRequest(string url, string body) { //Captcha api request start here
        HttpResponse response = null;
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('POST');
        req.setBody (body);
        try{
            Http http = new Http();
            response = http.send(req);
            return response.getBody();
        }catch(System.Exception e) {
            //System.debug('ERROR: ' + e);
        }
        return '{"success":false}';
    }//Captcha api request Ends here


    public static string getValueFromJson ( String strJson, String field ) {
        JSONParser parser = JSON.createParser(strJson);
        while (parser.nextToken() != null){
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)) {
                if(parser.getText() == field){
                    // Get the value.
                    parser.nextToken();
                    return parser.getText();
                }
            }
        }
        return null;
    }

}
How to test this method .
Somebody please help

 
hi i'm here

please can somebody help me in test class

this is my extension
 
public class addContactExtension {

 public List<Id> getFileId() {
        List<Id> ListOfImagesIds= new List<Id>();//store files/images Ids
        for(ContentDocumentLink CDL : [Select ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN(select Id from Campaign where Id=:camId.id) order by ContentDocument.CreatedDate ASC]){
            ListOfImagesIds.add(CDL.ContentDocument.LatestPublishedVersionId);
            //System.debug('Total Id'+ ListOfImagesIds);
        }
        return ListOfImagesIds;
    }//dynamically Images Fetching from Files Ends here.

}



How can I test this method
I need help developers
I have json data that I need to parse

Structure is this

I only need bold array value


Please help
{
    "id": "5BS9022******",
    "intent": "CAPTURE",
    "purchase_units": [
        {
            "reference_id": "default",
            "amount": {
                "currency_code": "USD",
                "value": "10.00"
            },
            "payee": {
                "email_address": "Busyaccount@exmaple.com",
                "merchant_id": "ZJCWA********"
            },
            "soft_descriptor": "PAYPAL *JOHNDOESTES",
            "shipping": {
                "name": {
                    "full_name": "Buyer Name"
                },
                "address": {
                    "address_line_1": "Buyer address",
                    "admin_area_2": "",
                    "admin_area_1": "GA",
                    "postal_code": "123456",
                    "country_code": "US"
                }
            },
            "payments": {
                "captures": [
                    {
                        "id": "31349714C********",
                        "status": "COMPLETED",
                        "amount": {
                            "currency_code": "USD",
                            "value": "10.00"
                        },
                        "final_capture": true,
                        "seller_protection": {
                            "status": "ELIGIBLE",
                            "dispute_categories": [
                                "ITEM_NOT_RECEIVED",
                                "UNAUTHORIZED_TRANSACTION"
                            ]
                        },
                        "seller_receivable_breakdown": {
                            "gross_amount": {
                                "currency_code": "USD",
                                "value": "10.00"
                            },
                            "paypal_fee": {
                                "currency_code": "USD",
                                "value": "0.59"
                            },
                            "net_amount": {
                                "currency_code": "USD",
                                "value": "9.41"
                            }
                        },
                        "links": [
  
                        ],
                        "create_time": "2020-02-06T04:00:56Z",
                        "update_time": "2020-02-06T04:00:56Z"
                    }
                ]
            }
        }
    ],
    "payer": {
        "name": {
            "given_name": "buyer Name",
            "surname": "Name"
        },
        "email_address": "testbuyer@example.com",
        "payer_id": "A8******",
        "address": {
            "country_code": "US"
        }
    },
    "create_time": "2020-02-06T03:59:18Z",
    "update_time": "2020-02-06T04:00:56Z",
    "links": [

    ],
    "status": "COMPLETED"
}


 
I'm Integrating with paypal using paypal smart button
everything is wokring fine all I want to send Order Id to controller How can I do this please help me SOMEONE

my visualforce page
<apex:page showHeader="false" controller="paypal_Integration">
     <script
    src="https://www.paypal.com/sdk/js?client-id=AdxbSNjRgSjzd***"> // Required. Replace SB_CLIENT_ID with your sandbox client ID.
  </script>
    
      <div id="paypal-button-container"></div>

<script>
  paypal.Buttons({
    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '0.01'
          }
        }]
      });
    },
    onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
        alert('Transaction completed by ' + details.payer.name.given_name);

   //I want to send this to my controller

        alert('Order Id '+ data.orderID);




        });
      });
    }
  }).render('#paypal-button-container');
</script>
</apex:page>
all I want to send is data.orderId to my controller please help
 
Hello guys.
I'm typing to get paypal access token and paypal uses basic auth

how can I post Basic auth in salesforce callouts
do I need to put it in request.setHeader('username','sldkj88***');
or in body request.setBody('username','sldkj88***');
I have a visualforce page and a custom controller
vf page have a form and required fields and i'm validating it throught <apex:inputtext value="{!data}" required="true">

my question is do I need to validate it in my controller also?
like if
if(data == Null || data == ''){
   pexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'my error message'));
}
i'm really confused about it.

please help.


 
Hello Sr. developers

Can someone tell me how can I pass Id with visualforce page
I'm calling a visualforce page with constent source URL , I know I can choose the visualforce page but I want to pass the Id
below is my code

visualforce page
<apex:page standardController="Campaign" extensions="OnLoadController" action="{!open_Donation_Site}" />

Extension
 
public class OnLoadController {
    Site subdomain;
    public OnLoadController(apexPages.StandardController con){}
    public String open_Donation_Site(){
        subdomain = [SELECT Subdomain FROM Site limit 1];
        Organization apt = [SELECT InstanceName FROM Organization];
        return 'https://'+subdomain.Subdomain+'.'+apt.InstanceName+'.force.com/CampaignPayment?id=';
    }
}
Actully I'm creating a managed pack that's why I want to fetch dynamically site domain name from different orgs.

my button
User-added image

It's saving but when I click button it gives error that page not found, but if i remove {!Campaign.Id} it works

I want to give visualforce page name and then Campaign.Id
Hello guys

I have a custom checkbox field On Campaign object.
and a custom setting called ManageData__c with 4 fields.
While creating Campaign if this checkbox is checked I want to make sure custom setting ManageData__c 's fields are filled.

if ManageData__c 's fields is not filled then while creating campaign a form will appear where I can fill the ManageData__c's filleds

please help
thank you.
I need help developers
I have json data that I need to parse

Structure is this

I only need bold array value


Please help
{
    "id": "5BS9022******",
    "intent": "CAPTURE",
    "purchase_units": [
        {
            "reference_id": "default",
            "amount": {
                "currency_code": "USD",
                "value": "10.00"
            },
            "payee": {
                "email_address": "Busyaccount@exmaple.com",
                "merchant_id": "ZJCWA********"
            },
            "soft_descriptor": "PAYPAL *JOHNDOESTES",
            "shipping": {
                "name": {
                    "full_name": "Buyer Name"
                },
                "address": {
                    "address_line_1": "Buyer address",
                    "admin_area_2": "",
                    "admin_area_1": "GA",
                    "postal_code": "123456",
                    "country_code": "US"
                }
            },
            "payments": {
                "captures": [
                    {
                        "id": "31349714C********",
                        "status": "COMPLETED",
                        "amount": {
                            "currency_code": "USD",
                            "value": "10.00"
                        },
                        "final_capture": true,
                        "seller_protection": {
                            "status": "ELIGIBLE",
                            "dispute_categories": [
                                "ITEM_NOT_RECEIVED",
                                "UNAUTHORIZED_TRANSACTION"
                            ]
                        },
                        "seller_receivable_breakdown": {
                            "gross_amount": {
                                "currency_code": "USD",
                                "value": "10.00"
                            },
                            "paypal_fee": {
                                "currency_code": "USD",
                                "value": "0.59"
                            },
                            "net_amount": {
                                "currency_code": "USD",
                                "value": "9.41"
                            }
                        },
                        "links": [
  
                        ],
                        "create_time": "2020-02-06T04:00:56Z",
                        "update_time": "2020-02-06T04:00:56Z"
                    }
                ]
            }
        }
    ],
    "payer": {
        "name": {
            "given_name": "buyer Name",
            "surname": "Name"
        },
        "email_address": "testbuyer@example.com",
        "payer_id": "A8******",
        "address": {
            "country_code": "US"
        }
    },
    "create_time": "2020-02-06T03:59:18Z",
    "update_time": "2020-02-06T04:00:56Z",
    "links": [

    ],
    "status": "COMPLETED"
}


 
Hello guys.
I'm typing to get paypal access token and paypal uses basic auth

how can I post Basic auth in salesforce callouts
do I need to put it in request.setHeader('username','sldkj88***');
or in body request.setBody('username','sldkj88***');