Payments

Sync a payment

Check a payment's latest state with the payment network and update it, what a sync answers, and the payment_intent.synced event.

Open as Markdown
On this page
  1. Sync a payment
  2. The payment_intent.synced event
  3. We sync too
  4. From the dashboard

A sync checks a payment's latest state with the payment network and updates the payment intent to match. Use it when a payment does not look the way you expect: your customer says they paid and the payment is still canceled or requires_action, or you missed a webhook.

  • Our team switches sync on for your organization. Until then the route answers 403 with sync_not_enabled, and the dashboard shows no Sync button. Write to support to ask for it.
  • A sync changes a payment only on what the payment network confirmed, as a confirmation reaching us on its own would. A payment it finds paid is credited to you exactly like one paid in time.
  • It also refreshes the card details we keep on each attempt.

A payment you canceled can turn out paid: see How payments work.

Sync a payment

Send POST /v1/payment_intents/{id}/sync with your secret key. It takes no body. An Idempotency-Key is accepted, not required: a sync sent twice applies nothing twice. Two syncs of the same payment at the same moment are safe too: the second waits for the first, or answers what it found.

The answer is 200 with a payment intent sync:

FieldWhat it holds
objectpayment_intent_sync
changedtrue when the sync changed the payment, false when it was already up to date.
payment_intentThe payment intent, as it is after the sync.
  • curl
  • Node.js
  • TypeScript
  • Python
  • PHP
  • Ruby
  • Go
  • Java
  • C#
  • Rust
sync.mjssync.tssync.pysync.phpsync.rbsync.goSync.javaSync.csmain.rs
curl -X POST \
  https://pay-api.adpromax.com/v1/payment_intents/pi_01k7e9q3w6e9r2t5y8v1c4n7pa/sync \
  -u "$APX_SECRET_KEY:"
const id = 'pi_01k7e9q3w6e9r2t5y8v1c4n7pa'
const response = await fetch(`https://pay-api.adpromax.com/v1/payment_intents/${id}/sync`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.APX_SECRET_KEY}` },
})
const sync = await response.json()
console.log(sync.changed, sync.payment_intent.status) // true succeeded
interface PaymentIntent {
  id: string
  object: 'payment_intent'
  status: string
}

interface PaymentIntentSync {
  object: 'payment_intent_sync'
  changed: boolean
  payment_intent: PaymentIntent
}

const id = 'pi_01k7e9q3w6e9r2t5y8v1c4n7pa'
const response = await fetch(`https://pay-api.adpromax.com/v1/payment_intents/${id}/sync`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.APX_SECRET_KEY}` },
})
const sync = (await response.json()) as PaymentIntentSync
console.log(sync.changed, sync.payment_intent.status) // true succeeded
import os

import requests

intent_id = "pi_01k7e9q3w6e9r2t5y8v1c4n7pa"
response = requests.post(
    f"https://pay-api.adpromax.com/v1/payment_intents/{intent_id}/sync",
    auth=(os.environ["APX_SECRET_KEY"], ""),
)
sync = response.json()
print(sync["changed"], sync["payment_intent"]["status"])  # True succeeded
<?php
$id = 'pi_01k7e9q3w6e9r2t5y8v1c4n7pa';
$ch = curl_init("https://pay-api.adpromax.com/v1/payment_intents/{$id}/sync");
curl_setopt_array($ch, [
    CURLOPT_USERPWD => getenv('APX_SECRET_KEY') . ':',
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
]);
$sync = json_decode(curl_exec($ch), true);
var_dump($sync['changed']); // bool(true)
echo $sync['payment_intent']['status'], PHP_EOL; // succeeded
require 'json'
require 'net/http'

id = 'pi_01k7e9q3w6e9r2t5y8v1c4n7pa'
uri = URI("https://pay-api.adpromax.com/v1/payment_intents/#{id}/sync")
request = Net::HTTP::Post.new(uri)
request.basic_auth(ENV.fetch('APX_SECRET_KEY'), '')

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end
sync = JSON.parse(response.body)
puts sync['changed'], sync['payment_intent']['status'] # true, succeeded
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
)

type PaymentIntentSync struct {
	Object        string `json:"object"`
	Changed       bool   `json:"changed"`
	PaymentIntent struct {
		ID     string `json:"id"`
		Status string `json:"status"`
	} `json:"payment_intent"`
}

