1.0.24 • Published 2 months ago

@avendure/vendure-plugin-store-credit v1.0.24

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

1.0.22

2 months ago

1.0.21

2 months ago

1.0.20

2 months ago

1.0.24

2 months ago

1.0.23

2 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

6 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago