Once a buyer has been created it’s possible to link transactions to that buyer. There are a few ways to associate a transaction to a buyer.

Associate the payment method to a buyer_id

The easiest way to associate a buyer to a transaction is to pass along a buyer_id when creating a transaction.

This will find a buyer with that id and associate it to the payment method for this transaction. If a buyer with that id could not be found it’s ignored.

curl -i -X POST "https://api.example.gr4vy.app/transactions" \
    -H "Authorization: Bearer [JWT_TOKEN]" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 1299,
      "currency": "AUD",
      "buyer_id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
      "payment_method": {
        "method": "card",
        "number": "4111111111111111",
        "expiration_date": "11/25",
        "security_code": "123",
      }
    }'

Associate by buyer_external_identifier

Alternatively, a transaction can be associated to a buyer by its external_identifier. If a buyer with that external_identifier could not be found it’s ignored.

curl -i -X POST "https://api.example.gr4vy.app/transactions" \
    -H "Authorization: Bearer [JWT_TOKEN]" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 1299,
      "currency": "AUD",
      "buyer_external_identifier": "412231123",
      "payment_method": {
        "method": "card",
        "number": "4111111111111111",
        "expiration_date": "11/25",
        "security_code": "123",
      }
    }'