import secrets from datetime import datetime, timezone from pathlib import Path from reportlab.lib.pagesizes import A4 from reportlab.pdfgen import canvas CONTRACT_DIR = Path("/contracts") CONTRACT_DIR.mkdir(exist_ok=True) def create_contract(user_id, company, tax_id, signature): CONTRACT_DIR.mkdir(exist_ok=True) filename = f"contract-{user_id}-{secrets.token_hex(8)}.pdf" path = CONTRACT_DIR / filename pdf = canvas.Canvas(str(path), pagesize=A4, pageCompression=0) pdf.setTitle("Starpost marketplace contract") pdf.setFont("Helvetica", 16) pdf.drawString(55, 790, "STARPOST MARKETPLACE CONTRACT") pdf.setFont("Helvetica", 10) lines = [ "MARKETPLACE SELLER AGREEMENT", "", "1. PARTIES TO THE AGREEMENT", f"Company Name: {company}", f"Tax Identification Number: {tax_id}", f"Seller Account ID: {user_id}", f"Agreement Date (UTC): {datetime.now(timezone.utc).isoformat()}", "", "2. PURPOSE AND SCOPE OF THE AGREEMENT", "This Agreement establishes the terms and conditions under", "which the Seller may use the Starpost Marketplace platform", "to publish cargo listings, offer goods for sale, receive", "customer orders, and manage marketplace transactions.", "Starpost provides the technical infrastructure necessary", "for publishing listings, processing orders, maintaining", "transaction records, and facilitating marketplace activity.", "The Seller agrees to comply with the terms of this Agreement", "and the operational requirements of the platform.", "", "3. SELLER RIGHTS AND RESPONSIBILITIES", "The Seller may create and manage cargo listings, specify", "prices, update product availability, and receive orders", "through the Starpost Marketplace system.", "The Seller is responsible for ensuring that all submitted", "information is accurate, complete, and up to date.", "Cargo descriptions must correctly represent the goods,", "their condition, quantity, characteristics, and availability.", "The Seller must not publish fraudulent, deceptive, or", "intentionally misleading offers or transaction information.", "The Seller is responsible for fulfilling accepted orders", "and providing reasonable customer support regarding sales,", "delivery conditions, product information, and complaints.", "", "4. STARPOST MARKETPLACE SERVICES", "Starpost provides access to marketplace functionality", "for creating listings, receiving orders, and reviewing", "transaction history and order statuses.", "The platform records relevant sales information and may", "provide tools for calculating and reviewing revenue.", "Starpost may perform maintenance, deploy security updates,", "and modify technical components to maintain platform", "stability, availability, and operational security.", "Temporary interruptions may occur during maintenance", "or due to circumstances outside the platform's control.", "", "5. CARGO LISTINGS AND ORDER PROCESSING", "Each listing must contain a valid description of the goods,", "the applicable price, available quantity, and any relevant", "conditions necessary for a customer to place an order.", "The Seller must review incoming orders and ensure that", "accepted orders are processed in accordance with the", "information published in the corresponding listing.", "Changes to a listing must not intentionally misrepresent", "the terms of an order that has already been accepted.", "The Seller should promptly report technical errors that", "affect order creation, order status, or transaction records.", "", "6. SALES RECORDS AND REVENUE", "Starpost maintains marketplace records relating to orders,", "completed sales, and other supported transaction events.", "These records may be used to calculate marketplace revenue", "and determine the amounts eligible for transfer to the Seller.", "Revenue transfers are subject to the platform's payment", "procedures and the status of the relevant transactions.", "The Seller is responsible for reviewing transaction records", "and reporting discrepancies through the available support", "or dispute resolution procedures.", "Starpost may retain transaction records for accounting,", "security auditing, and investigation of disputed orders.", "", "7. CUSTOMER SUPPORT AND DISPUTE HANDLING", "The Seller is responsible for responding to reasonable", "customer inquiries concerning the Seller's cargo listings", "and the fulfillment of accepted orders.", "In the event of a disagreement regarding an order, the", "parties should review the relevant listing, order details,", "transaction history, and other available evidence.", "Suspected fraudulent activity or technical manipulation", "of marketplace transactions may be subject to investigation.", "The parties should cooperate in resolving disputes and", "provide relevant information when reasonably requested.", "", "8. ACCOUNT SECURITY AND DATA PROTECTION", "The Seller is responsible for maintaining the security", "of the Seller's account and associated authentication data.", "Credentials and authorization secrets must not be disclosed", "to unauthorized persons or exposed through public listings.", "Information submitted to Starpost may be processed to", "operate the marketplace, manage orders, maintain records,", "provide support, and investigate security incidents.", "Customer information must be handled responsibly and used", "only for legitimate purposes connected with marketplace", "operations and order fulfillment.", "", "9. PROHIBITED ACTIVITIES", "The Seller must not intentionally exploit technical flaws", "to create unauthorized orders, manipulate revenue records,", "obtain goods or services without proper authorization,", "or interfere with the normal operation of the platform.", "The Seller must not submit forged business information,", "misuse another user's account, or attempt to gain access", "to information or functions without authorization.", "Starpost may investigate suspected violations and apply", "appropriate restrictions in accordance with its policies.", "", "10. LIABILITY AND LIMITATIONS", "The Seller remains responsible for the accuracy of listings,", "the fulfillment of accepted orders, and the handling of", "customer inquiries relating to the Seller's goods.", "Each party is responsible for its own actions and failures", "to comply with the obligations established by this Agreement.", "Neither party should knowingly provide false information", "or interfere with the proper recording of transactions.", "Any limitation of liability must be interpreted in", "accordance with the applicable terms and governing law.", "", "11. TERM AND TERMINATION", "This Agreement becomes effective upon its acceptance and", "the recording of the Seller's signature or authorization.", "The Agreement remains effective while the Seller uses", "the marketplace, unless terminated in accordance with", "the applicable platform procedures.", "Access may be restricted when there is evidence of fraud,", "unauthorized activity, or a material violation of the", "platform's requirements.", "Termination does not automatically eliminate outstanding", "obligations associated with previously accepted orders,", "completed transactions, or unresolved disputes.", "", "12. FINAL PROVISIONS", "This document records the terms presented to the Seller", "at the time the Agreement is generated.", "Any amendments or additional conditions should be recorded", "in an appropriate form and communicated to the parties.", "Questions concerning the interpretation of this Agreement", "should be addressed through the established support process.", "", "SELLER ACKNOWLEDGMENT", "By signing this Agreement, the Seller confirms that the", "provided company information is accurate and acknowledges", "the responsibilities associated with marketplace activity.", "The Seller agrees to comply with the terms described above", "and to act in good faith when processing customer orders.", "", "Seller Signature / Authorization Key:", ] y = 745 for line in lines: pdf.drawString(55, y, line) y -= 28 for offset in range(0, len(signature), 88): pdf.drawString(55, y, signature[offset:offset + 88]) y -= 16 pdf.save() return filename