简体   繁体   English

对于没有贝宝账户的用户,使用信用卡进行贝宝订阅

[英]PayPal Subscription using credit card for users without paypal account

I am trying to Integrate paypal payment gateway so that users can subscribe to our service through our subscription plans on a monthly basis and this is what I have doe so far. 我正在尝试集成贝宝支付网关,以便用户可以每月通过我们的订阅计划订阅我们的服务,这是我到目前为止所做的。

        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;

I was able to create a subscription for the user who has the paypal account. 我能够为拥有贝宝帐户的用户创建订阅。 But For the users who want to pay from their debit/credit card, I was not able to create a subscription. 但是对于想要通过借记卡/信用卡付款的用户,我无法创建订阅。

I want to know whatever I have implemented so far is proper, If I have missed anything please let me know. 我想知道到目前为止我已经实施的任何方法都是正确的,如果我错过了任何事情,请告诉我。

Paypals Technical support team told me to enable paypals payment pro , Which I have enabled for a account. Paypals技术支持团队告诉我启用我已为帐户启用的paypals pay pro。

@Thejas, That required Paypal Payment Pro, Also the billing plan and agreement API is deprecated now, For Subscription you should use Paypal Subscription API, It supports subscription via card also via Paypal, @Thejas,这要求使用Paypal Payment Pro,并且现在不建议使用结算计划和协议API,对于Subscription,您应该使用Paypal Subscription API,它支持通过Paypal通过卡进行订阅,

Integration guide: https://developer.paypal.com/docs/subscriptions/integrate/# 整合指南: https//developer.paypal.com/docs/subscriptions/integrate/#

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM