1

My problem is I get Invalid URI when I try to do a GET with commercepayments.PaymentsHttp in my class with implements commercepayments.PaymentGatewayAdapter

HttpRequest req = new HttpRequest();
req.setHeader('Content-Type', 'application/json');
req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
req.setMethod('GET');  
commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp();
HttpResponse res = http.send(req)
0

I understand the issue. The issue is that PaymentsHttp is sort of a wrapper around the standard Http class which uses the named credential (merchantcredential) associated with the payment gateway adapter (apexadapter.name) for the endpoint (it prefixes the httprequest.endpoint uri with the named cred uri upon http send) Unfortunately there is not much flexibility here.

The doc is (or at least used to be) pretty weak on this.

The suggestion is to build the request assuming it's using this named cred uri as the endpoint. Happy SFCC :)

ie. SELECT Id, PaymentGatewayName, PaymentGatewayProvider.ApexAdapter.Name, MerchantCredential.DeveloperName,MerchantCreditial.Endpoint FROM PaymentGateway

at runtime.

   String additionalSuffix = "/whateverhere";
   String ep = additionalSuffix;
   request.setEndpoint(ep);

if debugging upon http send the endpoint ends up being [MerchantCredital.Endpoint]/whateverhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.