Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/docs/reference/graphql-api/admin/input-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3534,6 +3534,12 @@ input NumberOperators {
amount: Money
paymentId: ID!
reason: String
"""
Optional refund destination code. When omitted, refunds to the original
payment method. Use the \`refundDestinations\` query to discover available
destinations for an order.
"""
destination: String
}`}
</GraphQLDoc>

Expand Down
23 changes: 23 additions & 0 deletions docs/docs/reference/graphql-api/admin/object-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,11 @@ type QuantityTooGreatError {
adjustment: Money!
total: Money!
method: String
"""
The refund destination code, if a non-default destination was used.
When null, the refund was directed to the original payment method.
"""
destination: String
state: String!
transactionId: String
reason: String
Expand Down Expand Up @@ -4015,6 +4020,24 @@ type RefundAmountError {
}`}
</GraphQLDoc>

<a name="refunddestination"></a>

## RefundDestination

<GraphQLDoc
type="type"
typeName="RefundDestination"
typeLinks={{
String: '/reference/graphql-api/admin/object-types#string',
}}
>
{`"""Represents an available refund destination for an order."""
type RefundDestination {
code: String!
description: String!
}`}
</GraphQLDoc>

<a name="refundline"></a>

## RefundLine
Expand Down
22 changes: 22 additions & 0 deletions docs/docs/reference/graphql-api/admin/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,28 @@ type Query {
}`}
</GraphQLDoc>

<a name="refunddestinations"></a>

## refundDestinations

<GraphQLDoc
type="query"
typeName="refundDestinations"
typeLinks={{
RefundDestination: '/reference/graphql-api/admin/object-types#refunddestination',
ID: '/reference/graphql-api/admin/object-types#id',
}}
>
{`"""
Returns the available refund destinations for the given order.
This includes the default destination (original payment method) plus
any custom destinations registered via RefundDestinationStrategy.
"""
type Query {
refundDestinations(orderId: ID!): [RefundDestination!]!
}`}
</GraphQLDoc>

<a name="role"></a>

## role
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/reference/graphql-api/shop/object-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,11 @@ type PriceRange {
adjustment: Money!
total: Money!
method: String
"""
The refund destination code, if a non-default destination was used.
When null, the refund was directed to the original payment method.
"""
destination: String
state: String!
transactionId: String
reason: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "AssetOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="716" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="717" packageName="@vendure/core" />

The AssetOptions define how assets (images and other files) are named and stored, and how preview images are generated.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/auth/auth-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "AuthOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="363" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="364" packageName="@vendure/core" />

The AuthOptions define how authentication and authorization is managed.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/auth/cookie-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "CookieOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="258" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="259" packageName="@vendure/core" />

Options for the handling of the cookies used to track sessions (only applicable if
`authOptions.tokenMethod` is set to `'cookie'`). These options are passed directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "SuperadminCredentials"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="892" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="893" packageName="@vendure/core" />

These credentials will be used to create the Superadmin user & administrator
when Vendure first bootstraps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ConfigArgs"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="140" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="135" packageName="@vendure/core" />

A object which defines the configurable arguments which may be passed to
functions in those classes which implement the [ConfigurableOperationDef](/reference/typescript-api/configurable-operation-def/#configurableoperationdef) interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ConfigurableOperationDefOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="230" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="224" packageName="@vendure/core" />

Common configuration options used when creating a new instance of a
[ConfigurableOperationDef](/reference/typescript-api/configurable-operation-def/#configurableoperationdef) (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ConfigurableOperationDef"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="335" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="329" packageName="@vendure/core" />

A ConfigurableOperationDef is a special type of object used extensively by Vendure to define
code blocks which have arguments which are configurable at run-time by the administrator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "LocalizedStringArray"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="43" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/common/configurable-operation.ts" sourceLine="38" packageName="@vendure/core" />

An array of string values in a given [LanguageCode](/reference/typescript-api/common/language-code#languagecode), used to define human-readable string values.
The `ui` property can be used in conjunction with the Vendure Admin UI to specify a custom form input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ApiOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="79" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="80" packageName="@vendure/core" />

The ApiOptions define how the Vendure GraphQL APIs are exposed, as well as allowing the API layer
to be extended with middleware.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "EntityOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1090" packageName="@vendure/core" since="1.3.0" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1103" packageName="@vendure/core" since="1.3.0" />

Options relating to the internal handling of entities.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "RuntimeVendureConfig"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1376" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1389" packageName="@vendure/core" />

This interface represents the VendureConfig object available at run-time, i.e. the user-supplied
config values have been merged with the [defaultConfig](/reference/typescript-api/configuration/default-config#defaultconfig) values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "SystemOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1188" packageName="@vendure/core" since="1.6.0" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1201" packageName="@vendure/core" since="1.6.0" />

Options relating to system functions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "TrustProxyOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="248" packageName="@vendure/core" since="3.4.0" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="249" packageName="@vendure/core" since="3.4.0" />

Configures Express trust proxy settings when running behind a reverse proxy (usually the case with most hosting services).
Setting `trustProxy` allows you to retrieve the original IP address from the `X-Forwarded-For` header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "VendureConfig"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1229" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1242" packageName="@vendure/core" />

All possible configuration options are defined by the
[`VendureConfig`](https://github.com/vendurehq/vendure/blob/master/packages/core/src/config/vendure-config.ts) interface.
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/reference/typescript-api/entities/refund.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Refund extends VendureEntity implements HasCustomFields {
@Money() adjustment: number;
@Money() total: number;
@Column() method: string;
@Column({ nullable: true, type: 'varchar' }) destination: string | null;
@Column({ nullable: true }) reason: string;
@Column('varchar') state: RefundState;
@Column({ nullable: true }) transactionId: string;
Expand Down Expand Up @@ -70,6 +71,12 @@ class Refund extends VendureEntity implements HasCustomFields {
<MemberInfo kind="property" type={`string`} />


### destination

<MemberInfo kind="property" type={`string | null`} since="3.6.0" />

The refund destination code, if a non-default destination was used.
When null, the refund was directed to the original payment method.
### reason

<MemberInfo kind="property" type={`string`} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ImportExportOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="990" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1003" packageName="@vendure/core" />

Options related to importing & exporting data.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "JobQueueOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1014" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="1027" packageName="@vendure/core" />

Options related to the built-in job queue.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "OrderOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="562" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="563" packageName="@vendure/core" />



Expand Down
12 changes: 11 additions & 1 deletion docs/docs/reference/typescript-api/payment/payment-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "PaymentOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="914" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="915" packageName="@vendure/core" />

Defines payment-related options in the [VendureConfig](/reference/typescript-api/configuration/vendure-config#vendureconfig).

Expand All @@ -13,6 +13,7 @@ interface PaymentOptions {
customPaymentProcess?: Array<PaymentProcess<any>>;
process?: Array<PaymentProcess<any>>;
refundProcess?: Array<RefundProcess<any>>;
refundDestinations?: RefundDestinationStrategy[];
}
```

