Orchardcore marketplace

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore marketplace is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the CrestApps Orchard Core Marketplace commerce module and its Stripe Connect payouts feature. Covers vendors and the users who run them, the VendorPart on products, commission per store or per vendor, VendorEarning records held in escrow until a hold ends and the order is fulfilled, refun

How to use this skill

Skill file

Orchard Core Marketplace - Prompt Templates

Sell Other Sellers' Products

You are an Orchard Core expert. Generate accurate setup and extension guidance for the CrestApps Marketplace module, which sells vendors' products, keeps a commission, holds what vendors earn in escrow, and pays them out.

Guidelines

Features and Services

| Item | Value |

|---|---|

| Feature IDs | CrestApps.OrchardCore.Marketplace, CrestApps.OrchardCore.Marketplace.StripeConnect |

| Content part | VendorPart (VendorId) |

| YesSql collection | Marketplace (Vendor, VendorEarning, VendorPayout; VendorUserIndex one row per vendor user) |

| Stores | IVendorStore, IVendorEarningStore, IVendorPayoutStore |

| Services | MarketplaceLedger (arithmetic), MarketplaceService (books) |

| Order seam filled | IOrderEventHandler (MarketplaceOrderEventHandler) |

| Seam added | IVendorPayoutProvider (namespace CrestApps.OrchardCore.Marketplace.Services), an IDisbursementProvider of the Banking Disbursements building block |

| Stripe Connect | StripeConnectVendorService, StripeConnectPayoutProvider |

| Site settings | MarketplaceSettings (group marketplace, Settings > Commerce > Marketplace) |

| Background task | MarketplaceBackgroundTask (hourly release, and payouts when automatic) |

| Permission | ManageMarketplace (Administrator, Store manager), also guards the settings group |

| Sample recipe | MarketplaceSample: a Vendor Product type and a $30 mug. Add a vendor under Commerce > Vendors, then pick it on the mug |

Records

Settings

| MarketplaceSettings | Default | Meaning |

|---|---|---|

| CommissionPercent | 10 | Store commission |

| HoldDays | 7 | Days a sale is held |

| ReleaseOnFulfillment | true | Goods also wait until the order is fulfilled |

| AutomaticPayouts | false | Pay out from the background task |

| DefaultCountry | US | Country a vendor's Stripe account is created in |

Settings are site settings, so the standard Orchard Core Settings recipe step sets them:

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.Marketplace",
        "CrestApps.OrchardCore.Marketplace.StripeConnect"
      ]
    },
    {
      "name": "Settings",
      "MarketplaceSettings": {
        "CommissionPercent": 12.5,
        "HoldDays": 14,
        "ReleaseOnFulfillment": true,
        "AutomaticPayouts": false,
        "DefaultCountry": "US"
      }
    }
  ]
}

The Ledger

Recipes, deployment and reporting

The Vendors step creates or updates vendors, matched by ItemId, then by name. Users are named by UserNames (must exist); commission is 0 to 100 or none. The Vendors deployment step (Commerce) writes every vendor. Stripe Connect accounts belong to the site they were made on, so account ids, onboarding keys and payout status are never exported or imported; earnings and payouts stay on the site.

{
  "steps": [
    {
      "name": "Vendors",
      "Vendors": [
        { "ItemId": "4vd00000000000000000000001", "Name": "Acme Crafts", "Email": "sales@acme.test", "UserNames": [ "acme" ], "CommissionPercent": 12.5, "Status": "Active", "Country": "US" }
      ]
    }
  ]
}

With Data Pipelines Core on (Report Builder), the Marketplace data source (Marketplace, permission ManageMarketplace) has Vendors, VendorEarnings (refunds negative) and VendorPayouts. Stripe account ids, keys and transfer references are never exposed. A vendor's user and email are anonymized by VendorPersonalDataContributor on a personal data erasure.

Stripe Connect

Custom Payout Provider

