Skip to content

Commit faf4bbb

Browse files
committed
Adyen: new action components
1 parent 6c50492 commit faf4bbb

File tree

8 files changed

+408
-7
lines changed

8 files changed

+408
-7
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../adyen.app.mjs";
2+
3+
export default {
4+
key: "adyen-cancel-payment",
5+
name: "Cancel Payment",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
paymentPspReference: {
12+
propDefinition: [
13+
app,
14+
"paymentPspReference",
15+
],
16+
},
17+
merchantAccount: {
18+
propDefinition: [
19+
app,
20+
"merchantAccount",
21+
],
22+
},
23+
},
24+
methods: {
25+
cancelPayment({
26+
paymentPspReference, ...args
27+
} = {}) {
28+
return this.app.post({
29+
path: `/payments/${paymentPspReference}/cancels`,
30+
...args,
31+
});
32+
},
33+
},
34+
async run({ $ }) {
35+
const {
36+
cancelPayment,
37+
paymentPspReference,
38+
merchantAccount,
39+
} = this;
40+
41+
const response = await cancelPayment({
42+
$,
43+
paymentPspReference,
44+
data: {
45+
merchantAccount,
46+
},
47+
});
48+
$.export("$summary", "Successfully cancelled payment.");
49+
return response;
50+
},
51+
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import app from "../../adyen.app.mjs";
2+
3+
export default {
4+
key: "adyen-capture-payment",
5+
name: "Capture Payment",
6+
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.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
paymentPspReference: {
12+
propDefinition: [
13+
app,
14+
"paymentPspReference",
15+
],
16+
},
17+
merchantAccount: {
18+
propDefinition: [
19+
app,
20+
"merchantAccount",
21+
],
22+
},
23+
amountCurrency: {
24+
propDefinition: [
25+
app,
26+
"amountCurrency",
27+
],
28+
},
29+
amountValue: {
30+
propDefinition: [
31+
app,
32+
"amountValue",
33+
],
34+
},
35+
},
36+
methods: {
37+
capturePayment({
38+
paymentPspReference, ...args
39+
} = {}) {
40+
return this.app.post({
41+
path: `/payments/${paymentPspReference}/captures`,
42+
...args,
43+
});
44+
},
45+
},
46+
async run({ $ }) {
47+
const {
48+
capturePayment,
49+
paymentPspReference,
50+
merchantAccount,
51+
amountCurrency,
52+
amountValue,
53+
} = this;
54+
55+
const response = await capturePayment({
56+
$,
57+
paymentPspReference,
58+
data: {
59+
merchantAccount,
60+
amount: {
61+
currency: amountCurrency,
62+
value: amountValue,
63+
},
64+
},
65+
});
66+
67+
$.export("$summary", "Successfully captured payment.");
68+
return response;
69+
},
70+
};
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import app from "../../adyen.app.mjs";
2+
3+
export default {
4+
key: "adyen-create-payment",
5+
name: "Create Payment",
6+
description: "Creates a payment for a shopper. [See the documentation](https://docs.adyen.com/api-explorer/Checkout/71/post/payments)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
merchantAccount: {
12+
propDefinition: [
13+
app,
14+
"merchantAccount",
15+
],
16+
},
17+
amountCurrency: {
18+
propDefinition: [
19+
app,
20+
"amountCurrency",
21+
],
22+
},
23+
amountValue: {
24+
propDefinition: [
25+
app,
26+
"amountValue",
27+
],
28+
},
29+
reference: {
30+
type: "string",
31+
label: "Reference",
32+
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.",
33+
},
34+
returnUrl: {
35+
type: "string",
36+
label: "Return URL",
37+
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).",
38+
},
39+
paymentMethodType: {
40+
propDefinition: [
41+
app,
42+
"paymentMethodType",
43+
({ merchantAccount }) => ({
44+
merchantAccount,
45+
}),
46+
],
47+
},
48+
paymentMethodDetails: {
49+
type: "object",
50+
label: "Payment Method Details",
51+
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).",
52+
optional: true,
53+
},
54+
},
55+
methods: {
56+
createPayment(args = {}) {
57+
return this.app.post({
58+
path: "/payments",
59+
...args,
60+
});
61+
},
62+
},
63+
async run({ $ }) {
64+
const {
65+
createPayment,
66+
amountCurrency,
67+
amountValue,
68+
merchantAccount,
69+
reference,
70+
returnUrl,
71+
paymentMethodType,
72+
paymentMethodDetails,
73+
} = this;
74+
75+
const response = await createPayment({
76+
$,
77+
data: {
78+
amount: {
79+
currency: amountCurrency,
80+
value: amountValue,
81+
},
82+
merchantAccount,
83+
reference,
84+
returnUrl,
85+
paymentMethod: {
86+
...paymentMethodDetails,
87+
type: paymentMethodType,
88+
},
89+
},
90+
});
91+
$.export("$summary", "Successfully created payment.");
92+
return response;
93+
},
94+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import app from "../../adyen.app.mjs";
2+
3+
export default {
4+
key: "adyen-refund-payment",
5+
name: "Refund Payment",
6+
description: "Refunds a captured payment. [See the documentation](https://docs.adyen.com/api-explorer/checkout/71/post/payments/(paymentpspreference)/refunds)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
paymentPspReference: {
12+
propDefinition: [
13+
app,
14+
"paymentPspReference",
15+
],
16+
},
17+
merchantAccount: {
18+
propDefinition: [
19+
app,
20+
"merchantAccount",
21+
],
22+
},
23+
amountCurrency: {
24+
propDefinition: [
25+
app,
26+
"amountCurrency",
27+
],
28+
},
29+
amountValue: {
30+
propDefinition: [
31+
app,
32+
"amountValue",
33+
],
34+
},
35+
},
36+
methods: {
37+
refundPayment({
38+
paymentPspReference, ...args
39+
} = {}) {
40+
return this.app.post({
41+
path: `/payments/${paymentPspReference}/refunds`,
42+
...args,
43+
});
44+
},
45+
},
46+
async run({ $ }) {
47+
const {
48+
refundPayment,
49+
paymentPspReference,
50+
merchantAccount,
51+
amountCurrency,
52+
amountValue,
53+
} = this;
54+
55+
const response = await refundPayment({
56+
$,
57+
paymentPspReference,
58+
data: {
59+
merchantAccount,
60+
amount: {
61+
currency: amountCurrency,
62+
value: amountValue,
63+
},
64+
},
65+
});
66+
$.export("$summary", `Successfully refunded payment with PSP Reference \`${response.paymentPspReference}\`.`);
67+
return response;
68+
},
69+
};
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)