Expand Down Expand Up @@ -47,6 +48,15 @@ Takes an array of objects implementing the [PaymentProcess](/reference/typescrip

Allows the definition of custom states and transition logic for the refund process state machine.
Takes an array of objects implementing the [RefundProcess](/reference/typescript-api/payment/refund-process#refundprocess) interface.
### refundDestinations

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/payment/refund-destination-strategy#refunddestinationstrategy'>RefundDestinationStrategy</a>[]`} default={`[]`} since="3.6.0" />

Defines additional refund destination strategies. These allow refunds to be
directed to alternative destinations such as store credit, gift cards, etc.

The default destination (refund to original payment method) is always
available and does not need to be included here.


</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: "RefundDestinationStrategy"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/payment/refund-destination-strategy.ts" sourceLine="51" packageName="@vendure/core" since="3.6.0" />

A RefundDestinationStrategy defines a possible destination for a refund.
The default destination is the original payment method, but plugins can add additional
destinations such as store credit, gift cards, or vouchers.

When a non-default destination is selected, this strategy's `createRefund()` method
is called **instead of** the `PaymentMethodHandler.createRefund()`. If your destination
shares logic with an existing payment method handler (e.g. both a store-credit payment
handler and a store-credit refund destination need to call the same API), extract the
shared logic into a service and inject it into both.

*Example*

```ts
class StoreCreditRefundDestination implements RefundDestinationStrategy {
readonly code = 'store-credit';
readonly description = [
{ languageCode: LanguageCode.en, value: 'Refund as store credit' },
];

async isAvailable(ctx, order, payment) {
return payment.method !== 'store-credit-payment';
}

async createRefund(ctx, input, amount, order, payment) {
// Issue store credit to the customer
return { state: 'Settled' as const, transactionId: 'sc-123' };
}
}
```

Register in VendureConfig:
```ts
paymentOptions: {
refundDestinations: [new StoreCreditRefundDestination()],
}
```

```ts title="Signature"
interface RefundDestinationStrategy extends InjectableStrategy {
readonly code: string;
readonly description: LocalizedStringArray;
isAvailable(ctx: RequestContext, order: Order, payment: Payment): boolean | Promise<boolean>;
createRefund(
ctx: RequestContext,
input: RefundOrderInput,
amount: number,
order: Order,
payment: Payment,
): CreateRefundResult | Promise<CreateRefundResult>;
}
```
* Extends: [`InjectableStrategy`](/reference/typescript-api/common/injectable-strategy#injectablestrategy)



<div className="members-wrapper">

### code

<MemberInfo kind="property" type={`string`} />

A unique code identifying this refund destination.
### description

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/configurable-operation-def/localized-string-array#localizedstringarray'>LocalizedStringArray</a>`} />

A human-readable description of this destination, used in the admin UI.
### isAvailable

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, order: <a href='/reference/typescript-api/entities/order#order'>Order</a>, payment: <a href='/reference/typescript-api/entities/payment#payment'>Payment</a>) => boolean | Promise<boolean>`} />

Whether this destination is available for the given order and payment.
This is called when resolving the `refundDestinations` query to determine
which destinations to offer the admin.
### createRefund

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: RefundOrderInput, amount: number, order: <a href='/reference/typescript-api/entities/order#order'>Order</a>, payment: <a href='/reference/typescript-api/entities/payment#payment'>Payment</a>) => <a href='/reference/typescript-api/payment/payment-method-types#createrefundresult'>CreateRefundResult</a> | Promise<<a href='/reference/typescript-api/payment/payment-method-types#createrefundresult'>CreateRefundResult</a>>`} />

Execute the refund to this destination. Called instead of
`PaymentMethodHandler.createRefund()` when this destination is selected.

The returned [CreateRefundResult](/reference/typescript-api/payment/payment-method-types#createrefundresult) determines the refund state
and any associated transaction ID or metadata.


</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "CatalogOptions"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="763" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="764" packageName="@vendure/core" />

Options related to products and collections.

Expand Down
Loading
Loading