Skip to content

Commit d8ace68

Browse files
authored
Merge pull request #117 from mollie/revert-113-bugfix/MOL-587-staging
Revert "Bugfix/MOL-587: Resolve develop"
2 parents f6a14ba + fb403c1 commit d8ace68

25 files changed

+84
-1673
lines changed

CHANGELOG.md

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -4,201 +4,6 @@ All notable changes to this project will be documented in this file.
44

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

7-
## v1.2.1
8-
9-
Added
10-
11-
- New custom field for transaction: `sctm_transaction_refund_for_mollie_payment` which would store the Mollie Payment ID that need to be refunded
12-
13-
Fixes
14-
15-
[Create Refund](./docs/CreateRefund.md)
16-
- Handling the Refund Creation for the case that the Payment has more than one Success Charge transaction
17-
- Changing the way to determine the Create Refund action:
18-
- Before
19-
```Typescript
20-
// processor/src/utils/paymentAction.utils.ts
21-
22-
if (groups.successCharge.length === 1 && groups.initialRefund.length) {
23-
return ConnectorActions.CreateRefund;
24-
}
25-
```
26-
27-
- After
28-
```Typescript
29-
// processor/src/utils/paymentAction.utils.ts
30-
31-
if (groups.successCharge.length >= 1 && groups.initialRefund.length) {
32-
return ConnectorActions.CreateRefund;
33-
}
34-
```
35-
36-
- We are supporting to create the refund for the payment which has more than one Success Charge transactions
37-
- By default, we will create the Refund for the latest Success Charge transaction. For example:
38-
```Typescript
39-
// CommerceTools Payment
40-
{
41-
id: 'payment-id',
42-
transactions: [
43-
{
44-
type: 'Charge',
45-
state: 'Success',
46-
interactionId: 'tr_123456' // Mollie Payment ID
47-
},
48-
{
49-
type: 'Charge',
50-
state: 'Success',
51-
interactionId: 'tr_999999' // Mollie Payment ID
52-
},
53-
{
54-
type: 'Refund',
55-
state: 'Initial', // Creating a Refund for the Mollie Payment tr_999999
56-
},
57-
]
58-
}
59-
```
60-
61-
- 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:
62-
63-
```Typescript
64-
// CommerceTools Payment
65-
{
66-
id: 'payment-id',
67-
transactions: [
68-
{
69-
type: 'Charge',
70-
state: 'Success',
71-
interactionId: 'tr_123456' // Mollie Payment ID
72-
},
73-
{
74-
type: 'Charge',
75-
state: 'Success',
76-
interactionId: 'tr_999999' // Mollie Payment ID
77-
},
78-
{
79-
type: 'Refund',
80-
state: 'Initial',
81-
custom: {
82-
type: {
83-
...
84-
},
85-
fields: {
86-
sctm_transaction_refund_for_mollie_payment: 'tr_123456' // Creating a Refund for the Mollie Payment tr_123456
87-
}
88-
}
89-
},
90-
]
91-
}
92-
```
93-
94-
[Cancel Refund](./docs/CancelPaymentRefund.md)
95-
- Following the changes for creating refund, we also updated the handler for Refund Cancellation to match with the above changes
96-
- Changing the way to determine the Cancel Refund action:
97-
- Before
98-
```Typescript
99-
// processor/src/utils/paymentAction.utils.ts
100-
101-
if (
102-
groups.successCharge.length === 1 &&
103-
groups.pendingRefund.length === 1 &&
104-
groups.initialCancelAuthorization.length === 1
105-
) {
106-
return ConnectorActions.CancelRefund;
107-
}
108-
```
109-
110-
- After
111-
```Typescript
112-
// processor/src/utils/paymentAction.utils.ts
113-
114-
if (
115-
groups.successCharge.length >= 1 &&
116-
groups.pendingRefund.length >= 1 &&
117-
groups.initialCancelAuthorization.length === 1
118-
) {
119-
return ConnectorActions.CancelRefund;
120-
}
121-
```
122-
123-
- 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:
124-
```Typescript
125-
// CommerceTools Payment
126-
{
127-
id: 'payment-id',
128-
transactions: [
129-
{
130-
type: 'Charge',
131-
state: 'Success',
132-
interactionId: 'tr_123456' // Mollie Payment ID
133-
},
134-
{
135-
type: 'Charge',
136-
state: 'Success',
137-
interactionId: 'tr_999999' // Mollie Payment ID
138-
},
139-
{
140-
id: 'refund-transaction-1',
141-
type: 'Refund',
142-
state: 'Pending',
143-
interactionId: 're_123456', // Mollie Refund ID
144-
},
145-
{
146-
id: 'refund-transaction-2',
147-
type: 'Refund',
148-
state: 'Pending',
149-
interactionId: 're_999999', // Mollie Refund ID
150-
},
151-
{
152-
type: 'CancelAuthorization',
153-
state: 'Initial'
154-
// interactionId is not set
155-
}
156-
]
157-
}
158-
159-
// In this case, this will be considered as a Cancellation request for the Pending Refund with id: refund-transaction-2
160-
```
161-
__*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.__
162-
163-
- 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:
164-
```Typescript
165-
// CommerceTools Payment
166-
{
167-
id: 'payment-id',
168-
transactions: [
169-
{
170-
type: 'Charge',
171-
state: 'Success',
172-
interactionId: 'tr_123456' // Mollie Payment ID
173-
},
174-
{
175-
type: 'Charge',
176-
state: 'Success',
177-
interactionId: 'tr_999999' // Mollie Payment ID
178-
},
179-
{
180-
id: 'refund-transaction-1',
181-
type: 'Refund',
182-
state: 'Pending',
183-
interactionId: 're_123456', // Mollie Refund ID
184-
},
185-
{
186-
id: 'refund-transaction-2',
187-
type: 'Refund',
188-
state: 'Pending',
189-
interactionId: 're_999999', // Mollie Refund ID
190-
},
191-
{
192-
type: 'CancelAuthorization',
193-
state: 'Initial',
194-
interactionId: 're_123456' // Mollie Refund ID that you want to cancel
195-
}
196-
]
197-
}
198-
199-
// In this case, this will be considered as a Cancellation request for the Pending Refund with id: refund-transaction-1
200-
```
201-
2027
## v1.2.0
2038

