generated from axonivy-market/market-product
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91774b6
commit 568a2f0
Showing
4 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
stripe-connector-demo/src/com/axonivy/connector/stripe/controller/StripeApiEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.axonivy.connector.stripe.controller; | ||
|
||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
|
||
import com.axonivy.connector.stripe.service.PaymentService; | ||
import com.stripe.model.checkout.Session; | ||
import com.stripe.param.checkout.SessionCreateParams; | ||
|
||
@Path("/stripe") | ||
public class StripeApiEndpoint { | ||
// @POST | ||
// @Path("/create-checkout-session") | ||
// @Produces("application/json") | ||
// public Response createCheckoutSession() { | ||
// try { | ||
// SessionCreateParams params = SessionCreateParams.builder().setMode(SessionCreateParams.Mode.PAYMENT) | ||
// .setSuccessUrl("https://yourdomain.com/success").setCancelUrl("https://yourdomain.com/cancel") | ||
// .addLineItem(SessionCreateParams.LineItem | ||
// .builder().setQuantity( | ||
// 1L) | ||
// .setPriceData(SessionCreateParams.LineItem.PriceData.builder().setCurrency("usd") | ||
// .setUnitAmount(2000L) // Amount in cents | ||
// .setProductData(SessionCreateParams.LineItem.PriceData.ProductData.builder() | ||
// .setName("Product Name").build()) | ||
// .build()) | ||
// .build()) | ||
// .build(); | ||
// | ||
// Session session = Session.create(params); | ||
// return Response.ok("{\"id\":\"" + session.getId() + "\"}").build(); | ||
// } catch (Exception e) { | ||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); | ||
// } | ||
// } | ||
|
||
@POST | ||
@Path("/create-checkout-session/{priceId}/{quantity}") | ||
@Produces("application/json") | ||
public Response createCheckoutSession(@PathParam("priceId") String priceId, @PathParam("quantity") Long quantity) { | ||
try { | ||
Session session = PaymentService.getInstance().createCheckoutSession(priceId, quantity); | ||
return Response.ok("{\"id\":\"" + session.getId() + "\"}").build(); | ||
} catch (Exception e) { | ||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters