Skip to content

Commit f60fdb4

Browse files
committed
[Usability Audit] Stripe
1 parent d7fb0e1 commit f60fdb4

File tree

39 files changed

+1661
-776
lines changed

39 files changed

+1661
-776
lines changed

components/stripe/actions/cancel-payment-intent/cancel-payment-intent.mjs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pick from "lodash.pick";
21
import app from "../../stripe.app.mjs";
32

43
export default {
@@ -16,22 +15,27 @@ export default {
1615
id: {
1716
propDefinition: [
1817
app,
19-
"payment_intent",
18+
"paymentIntent",
2019
],
2120
optional: false,
2221
},
23-
cancellation_reason: {
22+
cancellationReason: {
2423
propDefinition: [
2524
app,
26-
"payment_intent_cancellation_reason",
25+
"paymentIntentCancellationReason",
2726
],
2827
},
2928
},
3029
async run({ $ }) {
31-
const params = pick(this, [
32-
"cancellation_reason",
33-
]);
34-
const resp = await this.app.sdk().paymentIntents.cancel(this.id, params);
30+
const {
31+
app,
32+
id,
33+
cancellationReason,
34+
} = this;
35+
36+
const resp = await app.sdk().paymentIntents.cancel(id, {
37+
cancellation_reason: cancellationReason,
38+
});
3539
$.export("$summary", "Successfully cancelled payment intent");
3640
return resp;
3741
},

components/stripe/actions/capture-payment-intent/capture-payment-intent.mjs

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import pick from "lodash.pick";
21
import app from "../../stripe.app.mjs";
3-
import utils from "../../common/utils.mjs";
42

53
export default {
64
key: "stripe-capture-payment-intent",
@@ -14,39 +12,81 @@ export default {
1412
id: {
1513
propDefinition: [
1614
app,
17-
"payment_intent",
15+
"paymentIntent",
1816
],
1917
optional: false,
2018
},
21-
amount_to_capture: {
19+
amountToCapture: {
20+
description: "The amount to capture from the PaymentIntent, which must be less than or equal to the original amount. Defaults to the full `amount_capturable` if it's not provided.",
2221
propDefinition: [
2322
app,
2423
"amount",
2524
],
26-
description: "The amount to capture, which must be less than or equal to the original " +
27-
"amount. Any additional amount will be automatically refunded. Defaults to the full " +
28-
"`amount_capturable` if not provided.",
2925
},
30-
advanced: {
26+
metadata: {
3127
propDefinition: [
3228
app,
3329
"metadata",
3430
],
35-
label: "Advanced Options",
36-
description: "Specify less-common options that you require. See [Capture a PaymentIntent]" +
37-
"(https://stripe.com/docs/api/payment_intents/capture) for a list of supported options.",
31+
},
32+
applicationFeeAmount: {
33+
type: "integer",
34+
label: "Application Fee Amount",
35+
description: "The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner’s Stripe account. The amount of the application fee collected will be capped at the total amount captured. For more information, see the PaymentIntents use case for connected accounts.",
36+
optional: true,
37+
},
38+
finalCapture: {
39+
type: "boolean",
40+
label: "Final Capture",
41+
description: "When capturing a PaymentIntent, setting final_capture to false notifies Stripe to not release the remaining uncaptured funds to make sure that they're captured in future requests. You can only use this setting when multicapture is available for PaymentIntents.",
42+
optional: true,
43+
},
44+
statementDescriptor: {
45+
propDefinition: [
46+
app,
47+
"statementDescriptor",
48+
],
49+
},
50+
statementDescriptorSuffix: {
51+
type: "string",
52+
label: "Statement Descriptor Suffix",
53+
description: "Provides information about a card charge. Concatenated to the account’s statement descriptor prefix to form the complete statement descriptor that appears on the customer’s statement.",
54+
optional: true,
55+
},
56+
transferDataAmount: {
57+
type: "integer",
58+
label: "Transfer Data Amount",
59+
description: "The amount that will be transferred automatically when a charge succeeds.",
60+
optional: true,
3861
},
3962
},
4063
async run({ $ }) {
41-
const params = pick(this, [
42-
"amount_to_capture",
43-
]);
44-
const resp = await this.app.sdk().paymentIntents.capture(this.id, {
45-
...params,
46-
...utils.parseJson(this.advanced),
64+
const {
65+
id,
66+
amountToCapture,
67+
metadata,
68+
applicationFeeAmount,
69+
finalCapture,
70+
statementDescriptor,
71+
statementDescriptorSuffix,
72+
transferDataAmount,
73+
} = this;
74+
75+
const resp = await this.app.sdk().paymentIntents.capture(id, {
76+
amount_to_capture: amountToCapture,
77+
metadata,
78+
application_fee_amount: applicationFeeAmount,
79+
final_capture: finalCapture,
80+
statement_descriptor: statementDescriptor,
81+
statement_descriptor_suffix: statementDescriptorSuffix,
82+
...(transferDataAmount && {
83+
transfer_data: {
84+
amount: transferDataAmount,
85+
},
86+
}),
4787
});
48-
$.export("$summary", `Successfully captured ${params.amount_to_capture
49-
? params.amount_to_capture
88+
$.export("$summary", `Successfully captured ${amountToCapture
89+
? amountToCapture
5090
: `the full ${resp.amount_capturable}`} from the payment intent`);
5191
return resp;
5292
},

0 commit comments

Comments
 (0)