@PostMapping("/{boardId}")
public ResponseEntity<ApiResult<PaymentResponse>> request(
@PathVariable Long boardId,
@Valid @ModelAttribute PaymentRequest request
) {
String email = authenticationService.getEmail();
PaymentResponse paymentResponse = paymentService.request(request, email, boardId);
return ResponseEntity.ok(ApiUtils.success(paymentResponse));
}
그럼 결과 값으로
{
"success": true,
"response": {
"payType": "CARD",
"amount": 100,
"orderName": "주문명",
"customerName": "푸항항",
"customerEmail": "[email protected]",
"orderId": "4_923237306",
"successUrl": "<http://localhost:8080/payment/success>",
"failUrl": "<http://localhost:8080/payment/fail>",
"createAt": "2023-07-04T20:53:15.2922703",
"paymentStatus": "READY"
},
"error": null
}
button.addEventListener('click', function () {
tossPayments.requestPayment('카드', {
amount: 100,
orderId: '4_923237306',
orderName: "주문명",
customerName: "푸항항",
customerEamil: "[email protected]",
successUrl: '<http://localhost:8080/success>',
failUrl: '<http://localhost:8080/fail>',
})
})
http://localhost:8080/success?orderId=4_923237306&paymentKey=OR1ZwdkQD5GePWvyJnrK2wQl025P9aVgLzN97EoqYA60XKx4&amount=100