• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RequestOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.stripe.net.RequestOptions的典型用法代码示例。如果您正苦于以下问题:Java RequestOptions类的具体用法?Java RequestOptions怎么用?Java RequestOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RequestOptions类属于com.stripe.net包,在下文中一共展示了RequestOptions类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeCharge2

import com.stripe.net.RequestOptions; //导入依赖的package包/类
public void makeCharge2() {
    // see:
    // https://github.com/stripe/stripe-java#usage
    RequestOptions requestOptions = (new RequestOptions.RequestOptionsBuilder())
            .setApiKey("YOUR-SECRET-KEY").build();

    Map<String, Object> chargeMap = new HashMap<String, Object>();
    chargeMap.put("amount", 100);
    chargeMap.put("currency", "usd");

    Map<String, Object> cardMap = new HashMap<String, Object>();
    cardMap.put("number", "4242424242424242");
    cardMap.put("exp_month", 12);
    cardMap.put("exp_year", 2020);

    chargeMap.put("card", cardMap);

    try {
        Charge charge = Charge.create(chargeMap, requestOptions);

        System.out.println(charge);
    } catch (StripeException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:26,代码来源:TestStripe.java


示例2: pay

import com.stripe.net.RequestOptions; //导入依赖的package包/类
@Override
public void pay(final long cents, final String token, final String email)
    throws IOException {
    final String customer;
    try {
        customer = Customer.create(
            new StickyMap<String, Object>(
                new MapEntry<>("email", email),
                new MapEntry<>("source", token)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        ).getId();
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        new AttributeUpdates()
            .with(
                "stripe_cents",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withN(Long.toString(cents))
                ).withAction(AttributeAction.PUT)
            )
            .with(
                "stripe_customer",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withS(customer)
                ).withAction(AttributeAction.PUT)
            )
    );
    this.rebill();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:37,代码来源:DyScript.java


示例3: rebill

import com.stripe.net.RequestOptions; //导入依赖的package包/类
/**
 * Charge him again.
 * @throws IOException If fails
 */
private void rebill() throws IOException {
    final Item item = this.item();
    final Long cents = Long.parseLong(item.get("stripe_cents").getN());
    final String customer = item.get("stripe_customer").getS();
    try {
        Charge.create(
            new StickyMap<String, Object>(
                new MapEntry<>("amount", cents),
                new MapEntry<>("currency", "usd"),
                new MapEntry<>(
                    "description",
                    String.format("ThreeCopies: %s", this.name)
                ),
                new MapEntry<>("customer", customer)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        );
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        "paid",
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN(
                Long.toString(cents * TimeUnit.HOURS.toSeconds(1L))
            )
        ).withAction(AttributeAction.ADD)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:38,代码来源:DyScript.java


示例4: chargeCreditCard

import com.stripe.net.RequestOptions; //导入依赖的package包/类
/**
 * After client side integration with stripe widget, our server receives the stripeToken
 * StripeToken is a single-use token that allows our server to actually charge the credit card and
 * get money on our account.
 * <p>
 * as documented in https://stripe.com/docs/tutorials/charges
 *
 * @return
 * @throws StripeException
 */
Charge chargeCreditCard(String stripeToken, long amountInCent, Event event,
                        String reservationId, String email, String fullName, String billingAddress) throws StripeException {

    int tickets = ticketRepository.countTicketsInReservation(reservationId);
    Map<String, Object> chargeParams = new HashMap<>();
    chargeParams.put("amount", amountInCent);
    FeeCalculator.getCalculator(event, configurationManager).apply(tickets, amountInCent).ifPresent(fee -> chargeParams.put("application_fee", fee));
    chargeParams.put("currency", event.getCurrency());
    chargeParams.put("card", stripeToken);

    chargeParams.put("description", String.format("%d ticket(s) for event %s", tickets, event.getDisplayName()));

    Map<String, String> initialMetadata = new HashMap<>();
    initialMetadata.put("reservationId", reservationId);
    initialMetadata.put("email", email);
    initialMetadata.put("fullName", fullName);
    if (StringUtils.isNotBlank(billingAddress)) {
        initialMetadata.put("billingAddress", billingAddress);
    }
    chargeParams.put("metadata", initialMetadata);
    RequestOptions options = options(event);
    Charge charge = Charge.create(chargeParams, options);
    if(charge.getBalanceTransactionObject() == null) {
        try {
            charge.setBalanceTransactionObject(retrieveBalanceTransaction(charge.getBalanceTransaction(), options));
        } catch(Exception e) {
            log.warn("can't retrieve balance transaction", e);
        }
    }
    return charge;
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:42,代码来源:StripeManager.java


示例5: options

import com.stripe.net.RequestOptions; //导入依赖的package包/类
private RequestOptions options(Event event) {
    RequestOptions.RequestOptionsBuilder builder = RequestOptions.builder();
    if(isConnectEnabled(event)) {
        //connected stripe account
        builder.setStripeAccount(configurationManager.getRequiredValue(Configuration.from(event.getOrganizationId(), event.getId(), STRIPE_CONNECTED_ID)));
        return builder.setApiKey(getSystemApiKey()).build();
    }
    return builder.setApiKey(getSecretKey(event)).build();
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:10,代码来源:StripeManager.java


示例6: getInfo

import com.stripe.net.RequestOptions; //导入依赖的package包/类
Optional<PaymentInformation> getInfo(Transaction transaction, Event event) {
    try {
        RequestOptions options = options(event);
        Charge charge = Charge.retrieve(transaction.getTransactionId(), options);
        String paidAmount = MonetaryUtil.formatCents(charge.getAmount());
        String refundedAmount = MonetaryUtil.formatCents(charge.getAmountRefunded());
        List<Fee> fees = retrieveBalanceTransaction(charge.getBalanceTransaction(), options).getFeeDetails();
        return Optional.of(new PaymentInformation(paidAmount, refundedAmount, getFeeAmount(fees, "stripe_fee"), getFeeAmount(fees, "application_fee")));
    } catch (StripeException e) {
        return Optional.empty();
    }
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:13,代码来源:StripeManager.java


示例7: doPost

import com.stripe.net.RequestOptions; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    /* --- request*/
    String requestDataStr = ServletUtils.getAllRequestData(request);

    String responseStr = "{\"paymentData\":" + requestDataStr + ",";

    // Get the credit card details submitted by the form
    String token = request.getParameter("stripeToken");
    @SuppressWarnings("unused")
    String cardHolderName = request.getParameter("cardHolderName");

    /* -- see example on: https://github.com/stripe/stripe-java#usage */
    //
    RequestOptions requestOptions = (new RequestOptions.RequestOptionsBuilder())
            .setApiKey(STRIPE_SECRET_KEY).build();
    //
    // -- Card options:
    // ------------ // Map<String, Object> cardMap = new HashMap<>();
    // cardMap.put("name", cardHolderName);// - "Received both card and source parameters. Please pass in only one."
    /*
    cardMap.put("number", "4242424242424242");
    cardMap.put("exp_month", 12);
    cardMap.put("exp_year", 2020);
    */

    // -- Charge options:
    Map<String, Object> chargeMap = new HashMap<>();
    chargeMap.put("amount", 100); // -- this is ONE dollar
    chargeMap.put("currency", "usd");
    // see: https://stripe.com/docs/charges (Java)
    // chargeParams.put("source", token);
    // chargeParams.put("description", "Example charge");
    chargeMap.put("source", token);
    chargeMap.put("description", "Example charge: " + token);
    //
    // ------------ // chargeMap.put("card", cardMap);
    // -- make charge:
    responseStr += "\"charge\":";
    try {
        Charge charge = Charge.create(chargeMap, requestOptions);
        // System.out.println(charge);
        responseStr += GSON.toJson(charge);
        LOG.warning(GSON.toJson(charge));
        ExternalAccount source = charge.getSource();
        LOG.warning("source: " + GSON.toJson(source));
        charge.getStatus(); // -- "succeeded"
        charge.getPaid(); // - boolean: true or false
        //
        // String customerStr = source.getCustomer();
        // LOG.warning("customerStr: " + customerStr); //
        // responseStr += "," + "\"customerStr\":" + GSON.toJson(charge); // - same as source

    } catch (StripeException e) {
        String errorMessage = e.getMessage();
        responseStr += "\"";
        responseStr += errorMessage;
        responseStr += "\"";
        LOG.warning(errorMessage);
    }

    responseStr += "}";
    ServletUtils.sendJsonResponse(response, responseStr);
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:67,代码来源:StripeTestServlet.java


示例8: UserSubscriptionHttpService

import com.stripe.net.RequestOptions; //导入依赖的package包/类
@Inject
public UserSubscriptionHttpService(WebUserService service, RakamUIConfig config) {
    this.service = service;
    requestOptions = new RequestOptions.RequestOptionsBuilder()
            .setApiKey(config.getStripeKey()).build();
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:7,代码来源:UserSubscriptionHttpService.java


示例9: retrieveBalanceTransaction

import com.stripe.net.RequestOptions; //导入依赖的package包/类
private BalanceTransaction retrieveBalanceTransaction(String balanceTransaction, RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
    return BalanceTransaction.retrieve(balanceTransaction, options);
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:4,代码来源:StripeManager.java



注:本文中的com.stripe.net.RequestOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RadioGroupItem类代码示例发布时间:2022-05-22
下一篇:
Java SentryClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap