Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Bugfix/MOL-587: Resolve develop" #116

Closed
wants to merge 1 commit into from
Closed
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
195 changes: 0 additions & 195 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,201 +4,6 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## v1.2.1

Added

- New custom field for transaction: `sctm_transaction_refund_for_mollie_payment` which would store the Mollie Payment ID that need to be refunded

Fixes

[Create Refund](./docs/CreateRefund.md)
- Handling the Refund Creation for the case that the Payment has more than one Success Charge transaction
- Changing the way to determine the Create Refund action:
- Before
```Typescript
// processor/src/utils/paymentAction.utils.ts

if (groups.successCharge.length === 1 && groups.initialRefund.length) {
return ConnectorActions.CreateRefund;
}
```

- After
```Typescript
// processor/src/utils/paymentAction.utils.ts

if (groups.successCharge.length >= 1 && groups.initialRefund.length) {
return ConnectorActions.CreateRefund;
}
```

- We are supporting to create the refund for the payment which has more than one Success Charge transactions
- By default, we will create the Refund for the latest Success Charge transaction. For example:
```Typescript
// CommerceTools Payment
{
id: 'payment-id',
transactions: [
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_123456' // Mollie Payment ID
},
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_999999' // Mollie Payment ID
},
{
type: 'Refund',
state: 'Initial', // Creating a Refund for the Mollie Payment tr_999999
},
]
}
```

- However, you can also specify the Mollie Payment ID (which stored in the `interactionId` of the Success Charge transaction) that you want to create a refund for by adding the Mollie Payment ID to the custom field `sctm_transaction_refund_for_mollie_payment` of the Initial Refund transaction. For example:

```Typescript
// CommerceTools Payment
{
id: 'payment-id',
transactions: [
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_123456' // Mollie Payment ID
},
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_999999' // Mollie Payment ID
},
{
type: 'Refund',
state: 'Initial',
custom: {
type: {
...
},
fields: {
sctm_transaction_refund_for_mollie_payment: 'tr_123456' // Creating a Refund for the Mollie Payment tr_123456
}
}
},
]
}
```

[Cancel Refund](./docs/CancelPaymentRefund.md)
- Following the changes for creating refund, we also updated the handler for Refund Cancellation to match with the above changes
- Changing the way to determine the Cancel Refund action:
- Before
```Typescript
// processor/src/utils/paymentAction.utils.ts

if (
groups.successCharge.length === 1 &&
groups.pendingRefund.length === 1 &&
groups.initialCancelAuthorization.length === 1
) {
return ConnectorActions.CancelRefund;
}
```

- After
```Typescript
// processor/src/utils/paymentAction.utils.ts

if (
groups.successCharge.length >= 1 &&
groups.pendingRefund.length >= 1 &&
groups.initialCancelAuthorization.length === 1
) {
return ConnectorActions.CancelRefund;
}
```

- To support the old versions, we will create the cancellation for the latest Pending Refund transaction (which is a pending refund for the latest Success Charge transaction in that payment). For example:
```Typescript
// CommerceTools Payment
{
id: 'payment-id',
transactions: [
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_123456' // Mollie Payment ID
},
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_999999' // Mollie Payment ID
},
{
id: 'refund-transaction-1',
type: 'Refund',
state: 'Pending',
interactionId: 're_123456', // Mollie Refund ID
},
{
id: 'refund-transaction-2',
type: 'Refund',
state: 'Pending',
interactionId: 're_999999', // Mollie Refund ID
},
{
type: 'CancelAuthorization',
state: 'Initial'
// interactionId is not set
}
]
}

// In this case, this will be considered as a Cancellation request for the Pending Refund with id: refund-transaction-2
```
__*Note:* The above solution is just for supporting the old versions and will be remove in the near future (in next versions). From this version, please follow the below solution.__

- However, to do it in a correct way, from this version, you should specify the Mollie Refund ID (which stored in the `interactionId` of the Pending Refund transaction) that you want to cancel by putting it in the `interactionId` of the Initial CancelAuthorization. For example:
```Typescript
// CommerceTools Payment
{
id: 'payment-id',
transactions: [
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_123456' // Mollie Payment ID
},
{
type: 'Charge',
state: 'Success',
interactionId: 'tr_999999' // Mollie Payment ID
},
{
id: 'refund-transaction-1',
type: 'Refund',
state: 'Pending',
interactionId: 're_123456', // Mollie Refund ID
},
{
id: 'refund-transaction-2',
type: 'Refund',
state: 'Pending',
interactionId: 're_999999', // Mollie Refund ID
},
{
type: 'CancelAuthorization',
state: 'Initial',
interactionId: 're_123456' // Mollie Refund ID that you want to cancel
}
]
}

// In this case, this will be considered as a Cancellation request for the Pending Refund with id: refund-transaction-1
```

