Skip to content

Charge a credit card with Stripe#1556

Merged
KevinGilmore merged 4 commits into
eugenp:masterfrom
lsoares:charge-cc-with-stripe
Apr 20, 2017
Merged

Charge a credit card with Stripe#1556
KevinGilmore merged 4 commits into
eugenp:masterfrom
lsoares:charge-cc-with-stripe

Conversation

@lsoares

@lsoares lsoares commented Apr 1, 2017

Copy link
Copy Markdown
Contributor

Spring Boot project that includes Stripe Java library and does a charge to a credit card.

BAEL-742

@KevinGilmore KevinGilmore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments within individual files for details on the requested changes.

Comment thread stripe/pom.xml Outdated
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's omit dev-tools from the module

Comment thread stripe/pom.xml Outdated
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>4.0.0</version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest now is 4.2.0

th:attr='data-key=${stripePublicKey},
data-amount=${amount},
data-currency=${currency}'
data-name='Baldung'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Baeldung (spelling)

<input type='hidden' th:value='${amount}' name='amount' />
<label>Price:<span th:text='${amount/100}' /></label>
<!-- NOTE: data-key/data-amount/data-currency will be rendered by Thymeleaf -->
<script

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is supported elsewhere now, It's more typical to have a <script> tag in the section.
Either way, you do need a closing </script> tag instead of the shortcut <script ... />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which section should it be at? I could not understand.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to say that I've only seen <script> tags in the tag (sorry, I know I typed that in the comment but must have erased it before I submitted it) -- then again, I have been out of the UI side of web dev for a few years ;) so I will defer to you as to its placement.
But I am reasonably sure that you do still need the closing </script> tag -- the shorthand form will not be interpreted correctly -- I've experienced this firsthand, and everything I've read on stackoverflow and other sites claims that this is still the case today.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean inside head tag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not common to have scripts inside forms but look at their example :)

@KevinGilmore KevinGilmore Apr 11, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes, the placement within the form tag is fine. Notice in their example the closing script tag.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the enclosing script I did it right away. Thanks​. Will push when I implemented your suggestion of amount.

@lsoarestd

Copy link
Copy Markdown

@KevinGilmore can you check now? thx

@KevinGilmore KevinGilmore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See files for details.

@@ -0,0 +1,33 @@
package com.baeldung;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move all classes to the package com.baeldung.stripe

@Value("${STRIPE_SECRET_KEY}")
private String secretKey;

public void charge(ChargeRequest chargeRequest)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return the Charge object returned by Charge.create(...)

</head>
<body>
<div th:if='${error}' th:text='${error}' style='color: red;'></div>
<div th:unless='${error}' style='color: green;'>Success!</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an idea: If you return the Charge object from the StripeService to the ChargeController, you could use some of the Charge response data to populate additional elements in the model for the result page. I don't know what's interesting to show, but you could pick something (maybe the charge id?) of interest.
What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. I'll take a look at their response data.

lsoarestd and others added 4 commits April 16, 2017 12:06
Spring Boot project that includes Stripe Java library and does a
charge to a credit card.

BAEL-742
@KevinGilmore KevinGilmore merged commit 4b19cb6 into eugenp:master Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants