Skip to content

Commit 5728a4f

Browse files
committed
Adyen: new action components
1 parent 0fca082 commit 5728a4f

File tree

9 files changed

+436
-7
lines changed

9 files changed

+436
-7
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import app from "../../adyen.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "adyen-cancel-payment",
6+
name: "Cancel Payment",
7+
description: "Cancels a payment that has not yet been captured. [See the documentation](https://docs.adyen.com/api-explorer/checkout/71/post/payments/(paymentpspreference)/cancels)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
paymentPspReference: {
13+
propDefinition: [
14+
app,
15+
"paymentPspReference",
16+
],
17+
},
18+
merchantAccount: {
19+
propDefinition: [
20+
app,
21+
"merchantAccount",
22+
],
23+
},
24+
},
25+
methods: {
26+
cancelPayment({
27+
paymentPspReference, ...args
28+
} = {}) {
29+
return this.app.post({
30+
api: constants.API.CHECKOUT,
31+
path: `/payments/${paymentPspReference}/cancels`,
32+
...args,
33+
});
34+
},
35+
},
36+
async run({ $ }) {
37+
const {
38+
cancelPayment,
39+
paymentPspReference,
40+
merchantAccount,
41+
} = this;
42+
43+
const response = cancelPayment({
44+
$,
45+
paymentPspReference,
46+
data: {
47+
merchantAccount,
48+
},
49+
});
50+
$.export("$summary", "Successfully cancelled payment.");
51+
return response;
52+
},
53+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import app from "../../adyen.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "adyen-capture-payment",
6+
name: "Capture Payment",
7+
description: "Captures an authorized payment. This is typically used for delayed capture scenarios, such as when you need to verify the order before capturing the funds.",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
paymentPspReference: {
13+
propDefinition: [
14+
app,
15+
"paymentPspReference",
16+
],
17+
},
18+
merchantAccount: {
19+
propDefinition: [
20+
app,
21+
"merchantAccount",
22+
],
23+
},
24+
amountCurrency: {
25+
propDefinition: [
26+
app,
27+
"amountCurrency",
28+
],
29+
},
30+
amountValue: {
31+
propDefinition: [
32+
app,
33+
"amountValue",
34+
],
35+
},
36+
},
37+
methods: {
38+
capturePayment({
39+
paymentPspReference, ...args
40+
} = {}) {
41+
return this.app.post({
42+
api: constants.API.CHECKOUT,
43+
path: `/payments/${paymentPspReference}/captures`,
44+
...args,
45+
});
46+
},
47+
},
48+
async run({ $ }) {
49+
const {
50+
capturePayment,
51+
paymentPspReference,
52+
merchantAccount,
53+
amountCurrency,
54+
amountValue,
55+
} = this;
56+
57+
const response = await capturePayment({
58+
$,
59+
paymentPspReference,
60+
data: {
61+
merchantAccount,
62+
amount: {
63+
currency: amountCurrency,
64+
value: amountValue,
65+
},
66+
},
67+
});
68+
69+
$.export("$summary", "Successfully captured payment.");
70+
return response;
71+
},
72+
};
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import app from "../../adyen.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "adyen-create-payment",
6+
name: "Create Payment",
7+
description: "Creates a payment for a shopper. [See the documentation](https://docs.adyen.com/api-explorer/Checkout/71/post/payments)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
merchantAccount: {
13+
propDefinition: [
14+
app,
15+
"merchantAccount",
16+
],
17+
},
18+
amountCurrency: {
19+
propDefinition: [
20+
app,
21+
"amountCurrency",
22+
],
23+
},
24+
amountValue: {
25+
propDefinition: [
26+
app,
27+
"amountValue",
28+
],
29+
},
30+
reference: {
31+
type: "string",
32+
label: "Reference",
33+
description: "The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement. If you need to provide multiple references for a transaction, separate them with hyphens (`-`). Maximum length: 80 characters.",
34+
},
35+
returnUrl: {
36+
type: "string",
37+
label: "Return URL",
38+
description: "The URL to return to in case of a redirection. The format depends on the channel. For more information refer the the [documentation](https://docs.adyen.com/api-explorer/Checkout/71/post/payments#request-returnUrl).",
39+
},
40+
paymentMethodType: {
41+
propDefinition: [
42+
app,
43+
"paymentMethodType",
44+
({ merchantAccount }) => ({
45+
merchantAccount,
46+
}),
47+
],
48+
},
49+
paymentMethodDetails: {
50+
type: "object",
51+
label: "Payment Method Details",
52+
description: "The payment method details object required for submitting additional payment details. Should contain relevant payment details fields. For more information refer the the [documentation](https://docs.adyen.com/api-explorer/Checkout/71/post/payments#request-paymentMethod).",
53+
optional: true,
54+
},
55+
},
56+
methods: {
57+
createPayment(args = {}) {
58+
return this.app.post({
59+
api: constants.API.CHECKOUT,
60+
path: "/payments",
61+
...args,
62+
});
63+
},
64+
},
65+
async run({ $ }) {
66+
const {
67+
createPayment,
68+
amountCurrency,
69+
amountValue,
70+
merchantAccount,
71+
reference,
72+
returnUrl,
73+
paymentMethodType,
74+
paymentMethodDetails,
75+
} = this;
76+
77+
const response = await createPayment({
78+
$,
79+
data: {
80+
amount: {
81+
currency: amountCurrency,
82+
value: amountValue,
83+
},
84+
merchantAccount,
85+
reference,
86+
returnUrl,
87+
paymentMethod: {
88+
...paymentMethodDetails,
89+
type: paymentMethodType,
90+
},
91+
},
92+
});
93+
$.export("$summary", "Successfully created payment.");
94+
return response;
95+
},
96+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import app from "../../adyen.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "adyen-refund-payment",
6+
name: "Refund Payment",
7+
description: "Refunds a captured payment. [See the documentation](https://docs.adyen.com/api-explorer/checkout/71/post/payments/(paymentpspreference)/refunds)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
paymentPspReference: {
13+
propDefinition: [
14+
app,
15+
"paymentPspReference",
16+
],
17+
},
18+
merchantAccount: {
19+
propDefinition: [
20+
app,
21+
"merchantAccount",
22+
],
23+
},
24+
amountCurrency: {
25+
propDefinition: [
26+
app,
27+
"amountCurrency",
28+
],
29+
},
30+
amountValue: {
31+
propDefinition: [
32+
app,
33+
"amountValue",
34+
],
35+
},
36+
},
37+
methods: {
38+
refundPayment({
39+
paymentPspReference, ...args
40+
} = {}) {
41+
return this.app.post({
42+
api: constants.API.CHECKOUT,
43+
path: `/payments/${paymentPspReference}/refunds`,
44+
...args,
45+
});
46+
},
47+
},
48+
async run({ $ }) {
49+
const {
50+
refundPayment,
51+
paymentPspReference,
52+
merchantAccount,
53+
amountCurrency,
54+
amountValue,
55+
} = this;
56+
57+
const response = await refundPayment({
58+
$,
59+
paymentPspReference,
60+
data: {
61+
merchantAccount,
62+
amount: {
63+
currency: amountCurrency,
64+
value: amountValue,
65+
},
66+
},
67+
});
68+
$.export("$summary", `Successfully refunded payment with PSP Reference \`${response.paymentPspReference}\`.`);
69+
return response;
70+
},
71+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import app from "../../adyen.app.mjs";
2+
3+
export default {
4+
key: "adyen-submit-details",
5+
name: "Submit Additional Payment Details",
6+
description: "Submits additional details for a payment. [See the documentation](https://docs.adyen.com/api-explorer/checkout/71/post/payments/details)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
details: {
12+
type: "object",
13+
label: "Details",
14+
description: "Use this collection to submit the details that were returned as a result of the **Create Payment** action call.",
15+
},
16+
},
17+
methods: {
18+
submitAdditionalDetails(args = {}) {
19+
return this.app.post({
20+
path: "/payments/details",
21+
...args,
22+
});
23+
},
24+
},
25+
async run({ $ }) {
26+
const {
27+
submitAdditionalDetails,
28+
details,
29+
} = this;
30+
31+
const response = await submitAdditionalDetails({
32+
$,
33+
data: {
34+
details,
35+
},
36+
});
37+
$.export("$summary", "Successfully submitted additional payment details.");
38+
return response;
39+
},
40+
};

0 commit comments

Comments
 (0)