{
  "_comment": "Routing for a direct seller's callback endpoint. Bodies are as received (every value a string). A direct seller cannot verify payme_signature, so its presence or value never changes the decision: sale and subscription events are confirmed by querying PayMe. The endpoint answers HTTP 200 for every recorded decision.",
  "case_count": 15,
  "cases": [
    {
      "name": "sale-complete is verified by query, whatever its signature says",
      "body": {
        "notify_type": "sale-complete",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "transaction_id": "order-0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "0123456789abcdef0123456789abcdef"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "sale-authorized is verified by query",
      "body": {
        "notify_type": "sale-authorized",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "refund is verified by query",
      "body": {
        "notify_type": "refund",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "unsigned sale-failure is verified by query",
      "body": {
        "notify_type": "sale-failure",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_signature": ""
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "sale-chargeback is verified by query",
      "body": {
        "notify_type": "sale-chargeback",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "sale callback without payme_sale_id is only recorded",
      "body": {
        "notify_type": "sale-complete",
        "transaction_id": "order-0001"
      },
      "expected": {
        "action": "record",
        "kind": "sale"
      }
    },
    {
      "name": "a field sent twice (parsed as an array) is only recorded",
      "body": {
        "notify_type": "sale-complete",
        "payme_sale_id": [
          "SALE0000-EXAMPLE0-SALE0000-00000001",
          "SALE0000-EXAMPLE0-SALE0000-00000002"
        ]
      },
      "expected": {
        "action": "record",
        "kind": "sale"
      }
    },
    {
      "name": "sub-active is verified by query",
      "body": {
        "notify_type": "sub-active",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "sub-iteration-success is verified by query",
      "body": {
        "notify_type": "sub-iteration-success",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "sub-cancel is verified by query",
      "body": {
        "notify_type": "sub-cancel",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      },
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "seller-approve is a partner notification: recorded",
      "body": {
        "notify_type": "seller-approve",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      },
      "expected": {
        "action": "record",
        "kind": "partner"
      }
    },
    {
      "name": "withdrawal-complete is a partner notification: recorded",
      "body": {
        "notify_type": "withdrawal-complete",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      },
      "expected": {
        "action": "record",
        "kind": "partner"
      }
    },
    {
      "name": "unknown notify_type is recorded",
      "body": {
        "notify_type": "something-new"
      },
      "expected": {
        "action": "record",
        "kind": "unknown"
      }
    },
    {
      "name": "subscription callback without sub_payme_id is only recorded",
      "body": {
        "notify_type": "sub-iteration-success"
      },
      "expected": {
        "action": "record",
        "kind": "subscription"
      }
    },
    {
      "name": "sub_payme_id sent twice (parsed as an array) is only recorded",
      "body": {
        "notify_type": "sub-active",
        "sub_payme_id": [
          "SUB00000-EXAMPLE0-SUB00000-00000001",
          "SUB00000-EXAMPLE0-SUB00000-00000002"
        ]
      },
      "expected": {
        "action": "record",
        "kind": "subscription"
      }
    }
  ]
}