2049
Added

application/custom-application-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const config = {
1515
cloudIdentifier: CLOUD_IDENTIFIER,
1616
env: {
1717
development: {
18-
initialProjectKey: 'your_project_key',
18+
initialProjectKey: 'shopm-adv-windev',
1919
},
2020
production: {
2121
applicationId: CUSTOM_APPLICATION_ID,

application/cypress/fixtures/fetch-project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,4 @@
420420
"__typename": "Project"
421421
}
422422
}
423-
}
423+
}

application/src/components/welcome/welcome.tsx

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DataTable from '@commercetools-uikit/data-table';
1717
import IconButton from '@commercetools-uikit/icon-button';
1818
import { usePaymentMethodsFetcher } from '../../hooks/use-mollie-connector';
1919
import { ContentNotification } from '@commercetools-uikit/notifications';
20-
import { CustomMethodObject, CustomObjectUpdaterError } from '../../types/app';
20+
import { CustomMethodObject } from '../../types/app';
2121
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
2222
import Tootltip from '@commercetools-uikit/tooltip';
2323
import {
@@ -74,7 +74,7 @@ const Welcome = () => {
7474
key: 'key',
7575
order: 'asc',
7676
});
77-
const { customObjectsPaginatedResult, error, loading, refetch } =
77+
const { customObjectsPaginatedResult, error, loading } =
7878
useCustomObjectsFetcher({
7979
page,
8080
perPage,
@@ -110,13 +110,7 @@ const Welcome = () => {
110110
value: JSON.stringify(method),
111111
})
112112
.catch((error) => {
113-
Object.values(error).forEach((e) => {
114-
console.error(
115-
`SCTM custom application: ${
116-
(e as CustomObjectUpdaterError).message
117-
}`
118-
);
119-
});
113+
console.error(`Error creating custom object: ${error}`);
120114
});
121115
return method;
122116
} else {
@@ -126,15 +120,9 @@ const Welcome = () => {
126120
}
127121
})
128122
);
129-
refetch();
130123
setMethods(updatedMethods);
131124
}
132-
}, [
133-
customObjectUpdater,
134-
customObjectsPaginatedResult?.results,
135-
fetchedData,
136-
refetch,
137-
]);
125+
}, [customObjectUpdater, customObjectsPaginatedResult?.results, fetchedData]);
138126

