Skip to content

Quickstart

Create a finalized Inttegro order and open its hosted checkout invoice.

Create and finalize an order with an official server SDK. Then send your customer to its hosted checkout page and retrieve the order before fulfillment.

1PrepareChoose your server language and load a secret key.
2CreateCreate and finalize one order with a stable idempotency key.
3PresentOpen the returned hosted invoice URL for the customer.
4VerifyRead the order again before fulfilling the purchase.

Prerequisites

Install an SDK

Install the SDK for your server-side runtime before creating requests:

The code-language control in the Studio navigation updates compatible examples throughout the documentation.

SDK installation

cURLbash
# cURL calls the API directly, so there is no SDK to install.
curl --version
TypeScriptbash
npm install @inttegro/inttegro-sdk
Gobash
go get github.com/inttegro/inttegro-sdk-go/v14
Pythonbash
pip install inttegro
PHPbash
composer require inttegro/sdk
Rubybash
bundle add inttegro
Javaxml
<dependency>
  <groupId>com.inttegro</groupId>
  <artifactId>inttegro-sdk-java</artifactId>
  <version>2.0.0</version>
</dependency>
C#bash
dotnet add package Inttegro

Create a finalized order

Set finalize to true so the returned order is ready for Checkout. The SDK returns the order directly, including the hosted URL at invoice.format.web.url.

Create an order

POST/orders/create
cURLbash
response=$(curl https://api.inttegro.com/orders/create \
  -H "Authorization: Bearer $INTTEGRO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: checkout-order-123" \
  -d '{
    "customer_data": {
      "name": "Akua Mensah",
      "email_address": "akua@example.com",
      "phone_number": "+233544998605"
    },
    "finalize": true,
    "line_items": [{
      "product": {
        "name": "Monthly Subscription",
        "price": { "currency": "ghs", "value": 5000 },
        "quantity": 1,
        "type": "service"
      },
      "type": "product"
    }]
  }')

invoice_url=$(jq -er '.order.invoice.format.web.url' <<< "$response")
printf '%s\n' "$invoice_url"
TypeScripttypescript
import { InttegroClient, ProductTypes, LineItemTypes } from '@inttegro/inttegro-sdk'

const inttegro = new InttegroClient({
  apiKey: process.env.INTTEGRO_API_KEY!,
})

const result = await inttegro.orders.create({
  requestMeta: {
    idempotencyKey: "checkout-order-123",
  },
  customerData: {
    name: "Akua Mensah",
    emailAddress: "akua@example.com",
    phoneNumber: "+233544998605",
  },
  finalize: true,
  lineItems: [
    {
      product: {
        name: "Monthly Subscription",
        price: {
          currency: "ghs",
          value: 5000,
        },
        quantity: 1,
        type: ProductTypes.Service,
      },
      type: LineItemTypes.Product,
    },
  ],
})
Gogo
package main

import (
  "context"
  "log"
  "os"

  inttegro "github.com/inttegro/inttegro-sdk-go/v14"
  "github.com/inttegro/inttegro-sdk-go/v14/customer"
  "github.com/inttegro/inttegro-sdk-go/v14/money"
  "github.com/inttegro/inttegro-sdk-go/v14/order"
  "github.com/inttegro/inttegro-sdk-go/v14/price"
  "github.com/inttegro/inttegro-sdk-go/v14/product"
  "github.com/inttegro/inttegro-sdk-go/v14/request"
)

func main() {
  ctx := context.Background()
  client := inttegro.NewClient(os.Getenv("INTTEGRO_API_KEY"))

  params := order.CreateParams{
    RequestMeta: &request.Meta{
      IdempotencyKey: "checkout-order-123",
    },
    CustomerData: &customer.Data{
      Name: "Akua Mensah",
      Email: "akua@example.com",
      PhoneNumber: "+233544998605",
    },
    Finalize: inttegro.Bool(true),
    LineItems: []order.LineItemParams{
      {
        Product: &order.ProductLineItemParams{
          Name: "Monthly Subscription",
          Price: price.InlineParams{
            AmountParams: money.AmountParams{
              Currency: money.GHS,
              Value: 5000,
            },
          },
          Quantity: 1,
          Type: product.TypeService,
        },
        Type: order.LineItemTypeProduct,
      },
    },
  }
  result, err := client.Orders.Create(ctx, params)
  if err != nil {
    log.Fatal(err)
  }
  _ = result
}
Pythonpython
import os

import inttegro
from inttegro import InttegroClient

client = InttegroClient(api_key=os.environ["INTTEGRO_API_KEY"])

