TransWikia.com

Invalid URI commercepayments.PaymentGatewayAdapter

Salesforce Asked by Tabarcea Ioana-Carmen on November 17, 2021

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)

One Answer

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

Answered by ChiCloud on November 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP