没有贝宝账户的用户使用信用卡订阅贝宝

Posted

技术标签:

【中文标题】没有贝宝账户的用户使用信用卡订阅贝宝【英文标题】:PayPal Subscription using credit card for users without paypal account 【发布时间】:2019-11-19 06:56:12 【问题描述】:

我正在尝试集成贝宝支付网关,以便用户可以通过我们的订阅计划每月订阅我们的服务,这就是我目前所做的。

        APIContext apiContext = new APIContext(clientId, clientSecret, executionMode);
        Map<String, Object> response = new HashMap<>();
        try 
            Plan plan = new Plan();
            plan.setId("P-51X5509888001534KW7C3GMI");
            Agreement agreement = new Agreement();
            agreement.setPlan(plan);
            agreement.setName("Orion Agreement");
            agreement.setDescription("Plan creation Agreement");
            agreement.setStartDate("2019-08-01T00:00:01Z");

            //Now Create an object of credit card and add above details to it

            //Address for the payment
            Address billingAddress = new Address();
            billingAddress.setCity("Los Angeles");
            billingAddress.setCountryCode("US");
            billingAddress.setLine1("Aplha street line 1");
            billingAddress.setLine2("Beta street line 2");
            billingAddress.setPostalCode("9001");
            billingAddress.setState("Calofornia");
//This is only for users without paypal account
            CreditCard card = new CreditCard();
            card.setBillingAddress(billingAddress);
            card.setCvv2("123");
            card.setExpireMonth(9);
            card.setExpireYear(2021) ;
            card.setFirstName("Red");
            card.setLastName("John");
            card.setNumber("2221000000000009");
            card.setType("mastercard");

            // Now we need to specify the FundingInstrument of the Payer
            // for credit card payments, set the CreditCard which we made above
            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.setCreditCard(card);
            // The Payment creation API requires a list of FundingIntrument
            List<FundingInstrument> fundingInstrumentList = new ArrayList<>();
            fundingInstrumentList.add(fundInstrument);

            Payer payer = new Payer();
            payer.setPaymentMethod("credit_card");
            payer.setFundingInstruments(fundingInstrumentList);
            agreement.setPayer(payer);

            ShippingAddress shippingAd = new ShippingAddress();
            shippingAd.setLine1("111 First Street");
            shippingAd.setCity("Saratoga");
            shippingAd.setState("CA");
            shippingAd.setPostalCode("95070");
            shippingAd.setCountryCode("US");

            Agreement agreementPlan = null;

            try 
                agreementPlan = agreement.create(apiContext);
             catch (Exception e) 
                // TODO Auto-generated catch block
                log.info("setupPlan error - " + e.toString());

                e.printStackTrace();
            

            response.put("redirectURL", agreementPlan);
         catch (Exception e) 
            log.error("Exception in createAgreement ", e);
        

        return response;

我能够为拥有 paypal 帐户的用户创建订阅。但是对于想要从借记卡/信用卡付款的用户,我无法创建订阅。

我想知道到目前为止我所实施的一切是否正确,如果我遗漏了什么,请告诉我。

Paypals 技术支持团队告诉我启用 paypals payment pro ,我已为一个帐户启用。

【问题讨论】:

【参考方案1】:

@Thejas,这需要 Paypal Payment Pro,而且现在不推荐使用计费计划和协议 API, 对于订阅,您应该使用 Paypal Subscription API,它支持通过卡也可以通过 Paypal 订阅,

集成指南:https://developer.paypal.com/docs/subscriptions/integrate/#

API 文档:https://developer.paypal.com/docs/api/subscriptions/v1/

【讨论】:

以上是关于没有贝宝账户的用户使用信用卡订阅贝宝的主要内容,如果未能解决你的问题,请参考以下文章

贝宝:接受没有贝宝账户的信用卡/借记卡

我可以用信用卡创建账单协议吗(没有贝宝账户)

ActiveMerchant - 向用户汇款的最佳方法?贝宝账户或信用卡

Paypal 订阅付款想要 3 个选项?

贝宝支付网关接受信用卡或使用贝宝账户

没有贝宝账户的贝宝访客结账