## v1.2.0

Added
Expand Down
2 changes: 1 addition & 1 deletion application/custom-application-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = {
cloudIdentifier: CLOUD_IDENTIFIER,
env: {
development: {
initialProjectKey: 'your_project_key',
initialProjectKey: 'shopm-adv-windev',
},
production: {
applicationId: CUSTOM_APPLICATION_ID,
Expand Down
2 changes: 1 addition & 1 deletion application/cypress/fixtures/fetch-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,4 @@
"__typename": "Project"
}
}
}
}
32 changes: 10 additions & 22 deletions application/src/components/welcome/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import DataTable from '@commercetools-uikit/data-table';
import IconButton from '@commercetools-uikit/icon-button';
import { usePaymentMethodsFetcher } from '../../hooks/use-mollie-connector';
import { ContentNotification } from '@commercetools-uikit/notifications';
import { CustomMethodObject, CustomObjectUpdaterError } from '../../types/app';
import { CustomMethodObject } from '../../types/app';
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
import Tootltip from '@commercetools-uikit/tooltip';
import {
Expand Down Expand Up @@ -74,7 +74,7 @@ const Welcome = () => {
key: 'key',
order: 'asc',
});
const { customObjectsPaginatedResult, error, loading, refetch } =
const { customObjectsPaginatedResult, error, loading } =
useCustomObjectsFetcher({
page,
perPage,
Expand Down Expand Up @@ -110,13 +110,7 @@ const Welcome = () => {
value: JSON.stringify(method),
})
.catch((error) => {
Object.values(error).forEach((e) => {
console.error(
`SCTM custom application: ${
(e as CustomObjectUpdaterError).message
}`
);
});
console.error(`Error creating custom object: ${error}`);
});
return method;
} else {
Expand All @@ -126,15 +120,9 @@ const Welcome = () => {
}
})
);
refetch();
setMethods(updatedMethods);
}
}, [
customObjectUpdater,
customObjectsPaginatedResult?.results,
fetchedData,
refetch,
]);
}, [customObjectUpdater, customObjectsPaginatedResult?.results, fetchedData]);

useEffect(() => {
if (
Expand Down Expand Up @@ -224,13 +212,13 @@ const Welcome = () => {
sortDirection={tableSorting.value.order}
onSortChange={tableSorting.onChange}
onRowClick={(row) => {
const target = customObjectsPaginatedResult?.results.filter(
(obj) => obj.key === row.id
push(
`${match.url}/${
customObjectsPaginatedResult?.results.filter(
(obj) => obj.key === row.id
)?.[0]?.id
}/general`
);

if (target) {
push(`${match.url}/${target[0].id}/general`);
}
}}
/>
<Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import FetchCustomObjectsQuery from './fetch-custom-objects.ctp.graphql';
import FetchCustomObjectDetailsQuery from './fetch-custom-object-details.ctp.graphql';
import UpdateCustomObjectDetailsMutation from './update-custom-object-details.ctp.graphql';
import RemoveCustomObjectDetailsMutation from './remove-custom-object-details.ctp.graphql';
import { ApolloError, ApolloQueryResult } from '@apollo/client';
import { ApolloError } from '@apollo/client';
import { extractErrorFromGraphQlResponse } from '../../helpers';

type PaginationAndSortingProps = {
Expand All @@ -37,7 +37,6 @@ type TUseCustomObjectsFetcher = (
customObjectsPaginatedResult?: TFetchCustomObjectsQuery['customObjects'];
error?: ApolloError;
loading: boolean;
refetch: () => Promise<ApolloQueryResult<TFetchCustomObjectsQuery>>;
};

export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
Expand All @@ -46,7 +45,7 @@ export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
tableSorting,
container,
}) => {
const { data, error, loading, refetch } = useMcQuery<
const { data, error, loading } = useMcQuery<
TFetchCustomObjectsQuery,
TFetchCustomObjectsQueryVariables
>(FetchCustomObjectsQuery, {
Expand All @@ -65,7 +64,6 @@ export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
customObjectsPaginatedResult: data?.customObjects,
error,
loading,
refetch,
};
};
type TUseCustomObjectDetailsFetcher = (id: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
CustomMethodObject,
MollieResult,
SupportedPaymentMethods,
GooglePay,
} from '../../types/app';

/**
Expand Down Expand Up @@ -46,8 +45,6 @@ const convertMollieMethodToCustomMethod = (
method.status === 'activated' &&
SupportedPaymentMethods[method.id as SupportedPaymentMethods]
);

availableMethods.push(GooglePay);
return availableMethods.map((method: MollieMethod) => ({
id: method.id,
technicalName: method.description,
Expand Down
Loading
Loading