PaymentRequest constructor

PaymentRequest(
  1. String merchant_uuid,
  2. String merchant_op_id,
  3. String description,
  4. Details details,
  5. String return_url,
  6. String cancel_url,
  7. Currency currency,
  8. List<Product> items,
  9. String invoice_number,
  10. String terminal_id,
)

Implementation

PaymentRequest(this.merchant_uuid, this.merchant_op_id, this.description, Details details,
        this.return_url, this.cancel_url, Currency currency, this.items, this.invoice_number, this.terminal_id) {
    this.currency = currency.name;

    double productPriceTotal = 0;
    double productTaxTotal = 0;
    double productCount = items.length.toDouble();
    for(int i=0 ; i<productCount ; i++){
        productTaxTotal += items[i].getTax();
        productPriceTotal += items[i].getPrice() * items[i].getQuantity();
    }

    details.setTax(productTaxTotal);
    amount = Amount("${productPriceTotal + details.getAmount()}0", details);
}