Référence de l'API pour la capture divisée

Découvrez-en plus sur la capture fractionnée Split Capture et l'API Transactions, y compris les points de terminaison pour l'autorisation, la capture, l'annulation, le remboursement, la mise à jour et la lecture.

Aperçu

Capture divisée utilise l’API Transactions qui représente les prêts Affirm émis à l’utilisateur final. Vous pouvez utiliser l’API Transactions pour interagir avec les transactions via l’objet Transactions afin de modifier l’état d’une transaction, mettre à jour les métadonnées ou récupérer des détails.

Autorisation

L'autorisation d'une transaction se produit après qu'un utilisateur a terminé le processus de paiement Affirm et retourne sur le site du commerçant. L'autorisation des frais génère un transaction_id qui sera utilisé pour le référencer à l'avenir. Vous devez autoriser une transaction pour le créer entièrement.

Point de terminaison

<https://api.affirm.com/api/v1/transactions>

Paramètres d'en-tête

Paramètre

  • Idempotency-Key* string REQUIRED: Unique identifiers pre-generated by the client and used by the server to recognize successive calls to the same endpoint. This is required for Split Capture and encouraged for single transaction functionality.

Paramètres du corps

Paramètres

  • transaction_id* string REQUIRED: Unique token used for authorization. Received to the user_confirmation_url
  • order_id* string
  • Optionnel : Identifie la commande correspondante dans le système de gestion des commandes du marchand.Retourné seulement s'il est inclus dans la requête.
  • reference_id* string
  • Optionnel: Un identifiant unique pouvant être associé à chaque transaction et rapproché avec le système d’enregistrement utilisé par le commerçant.

demande

curl https://sandbox.affirm.com/api/v1/transactions \
     -X POST \
     -u "<public_api_key>:<private_api_key>" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: <idempotency_value>" \
     -d '{"transaction_id": "<checkout_token>","order_id": "<order_id_value>"}'

Réponse

"status": "authorized",
    "amount_refunded": 0,
    "provider_id": 1,
    "created": "2020-06-12T20:32:09Z",
    "order_id": "random",
    "checkout_id": "LBQFHCCGETZF21GY",
    "currency": "USD",
    "amount": 99999,
    "events": [
        {
            "currency": "USD",
            "amount": 99999,
            "type": "auth",
            "id": "95FD5182N72JJ20Y",
            "created": "2020-06-12T20:35:47Z"
        }
    ],
    "authorization_expiration": "2020-12-09T20:35:48Z",
    "id": "R1CN-7IIP"
}

Saisie

Capturer les fonds d'une transaction autorisée, comme pour une transaction par carte de crédit.

Point de terminaison

POST <https://api.affirm.com/api/v1/transactions/{transaction_id}/capture>

Paramètres d'en-tête

Paramètre

  • Idempotency-Key* string REQUIRED: Unique identifiers pre-generated by the client and used by the server to recognize successive calls to the same endpoint. This is required for Split Capture and encouraged for single transaction functionality.

Paramètres de chemin

Paramètres

  • transaction_id* string REQUIRED: A unique identifier representing the transaction. The value is an alphanumeric string of 9 or 12 characters in length, depending on whether it represents an installment loan or a lease, respectively.

Paramètres du corps

Paramètres

  • amount* int32 REQUIRED: Pass the amount to be captured. If you want to capture $50.80, the amount value would be 5080.
  • order_id* string
  • Optionnel : Identifie la commande correspondante dans le système de gestion des commandes du marchand.Retourné seulement s'il est inclus dans la requête.
  • reference_id* string
  • Optionnel: Un identifiant unique pouvant être associé à chaque transaction et rapproché avec le système d’enregistrement utilisé par le commerçant.
  • shipping_carrier* string
  • Optionnel_ : Le transporteur (par exemple« USPS ») utilisé pour expédier les articles.
  • shipping_confirmation* string
  • Facultatif_: Le numéro de suivi de l'expédition.

demande

curl https://sandbox.affirm.com/api/v1/transactions/{transaction_id}/capture \
    -X POST \
    -u "<public_api_key>:<private_api_key>" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: <idempotency_value>" \
    -d '{"amount":<enter_amount>, "order_id": "<order_id_value>", "shipping_carrier": "<carrier_value>", "shipping_confirmation": "<shipping_confirmation_value>"}'

Réponse

{
    "fee": 22,
    "created": "2020-06-12T20:38:18Z",
    "order_id": "R1CN-7IIP",
    "shipping_confirmation": "shipping_confirmation_id",
    "shipping_carrier": "UPS",
    "currency": "USD",
    "amount": 1000,
    "type": "split_capture",
    "id": "02PWU4FLAU07GYW4"
}

Annuler

Annuler une transaction autorisée.

Point de terminaison

POST <https://api.affirm.com/api/v1/transactions/{transaction_id}/void>

Paramètres d'en-tête

Paramètre

  • Idempotency-Key* string REQUIRED: Unique identifiers pre-generated by the client and used by the server to recognize successive calls to the same endpoint. This is required for Split Capture and encouraged for single transaction functionality.

Paramètres de chemin

Paramètres

  • transaction_id* string REQUIRED: A unique identifier representing the transaction. The value is an alphanumeric string of 9 or 12 characters in length, depending on whether it represents an installment loan or a lease, respectively.

Paramètres du corps

Paramètres

  • amount* int32 REQUIRED: Pass the amount to be voided. If you want to void $50.80, the amount value would be 5080.
  • reference_id* string
  • Optionnel: Un identifiant unique pouvant être associé à chaque transaction et rapproché avec le système d’enregistrement utilisé par le commerçant.

