Created
November 20, 2024 15:53
-
-
Save btoconnor/d1bcd701980d25907ac25e865d189a18 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/marketplace-server/src/main/java/com/tidal/marketplace/service/stripe/StripeService.java b/marketplace-server/src/main/java/com/tidal/marketplace/service/stripe/StripeService.java | |
index 62865df..70392e5 100644 | |
--- a/marketplace-server/src/main/java/com/tidal/marketplace/service/stripe/StripeService.java | |
+++ b/marketplace-server/src/main/java/com/tidal/marketplace/service/stripe/StripeService.java | |
@@ -12,65 +12,78 @@ import com.stripe.param.AccountCreateParams; | |
import com.stripe.param.AccountLinkCreateParams; | |
import com.stripe.param.checkout.SessionCreateParams; | |
import com.tidal.marketplace.exception.MarketplaceException; | |
import com.tidal.marketplace.model.db.ListingEntity; | |
import com.tidal.marketplace.model.db.ListingOfferingEntity; | |
import lombok.RequiredArgsConstructor; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.stereotype.Component; | |
@Slf4j | |
@Component | |
@RequiredArgsConstructor | |
public class StripeService { | |
+ private final String DIGITAL_MUSIC_MCC = "5815"; | |
+ | |
private final StripeClient stripeClient; | |
public Account createAccount() { | |
var accountCreateParams = AccountCreateParams.builder() | |
.setController(AccountCreateParams.Controller.builder() | |
.setStripeDashboard(AccountCreateParams.Controller.StripeDashboard.builder() | |
.setType(AccountCreateParams.Controller.StripeDashboard.Type.EXPRESS) | |
.build() | |
) | |
.setFees(AccountCreateParams.Controller.Fees.builder() | |
.setPayer(AccountCreateParams.Controller.Fees.Payer.APPLICATION) | |
.build() | |
) | |
.setLosses(AccountCreateParams.Controller.Losses.builder() | |
.setPayments(AccountCreateParams.Controller.Losses.Payments.APPLICATION) | |
.build() | |
) | |
.build() | |
) | |
+ .setBusinessProfile( | |
+ AccountCreateParams.BusinessProfile.builder() | |
+ .setMcc(DIGITAL_MUSIC_MCC) | |
+ .setUrl("https://accessible.stripe.com") | |
+ .build() | |
+ ) | |
.build(); | |
try { | |
return stripeClient.accounts().create(accountCreateParams); | |
} catch (StripeException e) { | |
throw new MarketplaceException(HttpStatus.BAD_REQUEST, | |
String.format("Failed to create seller in Stripe: %s", e.getMessage()), e); | |
} | |
} | |
public AccountLink createAccountLink(String stripeAccountId, String refreshUrl, String returnUrl) { | |
var accountLinkCreateParams = AccountLinkCreateParams.builder() | |
.setAccount(stripeAccountId) | |
.setReturnUrl(returnUrl + stripeAccountId) | |
.setRefreshUrl(refreshUrl + stripeAccountId) | |
.setType(AccountLinkCreateParams.Type.ACCOUNT_ONBOARDING) | |
+ .setCollectionOptions( | |
+ AccountLinkCreateParams.CollectionOptions.builder() | |
+ .setFields(AccountLinkCreateParams.CollectionOptions.Fields.CURRENTLY_DUE) | |
+ .build() | |
+ ) | |
.build(); | |
try { | |
return stripeClient.accountLinks().create(accountLinkCreateParams); | |
} catch (StripeException e) { | |
throw new MarketplaceException(HttpStatus.BAD_REQUEST, | |
String.format("Failed to start onboarding in Stripe: %s", e.getMessage()), e); | |
} | |
} | |
public Account retrieveAccount(String stripeAccountId) { | |
try { | |
return stripeClient.accounts().retrieve(stripeAccountId); | |
} catch (StripeException e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment