openapi: 3.0.3
info:
  title: EDC Payment Gateway - Online Payment
  version: 1.3.0
  description: 'This is sample API document for web payment that bank could use it to develop at their side.


    **Who implements it:** the partner bank. **Who calls it:** EDC App / Web. The bank sends the result back to EDC through
    the return URL and the callback (webhook).'
servers:
- url: https://{domain}
  description: Partner bank endpoint
  variables:
    domain:
      default: bank.example.com
      description: Bank API domain
paths:
  /transaction/create:
    post:
      operationId: createTransaction
      summary: Create Transaction
      description: 'This operation is to create transaction at bank side.


        Implemented by: Partner bank. Called by: EDC App / Web.'
      tags:
      - Online Payment
      servers:
      - url: https://{domain}
        description: Partner bank endpoint
        variables:
          domain:
            default: bank.example.com
            description: Bank API domain
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchant_id:
                  type: string
                  description: Merchant ID at bank side
                transaction_id:
                  type: string
                  description: Transaction reference number from EDC
                transaction_amount:
                  type: number
                  description: Amount to pay
                transaction_currency:
                  type: string
                  description: Currency code (ISO 4217)
                transaction_description:
                  type: string
                  description: Description
                bill_type:
                  type: string
                  description: freeze or utility
                return_url:
                  type: string
                  description: The URL that bank will redirect to after payment completed
                callback_url:
                  type: string
                  description: The URL that bank will send transaction details to EDC side to confirm the transaction (webhook)
                hash:
                  type: string
                  description: Hash calculation field (bank provide hash algorithm)
                details:
                  type: array
                  items:
                    type: object
                    properties:
                      company_code:
                        type: string
                        description: Company code
                      company_name:
                        type: string
                        description: Company name
                      consumer_code:
                        type: string
                        description: Consumer code
                      consumer_name:
                        type: string
                        description: Consumer name
                      consumer_name_latin:
                        type: string
                        description: Consumer name in Latin
                      amount:
                        type: number
                        description: Amount to pay of the consumer
                    required:
                    - company_code
                    - company_name
                    - consumer_code
                    - consumer_name
                    - amount
                  description: List of each consumer details and amount (Max Length for this field size)
              required:
              - merchant_id
              - transaction_id
              - transaction_amount
              - transaction_currency
              - bill_type
              - return_url
              - callback_url
              - hash
            example:
              merchant_id: EDC
              transaction_id: '174952172035635'
              transaction_amount: 100000.0
              transaction_currency: KHR
              transaction_description: ''
              bill_type: utility
              return_url: https://example.com/transaction/complete
              callback_url: https://example.com/transaction/callback
              hash: 4be8fc1f50834aacb5c46005501cda8b...
              details:
              - company_code: EDC-BTB
                company_name: អគ្គិសនីបាត់ដំបង
                consumer_code: '80581211'
                consumer_name: លោក ជា សំណាង
                consumer_name_latin: Mr. Chea Samnang
                amount: 30000.0
              - company_code: EDC
                company_name: អគ្គិសនីកម្ពុជា
                consumer_code: '90481599'
                consumer_name: លោក លីសីហា
                consumer_name_latin: Mr. Ly Seyha
                amount: 70000.0
      responses:
        '200':
          description: Response (check `code` for the business result)
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: Response code
                  message:
                    type: string
                    description: Response message
                  data:
                    type: object
                    properties:
                      web_payment_url:
                        type: string
                        description: The URL to call web payment
                      mobile_deep_link:
                        type: string
                        description: The deep link to call bank app
                    description: Data object
              example:
                code: '000'
                message: ''
                data:
                  web_payment_url: https://bankdomain/payment/....
                  mobile_deep_link: bank://...
      security: []
      callbacks:
        transactionCallback:
          '{$request.body#/callback_url}':
            post:
              summary: Callback (Webhook)
              description: Bank need to send transaction details to EDC to confirm the transaction via "callback_url" parameter
                from create transaction operation.
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        bank_transaction_id:
                          type: string
                          description: Transaction ID at bank side
                        bank_transaction_date:
                          type: string
                          description: Transaction date at bank side
                        bank_transaction_status:
                          type: string
                          description: Transaction status code at bank side
                        bank_transaction_status_message:
                          type: string
                          description: Transaction status message at bank side
                        transaction_id:
                          type: string
                          description: Transaction reference number from EDC
                        transaction_amount:
                          type: number
                          description: Transaction amount
                        transaction_currency:
                          type: string
                          description: Currency code (ISO 4217)
                        convenience_fee_amount:
                          type: number
                          description: Transaction fee will pay by consumer
                        sponsor_fee_amount:
                          type: number
                          description: Transaction fee will pay by biller
                    example:
                      bank_transaction_id: TF00001
                      bank_transaction_date: '2022-03-20 13:55:33'
                      bank_transaction_status: '000'
                      bank_transaction_status_message: ''
                      transaction_id: '174952172035635'
                      transaction_amount: 100000.0
                      transaction_currency: KHR
                      convenience_fee_amount: 0.0
                      sponsor_fee_amount: 0.0
              responses:
                '200':
                  description: Acknowledged by EDC
  /transaction/verify:
    post:
      operationId: verifyTransaction
      summary: Verify Transaction
      description: 'This operation is to verify the transaction at bank side.


        Implemented by: Partner bank. Called by: EDC App / Web.'
      tags:
      - Online Payment
      servers:
      - url: https://{domain}
        description: Partner bank endpoint
        variables:
          domain:
            default: bank.example.com
            description: Bank API domain
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchant_id:
                  type: string
                  description: Merchant ID at bank side
                transaction_id:
                  type: string
                  description: Transaction reference number from EDC
                hash:
                  type: string
                  description: Hash calculation field (bank provide hash algorithm)
              required:
              - merchant_id
              - transaction_id
              - hash
            example:
              merchant_id: EDC
              transaction_id: '174952172035635'
              hash: 4be8fc1f50834aacb5c46005501cda8b...
      responses:
        '200':
          description: Response (check `code` for the business result)
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: Response code
                  message:
                    type: string
                    description: Response message
                  data:
                    type: object
                    properties:
                      bank_transaction_id:
                        type: string
                        description: Transaction ID at bank side
                      bank_transaction_date:
                        type: string
                        description: Transaction date at bank side
                      bank_transaction_status:
                        type: string
                        description: Transaction status code at bank side
                      bank_transaction_status_message:
                        type: string
                        description: Transaction status message at bank side
                      transaction_id:
                        type: string
                        description: Transaction reference number from EDC
                      transaction_amount:
                        type: number
                        description: Transaction amount
                      transaction_currency:
                        type: string
                        description: Currency code (ISO 4217)
                      convenience_fee_amount:
                        type: number
                        description: Transaction fee will pay by consumer
                      sponsor_fee_amount:
                        type: number
                        description: Transaction fee will pay by biller
                    description: Data object
              example:
                code: '000'
                message: ''
                data:
                  bank_transaction_id: TF00001
                  bank_transaction_date: '2022-03-20 13:55:33'
                  bank_transaction_status: '000'
                  bank_transaction_status_message: ''
                  transaction_id: '174952172035635'
                  transaction_amount: 100000.0
                  transaction_currency: KHR
                  convenience_fee_amount: 0.0
                  sponsor_fee_amount: 0.0
      security: []
