Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
101303cb
提交
101303cb
authored
1月 04, 2021
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
购物车批量添加
上级
92f560c7
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
148 行增加
和
8 行删除
+148
-8
pom.xml
pom.xml
+7
-0
AfrishopV3Application.java
...n/java/com/example/afrishop_v3/AfrishopV3Application.java
+3
-0
StripeController.java
...com/example/afrishop_v3/controllers/StripeController.java
+92
-0
WebSecurityConfig.java
...a/com/example/afrishop_v3/security/WebSecurityConfig.java
+1
-1
StripePay.java
src/main/java/com/example/afrishop_v3/util/StripePay.java
+33
-0
application-prod.yml
src/main/resources/application-prod.yml
+1
-1
application-test.yml
src/main/resources/application-test.yml
+10
-5
application.properties
src/main/resources/application.properties
+1
-1
没有找到文件。
pom.xml
浏览文件 @
101303cb
...
...
@@ -31,6 +31,13 @@
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.stripe/stripe-java -->
<dependency>
<groupId>
com.stripe
</groupId>
<artifactId>
stripe-java
</artifactId>
<version>
11.6.1
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>
cn.hutool
</groupId>
...
...
src/main/java/com/example/afrishop_v3/AfrishopV3Application.java
浏览文件 @
101303cb
...
...
@@ -4,8 +4,11 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
//@EnableAsync
@EnableScheduling
@SpringBootApplication
public
class
AfrishopV3Application
{
...
...
src/main/java/com/example/afrishop_v3/controllers/StripeController.java
0 → 100644
浏览文件 @
101303cb
package
com
.
example
.
afrishop_v3
.
controllers
;
import
com.example.afrishop_v3.base.Result
;
import
com.google.gson.Gson
;
import
com.stripe.Stripe
;
import
com.stripe.exception.StripeException
;
import
com.stripe.model.Customer
;
import
com.stripe.model.PaymentIntent
;
import
com.stripe.model.PaymentMethod
;
import
com.stripe.model.checkout.Session
;
import
com.stripe.param.PaymentIntentCreateParams
;
import
com.stripe.param.checkout.SessionCreateParams
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Auther: wudepeng
* @Date: 2021/01/04
* @Description:Stripe支付
*/
@RestController
@RequestMapping
(
"/stripe"
)
public
class
StripeController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
StripeController
.
class
);
@Value
(
"${stripe.secret_key}"
)
private
String
SECRET_KEY
;
@Value
(
"${stripe.public_key}"
)
private
String
PUBLIC_KEY
;
@Value
(
"${stripe.success_url}"
)
private
String
SUCCESS_URL
;
@Value
(
"${stripe.cancel_url}"
)
private
String
CANCEL_URL
;
@PostMapping
(
"/payment"
)
public
Result
payment
(
@RequestParam
Map
<
String
,
Object
>
paramMap
)
{
return
new
Result
();
}
/* @PostMapping("/payment")
public Result payment(@RequestParam Map<String, Object> paramMap) {
Map<String, String> resultMap = new HashMap<>();
try {
Stripe.apiKey = SECRET_KEY;
Map<String, Object> params = new HashMap<String, Object>();
ArrayList<String> paymentMethodTypes = new ArrayList<>();
paymentMethodTypes.add("card");
params.put("payment_method_types", paymentMethodTypes);
ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
HashMap<String, Object> lineItem = new HashMap<String, Object>();
lineItem.put("name", "胡鹏飞测试商品");
lineItem.put("description", "这是一个测试单描述");
lineItem.put("amount", 500); // 支付金额
lineItem.put("currency", "usd"); //支付币种
lineItem.put("quantity", 1);
lineItems.add(lineItem);
params.put("line_items", lineItems);
//TODO 必须使用https 返回的回调地址
params.put("client_reference_id", paramMap.get("orderId"));//业务系统唯一标识 即订单唯一编号
params.put("success_url", SUCCESS_URL);// 支付成功跳转页面
params.put("cancel_url", CANCEL_URL);// 支付失败跳转页面
Session session = Session.create(params);
String sessionId = session.getId();
logger.info("sessionId :{}", session.getId());
resultMap.put("sessionId", sessionId);
} catch (StripeException e) {
e.printStackTrace();
}
return new Result(resultMap);
}*/
@GetMapping
(
"/getPublicKey"
)
public
Result
getPublicKey
()
{
return
new
Result
(
PUBLIC_KEY
);
}
}
src/main/java/com/example/afrishop_v3/security/WebSecurityConfig.java
浏览文件 @
101303cb
...
...
@@ -70,7 +70,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
authorizeRequests
().
antMatchers
(
"/api/auth/**"
,
"/search/image/**"
,
"/itemStation/**"
,
"/startPage/**"
,
"/goodsType/**"
,
"/home/**"
,
"/spider/**"
,
"/store/**"
,
"/shopify/**"
,
"/community/**"
,
"/version/**"
,
"/flutterwave/notify/**"
,
"/dpo/notify/**"
,
"/advertisement/**"
,
"/website/**"
,
"/paypal/**"
,
"/discover/bonus/**"
,
"/problem/**"
,
"/cube/**"
,
"/activity/**"
,
"/attributes
/**"
).
permitAll
()
"/problem/**"
,
"/cube/**"
,
"/activity/**"
,
"/attributes/**"
,
"/stripe
/**"
).
permitAll
()
.
antMatchers
(
"/api/test/**"
).
permitAll
()
.
anyRequest
().
authenticated
();
...
...
src/main/java/com/example/afrishop_v3/util/StripePay.java
0 → 100644
浏览文件 @
101303cb
package
com
.
example
.
afrishop_v3
.
util
;
import
com.stripe.Stripe
;
import
com.stripe.exception.StripeException
;
import
com.stripe.model.Charge
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* stripe支付相关方法
*/
public
class
StripePay
{
/**
* 发起支付,默认使用美元支付
* @param amount 货币的最小单位,比如美元,传入1000,就是1000美分,10美元
* @param sk
* @param token
* @return
*/
public
static
Charge
createCharge
(
Integer
amount
,
String
sk
,
String
token
)
throws
StripeException
{
Stripe
.
apiKey
=
sk
;
Map
<
String
,
Object
>
chargeParams
=
new
HashMap
<>(
16
);
chargeParams
.
put
(
"amount"
,
amount
);
chargeParams
.
put
(
"currency"
,
"usd"
);
// 会出现在付款后页面
/** chargeParams.put("description", "Charge for jenny.rosen@example.com");*/
chargeParams
.
put
(
"source"
,
token
);
return
Charge
.
create
(
chargeParams
);
}
}
src/main/resources/application-prod.yml
浏览文件 @
101303cb
...
...
@@ -73,7 +73,7 @@ dpo:
flutter
:
pay_url
:
https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify
refund_url
:
https://api.ravepay.co/gpx/merchant/transactions/refund
redirect_url
:
https://
www.afrieshop.com/afrishop
/flutterwave/notify
redirect_url
:
https://
app.afrieshop.com/zion
/flutterwave/notify
public_key
:
FLWPUBK-ee0f5d653f5f33fc89e6caf9de6a4c34-X
secret_key
:
FLWSECK-c06cdc19526077f3855b76045ca77de3-X
...
...
src/main/resources/application-test.yml
浏览文件 @
101303cb
...
...
@@ -9,11 +9,11 @@ spring:
username
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
password
:
Diaoyunnuli.8
# secondsource:
# url: jdbc:mysql://165.22.82.105:3306/chinafrica?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
# username: root
# driver-class-name: com.mysql.cj.jdbc.Driver
# password: clement123
# secondsource:
# url: jdbc:mysql://165.22.82.105:3306/chinafrica?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
# username: root
# driver-class-name: com.mysql.cj.jdbc.Driver
# password: clement123
redis
:
#Redis数据库分片索引(默认为0)
...
...
@@ -93,3 +93,8 @@ paypal:
failed_page
:
https://www.afrieshop.com/payment_failed
mode
:
sandbox
stripe
:
success_url
:
https://app.afrieshop.com/afrishop/stripe/success
cancel_url
:
https://app.afrieshop.com/afrishop/stripe/cancel
public_key
:
pk_test_y5dXLjyUyBD11Ta9g2DGynxN0048vnmpGz
secret_key
:
sk_test_tGl2q7Omxehpli7R3Z6xU6G900iL1eX32c
src/main/resources/application.properties
浏览文件 @
101303cb
server.servlet.context-path
=
/zion
spring.jpa.hibernate.ddl-auto
=
update
server.port
=
8083
spring.profiles.active
=
test
spring.profiles.active
=
prod
#spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
#spring.datasource.username=root
#spring.datasource.password=Diaoyunnuli.8
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论