npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@avendure/vendure-plugin-store-credit

v1.0.24

Published

Offers a store credit implementation plugin for users to transact using store credits

Downloads

25

Readme

Store Credits Plugin

Plugin to enable payments through store credits system. This plugin can be used in a multivendor scenario where the superadmin will create the store credits.

Buyers and sellers can transact with store-credit. Platform Fee will diminish credit supply.

##Creating store credit

This plugin extends the admin-ui and adds a "store-credit" section to the side-nav menu. This should be only accessible by users with superadmin permissions

##instructions

  1. Modify the mv.service.ts file in the default Multivendor plugin from Vendure You should include the following lines in the registerNewSeller() function. These will link the customer account with the seller account:
const sellerCustomer = await this.connection
      .getRepository(ctx, Customer)
      .findOne({
        where: { emailAddress: input.seller.emailAddress },
      });

if (!sellerCustomer) {
    throw new InternalServerError(
     "Customer Account Is not created. Can't create Seller account.",
    );
}

//Link Seller account with customer account
await this.sellerService.update(ctx, {
	id: channel.sellerId as ID,
	customFields: {
		customerId: sellerCustomer?.id,
	},
});
  1. You must register the customer account before the seller account You must register the customer account before registering the seller. Pass them the same email address. This will link to two accounts so that credit can be transferred between them.

E.g. On registration, you should call:

registerCustomerAccount(input: $input) {
	__typename
	... on Success {
		success
	}
	... on ErrorResult {
		errorCode
		message
	}
}

Followed by:

registerNewSeller(input: $input) {
	__typename
	id
	code
	token
}

Shop APIs

Query

storeCredit(id: ID!): StoreCredit!
customerStoreCredit(id: ID!, customerId: ID!): StoreCredit!
customerStoreCredits: [StoreCredit!]!

Admin APIs

Query

storeCredits(options: StoreCreditListOptions): StoreCreditList!
transferCreditfromSellerToCustomer(
  value: Int!
  sellerId: ID!
  ): AccountBalance!
getSellerANDCustomerStoreCredits(sellerId: ID!): AccountBalance!

Mutation

createStoreCredit(input: StoreCreditAddInput!): StoreCredit!
updateStoreCredit(input: StoreCreditUpdateInput!): StoreCredit!
deleteSingleStoreCredit(id: ID!): DeletionResponse!

Installation

  • Server should run on port 3050, so the endpoints are

    http://localhost:3050/admin
    http://localhost:3050/shop-api
    http://localhost:3050/admin-api
  • yarn

  • Edit the .env file to add the required environment variables.

  • yarn start

  • Edit test/store-credit.e2e-spec.ts with required constants.

  • yarn test

Errors

I commonly see Serialized Error: { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 3050 } To get around this, run: fuser -k 3050/tcp to find/kill the process using 3050.