Как получить Charge id Stripe и записать его в таблицу?

Не могу записать в базу Charge id

При создании charge со Stripe возвращается объект Charge, я хочу charge id записать в базу для дальнейшего использования.

Пример объекта Charge, который я должен получить и его id, который хочу записать в базу

{
"id": "ch_1HU7oJBvP3uypX39ZQk1n8JC",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1GG1SWBvP3uypX39X6sCO4we",
"billing_details": {
"address": {
  "city": null,
  "country": null,
  "line1": null,
  "line2": null,
  "postal_code": null,
  "state": null
},
"email": null,
"name": "Jenny Rosen",
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1600766959,
"currency": "dkk",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"order": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1HU6xpBvP3uypX39jOlnayk1",
"payment_method_details": {
"card": {
  "brand": "visa",
  "checks": {
  "address_line1_check": null,
  "address_postal_code_check": null,
  "cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2021,
"fingerprint": "3D881K0RUc9Adq5Z",
"funding": "credit",
"installments": null,
"last4": "4242",
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/",
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_1HU7oJBvP3uypX39ZQk1n8JC/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}

таблица payment_customer соответствует сущности PaymentCustomerEntity

таблица payment_customer

Метод в сервисе

public String charge(String customerId, double amount, String description, Map<String, String> params) {
    try {
        Map<String, Object> chargeParams = new HashMap<>();
        chargeParams.put("amount", (int) (amount * 100));
        chargeParams.put("currency", "dkk");
        chargeParams.put("customer", customerId);
        if (description != null)
            chargeParams.put("description", description);
        if (params != null) {
            chargeParams.put("metadata", params);
        }
        Charge charge = Charge.create(chargeParams);

        //setchargeId
        if(paymentCustomerDao.getByStripeId(customerId)!= null) {
            PaymentCustomerEntity paymentCustomerEntity = 
      paymentCustomerDao.getByStripeId(customerId);
            paymentCustomerEntity.setStripeChargeId(charge.getId());
        }
        return charge.getId();
    } catch (StripeException e) {
        throw ErrorMessage.build(ERROR_SERVER_INTERNAL)
                .logLevel(LogLevel.ERROR)
                .cause(e)
                .detail(STRIPE_CUSTOMER_ID, customerId)
                .httpStatus(INTERNAL_SERVER_ERROR)
                .exception();
    }
}

Класс сущности

@Entity
@Table(name = "payment_customer")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PaymentCustomerEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "email")
private String email;

@Column(name = "stripe_id")
private String stripeId;

@Column(name = "charge_id")
private String stripeChargeId;

@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "address_id")
private AddressEntity address;


@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "created_by_user_id")
private UserEntity createdByUser;

@Column(name = "create_time")
private Timestamp createTime;

public PaymentCustomerEntity(String stripeCustomerId, UserEntity userEntity) {
    this.email = userEntity.getEmail();
    this.stripeId = stripeCustomerId;
    this.address = userEntity.getAddress();
    this.createdByUser = userEntity;
    createTime = DateTimeUtil.getCurrentTimestamp();
    }
}

Ответы (0 шт):