139127
useEffect(() => {
140128
if (
@@ -224,13 +212,13 @@ const Welcome = () => {
224212
sortDirection={tableSorting.value.order}
225213
onSortChange={tableSorting.onChange}
226214
onRowClick={(row) => {
227-
const target = customObjectsPaginatedResult?.results.filter(
228-
(obj) => obj.key === row.id
215+
push(
216+
`${match.url}/${
217+
customObjectsPaginatedResult?.results.filter(
218+
(obj) => obj.key === row.id
219+
)?.[0]?.id
220+
}/general`
229221
);
230-
231-
if (target) {
232-
push(`${match.url}/${target[0].id}/general`);
233-
}
234222
}}
235223
/>
236224
<Switch>

application/src/hooks/use-custom-objects-connector/use-custom-objects-connector.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import FetchCustomObjectsQuery from './fetch-custom-objects.ctp.graphql';
2121
import FetchCustomObjectDetailsQuery from './fetch-custom-object-details.ctp.graphql';
2222
import UpdateCustomObjectDetailsMutation from './update-custom-object-details.ctp.graphql';
2323
import RemoveCustomObjectDetailsMutation from './remove-custom-object-details.ctp.graphql';
24-
import { ApolloError, ApolloQueryResult } from '@apollo/client';
24+
import { ApolloError } from '@apollo/client';
2525
import { extractErrorFromGraphQlResponse } from '../../helpers';
2626

2727
type PaginationAndSortingProps = {
@@ -37,7 +37,6 @@ type TUseCustomObjectsFetcher = (
3737
customObjectsPaginatedResult?: TFetchCustomObjectsQuery['customObjects'];
3838
error?: ApolloError;
3939
loading: boolean;
40-
refetch: () => Promise<ApolloQueryResult<TFetchCustomObjectsQuery>>;
4140
};
4241

4342
export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
@@ -46,7 +45,7 @@ export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
4645
tableSorting,
4746
container,
4847
}) => {
49-
const { data, error, loading, refetch } = useMcQuery<
48+
const { data, error, loading } = useMcQuery<
5049
TFetchCustomObjectsQuery,
5150
TFetchCustomObjectsQueryVariables
5251
>(FetchCustomObjectsQuery, {
@@ -65,7 +64,6 @@ export const useCustomObjectsFetcher: TUseCustomObjectsFetcher = ({
6564
customObjectsPaginatedResult: data?.customObjects,
6665
error,
6766
loading,
68-
refetch,
6967
};
7068
};
7169
type TUseCustomObjectDetailsFetcher = (id: string) => {

application/src/hooks/use-mollie-connector/use-mollie-connector.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
CustomMethodObject,
1616
MollieResult,
1717
SupportedPaymentMethods,
18-
GooglePay,
1918
} from '../../types/app';
2019

2120
/**
@@ -46,8 +45,6 @@ const convertMollieMethodToCustomMethod = (
4645
method.status === 'activated' &&
4746
SupportedPaymentMethods[method.id as SupportedPaymentMethods]
4847
);
49-
50-
availableMethods.push(GooglePay);
5148
return availableMethods.map((method: MollieMethod) => ({
5249
id: method.id,
5350
technicalName: method.description,

0 commit comments

Comments
 (0)