result = client.orders.create(inttegro.order.CreateNewCustomerInput(
  request_meta=inttegro.order.CreateNewCustomerInputRequestMeta(
    idempotency_key="checkout-order-123",
  ),
  customer_data=inttegro.customer.DataInput(
    name="Akua Mensah",
    email_address="akua@example.com",
    phone_number="+233544998605",
  ),
  finalize=True,
  line_items=[
    inttegro.product.LineItemInput(
      product=inttegro.product.InlineDetailsInput(
        name="Monthly Subscription",
        price=inttegro.price.InlineParams(
          currency=inttegro.money.Currency.GHS,
          value=5000,
        ),
        quantity=1,
        type=inttegro.product.Type.SERVICE,
      ),
      type=inttegro.order.LineItemType.PRODUCT,
    ),
  ],
))
PHPphp
<?php

use Inttegro\Client;

$client = new Client($_ENV['INTTEGRO_API_KEY']);
$result = $client->orders->create([
  'request_meta' => new \Inttegro\Request\Meta(
    idempotencyKey: 'checkout-order-123',
  ),
  'customer_data' => [
    'name' => 'Akua Mensah',
    'email_address' => 'akua@example.com',
    'phone_number' => '+233544998605',
  ],
  'finalize' => true,
  'line_items' => [
    [
      'product' => [
        'name' => 'Monthly Subscription',
        'price' => [
          'currency' => 'ghs',
          'value' => 5000,
        ],
        'quantity' => 1,
        'type' => \Inttegro\ProductType::Service,
      ],
      'type' => \Inttegro\LineItemType::Product,
    ],
  ],
]);
Rubyruby
require "inttegro"

client = Inttegro::Client.new(api_key: ENV.fetch("INTTEGRO_API_KEY"))
result = client.orders.create(
  request_meta: Inttegro::Order::CreateNewCustomerRequestMeta.new(
    idempotency_key: "checkout-order-123",
  ),
  customer_data: {
    name: "Akua Mensah",
    email_address: "akua@example.com",
    phone_number: "+233544998605",
  },
  finalize: true,
  line_items: [
    {
      product: {
        name: "Monthly Subscription",
        price: {
          currency: "ghs",
          value: 5000,
        },
        quantity: 1,
        type: Inttegro::ProductType::SERVICE,
      },
      type: Inttegro::LineItemType::PRODUCT,
    },
  ]
)
Javajava
import com.inttegro.Client;
import com.inttegro.orders.OrderCreateParams;
import com.inttegro.RequestMeta;
import com.inttegro.customers.CustomerData;
import com.inttegro.orders.OrderLineItemParams;
import com.inttegro.orders.ProductLineItemParams;
import com.inttegro.prices.PriceParams;
import com.inttegro.money.Currency;
import com.inttegro.products.ProductType;

public class Example {
  public static void main(String[] args) throws Exception {
    var client = new Client(System.getenv("INTTEGRO_API_KEY"));
    var params = OrderCreateParams.builder()
      .requestMeta(RequestMeta.builder()
          .idempotencyKey("checkout-order-123")
          .build())
      .customerData(CustomerData.builder()
          .name("Akua Mensah")
          .email("akua@example.com")
          .phoneNumber("+233544998605")
          .build())
      .finalizeOrder(true)
      .lineItem(OrderLineItemParams.product(ProductLineItemParams.builder()
            .name("Monthly Subscription")
            .price(PriceParams.of(Currency.GHS, 5000))
            .quantity(1L)
            .type(ProductType.SERVICE)
            .build()))
      .build();
    var result = client.orders().create(params);
  }
}
C#csharp
using Inttegro;

using var inttegro = new InttegroClient(
    Environment.GetEnvironmentVariable("INTTEGRO_API_KEY")!
);
var result = await inttegro.Orders.CreateAsync(new OrderCreateRequest {
  RequestMeta = new RequestMeta {
    IdempotencyKey = "checkout-order-123",
  },
  CustomerData = new CustomerData {
    Name = "Akua Mensah",
    EmailAddress = "akua@example.com",
    PhoneNumber = "+233544998605",
  },
  Finalize = true,
  LineItems = new List<LineItemParams> {
    new LineItemParams {
      Product = new ProductDetailsParams {
        Name = "Monthly Subscription",
        Price = new Inttegro.PriceParams {
          Currency = Inttegro.Money.Currency.GHS,
          Value = 5000,
        },
        Quantity = 1,
        Type = Inttegro.ProductType.Service,
      },
      Type = Inttegro.LineItemType.Product,
    },
  },
});

Redirect the customer’s browser to invoice.format.web.url.

Verify the order before fulfillment

The customer returning from checkout is not proof of payment. Look up the order with the returned order ID and use its latest payment and order state before granting access, shipping goods, or marking work complete.

Repeat uncertain requests with the same idempotency key. Do not create a replacement order merely because a client timed out.

Type to search…

↑↓ navigate↵ selectEsc close