{
  "_comment": "Routing decisions for a partner callback endpoint, using the same words as seller-callbacks.json: verify-by-query, record, and for a bad signature reject. A valid signature covers only the credentials and two ids, so it is never proof of payment and no case applies a body. Subscription, seller and withdrawal callbacks are unsigned. Bodies are as received: every value a string (application/x-www-form-urlencoded). The endpoint answers HTTP 200 in every case. Digests were computed with node:crypto. All values are fake.",
  "case_count": 21,
  "credentials": {
    "client_key": "MPL00000-EXAMPLE0-PARTNER0-KEY00000",
    "client_secret": "example-partner-secret"
  },
  "cases": [
    {
      "name": "signed sale-complete is verified by query, not applied",
      "body": {
        "status_code": "0",
        "notify_type": "sale-complete",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "badly signed sale is rejected",
      "body": {
        "status_code": "0",
        "notify_type": "sale-complete",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000009",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "reject",
        "kind": "sale"
      }
    },
    {
      "name": "unsigned sale callback with no transaction is recorded, and may trigger the query",
      "body": {
        "status_code": "0",
        "notify_type": "sale-failure",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": ""
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "record",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "signed refund is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "refund",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "no secret configured: sale is not applied",
      "body": {
        "status_code": "0",
        "notify_type": "sale-complete",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "",
      "expected": {
        "action": "reject",
        "kind": "sale"
      }
    },
    {
      "name": "a signature on a subscription callback is ignored: the re-read decides",
      "body": {
        "status_code": "0",
        "notify_type": "sub-iteration-success",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001",
        "transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SUB00001",
        "payme_signature": "d02ac4d703b6abe6d88a06822e9c6277"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "unsigned sub-create is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sub-create",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001",
        "sub_status": "2"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "unsigned sub-cancel is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sub-cancel",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001",
        "sub_status": "2"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "unsigned sub-iteration-success is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sub-iteration-success",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001",
        "sub_status": "2"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "subscription",
        "sub_payme_id": "SUB00000-EXAMPLE0-SUB00000-00000001"
      }
    },
    {
      "name": "seller-approve is verified by query, body ignored",
      "body": {
        "notify_type": "seller-approve",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
        "seller_approved": "1"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "seller",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      }
    },
    {
      "name": "withdrawal-complete is verified by query",
      "body": {
        "notify_type": "withdrawal-complete",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
        "tran_total": "4500"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "withdrawal",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      }
    },
    {
      "name": "unknown notify_type is recorded",
      "body": {
        "notify_type": "something-new"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "record",
        "kind": "unknown"
      }
    },
    {
      "name": "signed sale-authorized is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sale-authorized",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "signed sale-chargeback is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sale-chargeback",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "signed sale-chargeback-refund is verified by query",
      "body": {
        "status_code": "0",
        "notify_type": "sale-chargeback-refund",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "seller-create is verified by query",
      "body": {
        "notify_type": "seller-create",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "seller",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      }
    },
    {
      "name": "seller-update is verified by query",
      "body": {
        "notify_type": "seller-update",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "seller",
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567"
      }
    },
    {
      "name": "a field sent twice (parsed as an array) is rejected",
      "body": {
        "status_code": "0",
        "notify_type": "sale-complete",
        "transaction_id": "order-0001",
        "payme_sale_id": [
          "SALE0000-EXAMPLE0-SALE0000-00000001",
          "SALE0000-EXAMPLE0-SALE0000-00000002"
        ],
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "5075",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "reject",
        "kind": "sale"
      }
    },
    {
      "name": "a replayed signature with its notification type and status changed still only triggers the query",
      "body": {
        "status_code": "0",
        "notify_type": "sale-chargeback-refund",
        "transaction_id": "order-0001",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001",
        "payme_transaction_id": "TRAN0000-EXAMPLE0-TRANSACT-SALE0001",
        "price": "999999",
        "currency": "ILS",
        "payme_signature": "320349e9aeb4b491a063af4556ca1e14",
        "sale_status": "completed"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "verify-by-query",
        "kind": "sale",
        "payme_sale_id": "SALE0000-EXAMPLE0-SALE0000-00000001"
      }
    },
    {
      "name": "subscription callback without sub_payme_id is only recorded",
      "body": {
        "notify_type": "sub-iteration-success"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "record",
        "kind": "subscription"
      }
    },
    {
      "name": "seller callback without seller_payme_id is only recorded",
      "body": {
        "notify_type": "seller-approve"
      },
      "client_secret": "example-partner-secret",
      "expected": {
        "action": "record",
        "kind": "seller"
      }
    }
  ]
}