demande

curl https://sandbox.affirm.com/api/v1/transactions/{transaction_id}/void \
    -X POST \
    -u "<public_api_key>:<private_api_key>" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: <idempotency_value>" \
    -d '{"amount":<enter_amount>}'

Réponse

{
    "currency": "USD",
    "amount": 2000,
    "type": "refund_voided",
    "id": "Y5NVH0OHZLHR20IA",
    "created": "2020-06-12T20:38:58Z"
}

remboursement

Rembourser une transaction.

Point de terminaison

POST <https://api.affirm.com/api/v1/transactions/{transaction_id}/refund>

Paramètres d'en-tête

Paramètre

  • Idempotency-Key* string REQUIRED: Unique identifiers pre-generated by the client and used by the server to recognize successive calls to the same endpoint. This is required for Split Capture and encouraged for single transaction functionality.

Paramètres de chemin

Paramètres

  • transaction_id* string REQUIRED: A unique identifier representing the transaction. The value is an alphanumeric string of 9 or 12 characters in length, depending on whether it represents an installment loan or a lease, respectively.

Paramètres du corps

Paramètres

  • amount* int32 REQUIRED: Pass the amount to be refunded. If you want to refund $50.80, the amount value would be 5080.
  • reference_id* string
  • Optionnel: Un identifiant unique pouvant être associé à chaque transaction et rapproché avec le système d’enregistrement utilisé par le commerçant.

demande

curl https://sandbox.affirm.com/api/v1/transactions/{transaction_id}/refund \
    -X POST \
    -u "<public_api_key>:<private_api_key>" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: <idempotency_value>" \
    -d '{"amount":<enter_amount>}'

Réponse

{
    "created": "2020-06-12T20:40:54Z",
    "fee_refunded": 22,
    "currency": "USD",
    "amount": 1000,
    "type": "refund",
    "id": "DKJYFG2LYG264LGK"
}

Mettre à jour

Mettre à jour une transaction avec de nouvelles informations d’exécution ou de commande, telles que le numéro de suivi d’expédition, le transporteur ou l’identifiant de la commande.

Point de terminaison

POST <https://api.affirm.com/api/v1/transactions/{transaction_id}>

Paramètres de chemin

Paramètres

  • transaction_id* string REQUIRED: A unique identifier representing the transaction. The value is an alphanumeric string of 9 or 12 characters in length, depending on whether it represents an installment loan or a lease, respectively.

Paramètres du corps

Paramètres

  • order_id* string
  • Optionnel : Identifie la commande correspondante dans le système de gestion des commandes du marchand.Retourné seulement s'il est inclus dans la requête.
  • reference_id* string
  • Optionnel: Un identifiant unique pouvant être associé à chaque transaction et rapproché avec le système d’enregistrement utilisé par le commerçant.
  • shipping* string
  • Optional_: A Contact contenant les renseignements d'expédition du client.
  • shipping_carrier* string
  • Optionnel_ : Le transporteur (par exemple« USPS ») utilisé pour expédier les articles.
  • shipping_confirmation* string
  • Facultatif_: Le numéro de suivi de l'expédition.

demande

curl https://sandbox.affirm.com/api/v1/transactions/{transaction_id} \
	-X POST \
	-u "<public_api_key>:<private_api_key>" \
	-H "Content-Type: application/json" \
	-d '{"order_id": "JLKM4321", "shipping_carrier": "USPS", "shipping_confirmation": "1Z23223", "shipping": {"name":{ "full": "John Doe"}, "address": {"line1": "325 Pacific Ave", "state": "CA", "city": "San Francisco", "zipcode": "94111", "country": "USA"}}}'

Réponse

{
    "created": "2020-06-12T20:43:23Z",
    "order_id": "R1CN-7IIP",
    "shipping_confirmation": "shipping_confirmation_id_1591994603",
    "shipping_carrier": "UPS",
    "type": "update",
    "id": "L88BIOQTCQNP2JAZ"
}

Lire

Lire les informations de transaction, l’état actuel de la transaction et les données de paiement pour une ou plusieurs transactions. Ceci est utile pour mettre à jour vos enregistrements ou votre système de gestion des commandes avec les états de transaction actuels avant d'effectuer des actions dessus. Il vous permet également de garder votre système synchronisé avec Affirm si votre personnel gère manuellement les prêts dans le portail du commerçant.

Point de terminaison

GET <https://api.affirm.com/api/v1/transactions/{transaction_id}>

Paramètres de chemin

Paramètres

  • transaction_id* string REQUIRED: A unique identifier representing the transaction. The value is an alphanumeric string of 9 or 12 characters in length, depending on whether it represents an installment loan or a lease, respectively.

Paramètres de requête

Paramètres

  • expand* string A comma-separated set of related objects to expand in the response. Valid values are: events

demande

curl https://sandbox.affirm.com/api/v1/transactions/{transaction_id} \
    -X GET \
    -u "<public_api_key>:<private_api_key>"

Réponse

{
    "status": "partially_refunded",
    "amount_refunded": 1000,
    "provider_id": 1,
    "created": "2020-06-12T20:32:09Z",
    "order_id": "R1CN-7IIP",
    "checkout_id": "LBQFHCCGETZF21GY",
    "currency": "USD",
    "amount": 99999,
    "events": [],
    "authorization_expiration": "2020-12-09T20:35:48Z",
    "id": "R1CN-7IIP"
}