func main() {
	id := "pi_01k7e9q3w6e9r2t5y8v1c4n7pa"
	req, err := http.NewRequest(http.MethodPost,
		"https://pay-api.adpromax.com/v1/payment_intents/"+id+"/sync", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.SetBasicAuth(os.Getenv("APX_SECRET_KEY"), "")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var sync PaymentIntentSync
	if err := json.NewDecoder(res.Body).Decode(&sync); err != nil {
		log.Fatal(err)
	}
	fmt.Println(sync.Changed, sync.PaymentIntent.Status) // true succeeded
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Sync {
    public static void main(String[] args) throws Exception {
        String id = "pi_01k7e9q3w6e9r2t5y8v1c4n7pa";
        HttpRequest request = HttpRequest.newBuilder(
                URI.create("https://pay-api.adpromax.com/v1/payment_intents/" + id + "/sync"))
            .header("Authorization", "Bearer " + System.getenv("APX_SECRET_KEY"))
            .POST(HttpRequest.BodyPublishers.noBody())
            .build();
        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        // The sync as JSON: "changed", and the payment intent as it is now.
        System.out.println(response.body());
    }
}
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

var json = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower };
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
    "Bearer", Environment.GetEnvironmentVariable("APX_SECRET_KEY"));

var id = "pi_01k7e9q3w6e9r2t5y8v1c4n7pa";
using var response = await http.PostAsync(
    $"https://pay-api.adpromax.com/v1/payment_intents/{id}/sync", null);
var sync = await response.Content.ReadFromJsonAsync<PaymentIntentSync>(json);
Console.WriteLine($"{sync!.Changed} {sync.PaymentIntent.Status}"); // True succeeded

record PaymentIntent(string Id, string Status);
record PaymentIntentSync(string Object, bool Changed, PaymentIntent PaymentIntent);
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }
//             serde = { version = "1", features = ["derive"] }
use serde::Deserialize;

#[derive(Deserialize)]
struct PaymentIntent {
    status: String,
}

#[derive(Deserialize)]
struct PaymentIntentSync {
    changed: bool,
    payment_intent: PaymentIntent,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let id = "pi_01k7e9q3w6e9r2t5y8v1c4n7pa";
    let sync: PaymentIntentSync = reqwest::blocking::Client::new()
        .post(format!("https://pay-api.adpromax.com/v1/payment_intents/{id}/sync"))
        .bearer_auth(std::env::var("APX_SECRET_KEY")?)
        .send()?
        .json()?;
    println!("{} {}", sync.changed, sync.payment_intent.status); // true succeeded
    Ok(())
}
Response200 OK
{
  "object": "payment_intent_sync",
  "changed": true,
  "payment_intent": {
    "id": "pi_01k7e9q3w6e9r2t5y8v1c4n7pa",
    "object": "payment_intent",
    "amount": 35000,
    "amount_received": 35000,
    "currency": "mad",
    "status": "succeeded",
    "latest_charge": "ch_01k7e9q4x7f0s3v6w9y2a5c8eb",
    "canceled_at": null,
    "cancellation_reason": null,
    "metadata": {},
    "livemode": false
  }
}

The payment_intent.synced event

payment_intent.synced is sent only when something changed: after your sync, after one of ours, or when a confirmation from the payment network reaches us late. A sync that changes nothing sends no event and answers changed: false.

  • data.object is the payment intent as it is now.
  • data.previous_attributes holds only the fields that changed, with the values they had before.

When a canceled payment turns out paid, you receive, in this order, payment_intent.synced, charge.succeeded and payment_intent.succeeded.

payment_intent.synced
{
  "id": "evt_01k7e9r5z8b1d4f7h0k3m6p9sv",
  "object": "event",
  "type": "payment_intent.synced",
  "api_version": "2026-11-01",
  "created": 1794511981,
  "livemode": false,
  "organization": "org_01k7cz9q3m8v6t2x4b5n7p1r0s",
  "data": {
    "object": {
      "id": "pi_01k7e9q3w6e9r2t5y8v1c4n7pa",
      "object": "payment_intent",
      "amount": 35000,
      "amount_received": 35000,
      "currency": "mad",
      "status": "succeeded",
      "latest_charge": "ch_01k7e9q4x7f0s3v6w9y2a5c8eb",
      "canceled_at": null,
      "metadata": {},
      "livemode": false
    },
    "previous_attributes": {
      "status": "canceled",
      "amount_received": 0,
      "canceled_at": 1794511381
    }
  },
  "request": { "id": null, "idempotency_key": null },
  "pending_webhooks": 1
}

We sync too

Whether or not sync is on for you, we sync on our side: for 24 hours after a card payment is created, a payment that is canceled or under review is checked every 10 minutes. You hear of it only when something changed, through the events above.

From the dashboard

When sync is on for your organization, a payment's page has a Sync button. It does what the route does, and says what it found.