Skip to main content

Authentication

Authentication to the Kody API is accomplished using a Store ID and an API key. These credentials are provided during your technical integration onboarding or by your Kody contact.

During development, you'll use a test Store and API key. When you're ready for live access, production credentials will be shared securely and linked with your live store. The API endpoints for test and live environments are compatible; only the credentials and service hostname differ.


Hostnames

  • Development and Test:

    • Default: https://grpc-staging.kodypay.com
    • For Asia-specific region: https://grpc-staging-ap.kodypay.com
    • For Europe-specific region: https://grpc-staging-eu.kodypay.com
  • Live:

    • Default: https://grpc.kodypay.com
    • For Asia-specific region: https://grpc-ap.kodypay.com
    • For Europe-specific region: https://grpc-eu.kodypay.com

Note to Developers: If possible, please set the region based on the user's location. This will route traffic to the closest datacenter, thereby improving connection performance.


Examples

Authentication Code Samples

Below are examples in multiple programming languages demonstrating how to set up authentication when calling Kody API services.

import io.grpc.ManagedChannelBuilder;
import io.grpc.Metadata;
import io.grpc.stub.MetadataUtils;
import com.kodypay.ecom.v1.GetPaymentsRequest;
import com.kodypay.ecom.v1.GetPaymentsResponse;
import com.kodypay.ecom.v1.KodyEcomPaymentsServiceGrpc;

class Main {
public static void main(String[] args) {
// Setup channel and client with authentication
Metadata metadata = new Metadata();
metadata.put(Metadata.Key.of("X-API-Key", Metadata.ASCII_STRING_MARSHALLER), "API_KEY");

var channel = ManagedChannelBuilder.forAddress("HOSTNAME", 443)
.useTransportSecurity()
.build();
var client = KodyEcomPaymentsServiceGrpc.newBlockingStub(channel)
.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));

// Create GetPayments request
var request = GetPaymentsRequest.newBuilder()
.setStoreId("STORE_ID")
.setPageCursor(GetPaymentsRequest.PageCursor.newBuilder()
.setPageSize(10)
.build())
.build();

// Fetch payments
GetPaymentsResponse response = client.getPayments(request);

// Print payment details
response.getResponse().getPaymentsList().forEach(payment -> {
System.out.println("Payment ID: " + payment.getPaymentId());
System.out.println("Status: " + payment.getStatus());
});
}
}

Remember to replace the following placeholders with your actual values:

  • HOSTNAME: Use either grpc-staging.kodypay.com (for development and test) or grpc.kodypay.com (for live).
  • API_KEY: Your API key
  • STORE_ID: Your store identifier

For further support or more detailed information, please contact our support team.