-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathadyen.app.mjs
74 lines (73 loc) · 2.22 KB
/
adyen.app.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import adyen from "@adyen/api-library";
export default {
type: "app",
app: "adyen",
propDefinitions: {
merchantAccount: {
type: "string",
label: "Merchant Account",
description: "The merchant account identifier, with which you want to process the transaction.",
},
amountCurrency: {
type: "string",
label: "Currency",
description: "The currency of the payment amount. The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).",
},
amountValue: {
type: "integer",
label: "Value",
description: "The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes).",
},
paymentMethodType: {
type: "string",
label: "Payment Method Type",
description: "The payment method used for the payment. For example `scheme` or `paypal`. For the full list of payment methods, refer to the [documentation](https://docs.adyen.com/api-explorer/Checkout/71/post/payments#request-paymentMethod).",
async options({ merchantAccount }) {
if (!merchantAccount) {
return [];
}
const { paymentMethods } = await this.listPaymentMethods({
data: {
merchantAccount,
},
});
return paymentMethods.map(({
name: label, type: value,
}) => ({
label,
value,
}));
},
},
paymentPspReference: {
type: "string",
label: "Payment PSP Reference",
description: "The PSP reference of the payment for which you want to perform the action.",
},
},
methods: {
getClient() {
const {
api_key: apiKey,
live_endpoint_url_prefix: liveEndpointUrlPrefix,
environment,
} = this.$auth;
const isLiveEnv = environment === "LIVE";
return new adyen.Client({
apiKey,
environment,
...(isLiveEnv && {
liveEndpointUrlPrefix,
}),
});
},
getCheckoutAPI() {
return new adyen.CheckoutAPI(this.getClient());
},
listPaymentMethods({
data, options,
} = {}) {
return this.getCheckoutAPI().PaymentsApi.paymentMethods(data, options);
},
},
};