+ Start a Discussion
Aakanksha Singh 11Aakanksha Singh 11 

Integrating Braintree payment gateway

Hello Everyone,

I'm Integrating braitree payment gateway in salesfore using REST API. But I'm not getting the desired result. Please tell me what is missing in my code which is mentioned below:
 
<!-- Visualforce Page -->
<apex:page controller="braintreeConfig" standardstylesheets="false" applyHtmlTag="false" applybodytag="false" cache="false" showheader="false" doctype="html-5.0" title="Braintree">
  <apex:form >
      <apex:outputPanel id="main">      
          {!str}
      </apex:outputPanel>
      <apex:commandButton value="Click" action="{!click}" rerender="main" oncomplete="myfunc()"/>      
  </apex:form>  
</apex:page>


<!-- Controller -->
public with sharing class braintreeConfig{

    public string str{get;set;} 
    public void click(){
        try{
        
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://api.sandbox.braintreegateway.com:443/merchants/qhbgvbfxxsqdrbtj/client_token/?version=2');
            req.setMethod('POST');
            
            
            map<string,string> mp = new map<string,string>();
            mp.put('[environment:Braintree\\Configuration:private]', 'sandbox');
            mp.put('[merchantId:Braintree\\Configuration:private]', 'qhbgvbfxxsqdrbtj');
            mp.put('[publicKey:Braintree\\Configuration:private]', '52nztrwwvp8zvqg8');
            mp.put('[privateKey:Braintree\\Configuration:private]', 'f17db5318738459ca0278906181d5aa8');
            mp.put('[_clientId:Braintree\\Configuration:private]', '');
            mp.put('[_clientSecret:Braintree\\Configuration:private]', '');
            mp.put('[_accessToken:Braintree\\Configuration:private]', '');
            mp.put('[_proxyHost:Braintree\\Configuration:private]', '');
            mp.put('[_proxyPort:Braintree\\Configuration:private]', '');
            mp.put('[_proxyType:Braintree\\Configuration:private]', '');
            mp.put('[_proxyUser:Braintree\\Configuration:private]', '');
            mp.put('[_proxyPassword:Braintree\\Configuration:private]', '');
            mp.put('[timeout:Braintree\\Configuration:private]', '60');
            mp.put('[acceptGzipEncoding:Braintree\\Configuration:private]', '1');
            mp.put('[_useClientCredentials:Braintree\\Http:private]', '');
            
            req.setBody(JSON.serialize(mp));
            
            Http http = new Http();
            HTTPresponse res= http.send(req);
            str = res.getBody();
            
        }catch(exception e){
            system.debug(e);
        }
    }   
    
}

I'm getting the response mentioned in screenshot.
https://qsnapnet.com/snaps/o1bn133wd5z5mi 

Please Help me out with this.

Thanks In Advance
Aakanksha Singh 
 
Ryan MeyerRyan Meyer
Hey Aakanksha, did you ever get this working by chance? We're looking at building this out now.