Implement IVendorPayoutProvider (an IDisbursementProvider, CrestApps.OrchardCore.Banking.Disbursements.Services) to pay vendors another way (bank file, PayPal). SubmitAsync receives a batch of Disbursements: read the vendor from Payee (kind MarketplaceConstants.VendorPartyKind) and the order from SourceId (kind PayoutSourceKind), send each with disbursement.IdempotencyKey, and report each disbursement's Statuses (DisbursementStatus.Settled, Submitted or Failed), TraceNumbers and FailureReasons by ItemId. Register one instance as both services in a module that depends on Marketplace and Disbursements, and do not enable the Stripe Connect feature alongside it unless MarketplaceSettings.PayoutProvider names one.

using CrestApps.OrchardCore.Banking.Disbursements.Models;
using CrestApps.OrchardCore.Banking.Disbursements.Services;
using CrestApps.OrchardCore.Marketplace;
using CrestApps.OrchardCore.Marketplace.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Localization;
using OrchardCore.Modules;

namespace MyCompany.Marketplace.BankPayouts;

public sealed class BankFilePayoutProvider : IVendorPayoutProvider
{
    private readonly IBankTransferClient _bank;
    private readonly IVendorStore _vendors;

    internal readonly IStringLocalizer S;

    public BankFilePayoutProvider(IBankTransferClient bank, IVendorStore vendors, IStringLocalizer<BankFilePayoutProvider> stringLocalizer)
    {
        _bank = bank;
        _vendors = vendors;
        S = stringLocalizer;
    }

    public string Name => "BankFile";

    public LocalizedString DisplayName => S["Bank file"];

    public string Method => "BankFile";

    public async Task<DisbursementSubmitResult> SubmitAsync(DisbursementBatch batch, IReadOnlyList<Disbursement> disbursements, CancellationToken cancellationToken = default)
    {
        var result = new DisbursementSubmitResult { Succeeded = true };

        foreach (var disbursement in disbursements)
        {
            var vendor = disbursement.Payee.Kind == MarketplaceConstants.VendorPartyKind
                ? await _vendors.FindByIdAsync(disbursement.Payee.Id, cancellationToken)
                : null;

            var sent = vendor is null
                ? null
                : await _bank.SendAsync(vendor.Email, disbursement.Amount, disbursement.Currency, disbursement.IdempotencyKey, cancellationToken);

            if (sent?.Succeeded == true)
            {
                result.Statuses[disbursement.ItemId] = DisbursementStatus.Settled;
                result.TraceNumbers[disbursement.ItemId] = sent.Reference;
            }
            else
            {
                result.Statuses[disbursement.ItemId] = DisbursementStatus.Failed;
                result.FailureReasons[disbursement.ItemId] = sent?.Error ?? S["Unknown vendor."].Value;
            }
        }

        return result;
    }
}

[RequireFeatures("CrestApps.OrchardCore.Marketplace", "CrestApps.OrchardCore.Banking.Disbursements")]
public sealed class Startup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<BankFilePayoutProvider>();
        services.TryAddEnumerable(ServiceDescriptor.Scoped<IDisbursementProvider, BankFilePayoutProvider>(sp => sp.GetRequiredService<BankFilePayoutProvider>()));
        services.AddScoped<IVendorPayoutProvider>(sp => sp.GetRequiredService<BankFilePayoutProvider>());
    }
}

IBankTransferClient stands for your own payment client. Set Vendor.PayoutsEnabled once the vendor's payout details are known, or PayOutAsync refuses the vendor.

Pages

Troubleshooting

| Symptom | Check |

|---|---|

| No earnings after a paid order | The product needs VendorPart with a VendorId |

| Earnings stay Held | The hold has not ended, or ReleaseOnFulfillment waits for fulfillment. Use Release now |

| Payout refused | The vendor is suspended or PayoutsEnabled is false, or no payout provider is registered |

| Nothing paid and the vendor page says Disbursements is off | Enable Disbursements (CrestApps.OrchardCore.Banking.Disbursements); payouts are disbursements |

| A refused payout | Find it under Banking > Disbursements with Stripe's reason; Pay out what's ready tries again with a new request |

| Set up payouts does nothing | Turn on Connect in the Stripe dashboard and enable the Stripe Connect feature |

| Automatic payouts never run | Enable AutomaticPayouts; the background task runs only for tenants that have served a request |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.