Aller au contenu

Cartes bancaires de test

Sangho utilise Braintree pour le traitement des cartes bancaires. En Sandbox, utilisez les numéros de carte Braintree standards pour simuler différents scénarios — aucun débit réel n’est effectué.

Cartes de test

NuméroMarqueComportementCode d'erreur
4111 1111 1111 1111Visa✅ Paiement réussi
5500 0000 0000 0004Mastercard✅ Paiement réussi
4000 0000 0000 0002Visa❌ Carte déclinéecard_declined
4000 0000 0000 9995Visa❌ Fonds insuffisantsinsufficient_funds
4000 0000 0000 3220Visa🔐 Déclenche 3DSauthentication_required
4000 0000 0000 0069Visa❌ Carte expiréeexpired_card
4000 0000 0000 0127Visa❌ CVV incorrectincorrect_cvc
Données communes à toutes les cartes de test

Date d’expiration : toute date future, ex. 12/28 · CVV : 123 · Code postal : 75001

3D Secure en Sandbox

Utilisez la carte 4000 0000 0000 3220 pour déclencher le flux 3DS. En Sandbox, le formulaire d’authentification est simulé et accepte n’importe quel code OTP.

Codes d’erreur carte

Code d'erreurDescription
card_declinedCarte déclinée par la banque émettrice.
insufficient_fundsFonds insuffisants sur le compte.
expired_cardDate d'expiration dépassée.
incorrect_cvcCVV incorrect.
authentication_required3DS requis et non complété.

Intégration Braintree Hosted Fields

javascript
const sangho = new Sangho('pk_test_xxxx');


const cardForm = await sangho.elements.create('card', {
  style: {
    base: {
      fontSize: '16px',
      color: '#1a2332',
    },
  },
});


cardForm.mount('#card-element');


document.getElementById('pay-btn').onclick = async () => {
  const { paymentMethod, error } = await sangho.createPaymentMethod({
    type: 'card',
    card: cardForm,
  });


  if (error) {
    document.getElementById('error').textContent = error.message;
    return;
  }


  await fetch('/confirm-payment', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ payment_method_id: paymentMethod.id }),
  });
};

Flux 3DS (TypeScript)

javascript
import Sangho from '@sangho/sdk';


const sangho = new Sangho(process.env.SANGHO_TEST_KEY!);


// La carte 4000 0000 0000 3220 déclenche automatiquement 3DS
const intent = await sangho.paymentIntents.create({
  amount: 5000,
  currency: 'XAF',
  payment_method_types: ['card'],
});


// Le SDK gère la redirection 3DS automatiquement
const confirmed = await sangho.paymentIntents.confirm(intent.id, {
  payment_method: 'pm_card_threeDSecure2Required',
  return_url: 'https://votre-app.com/paiement/retour',
});


console.log(confirmed.status); // 'succeeded' après authentification