【问题标题】:Using Paypal Express Checkout using your Credit Card使用信用卡使用 Paypal Express 结帐
【发布时间】:2020-10-06 06:14:08
【问题描述】:

我只有一个简单的问题,如果我希望我的网站允许用户填写信用卡信息而不是去贝宝付款,我需要为这项服务付费吗?

public ActionResult Checkout()
    {
        //create and item for which you are taking payment
        //if you need to add more items in the list
        //Then you will need to create multiple item objects or use some loop to instantiate object
        Item item = new Item();
        item.name = "Demo Item";
        item.currency = "USD";
        item.price = "5";
        item.quantity = "1";
        item.sku = "sku";

        //Now make a List of Item and add the above item to it
        //you can create as many items as you want and add to this list
        List<Item> itms = new List<Item>();
        itms.Add(item);
        ItemList itemList = new ItemList();
        itemList.items = itms;

        //Address for the payment
        Address billingAddress = new Address();
        billingAddress.city = "NewYork";
        billingAddress.country_code = "US";
        billingAddress.line1 = "23rd street kew gardens";
        billingAddress.postal_code = "43210";
        billingAddress.state = "NY";


        //Now Create an object of credit card and add above details to it
        //Please replace your credit card details over here which you got from paypal
        CreditCard crdtCard = new CreditCard();
        crdtCard.billing_address = billingAddress;
        crdtCard.cvv2 = "874";  //card cvv2 number
        crdtCard.expire_month = 7; //card expire date
        crdtCard.expire_year = 2025; //card expire year
        crdtCard.first_name = "Aman";
        crdtCard.last_name = "Thakur";
        crdtCard.number = "4137354036661279"; //enter your credit card number here
        crdtCard.type = "visa"; //credit card type here paypal allows 4 types

        // Specify details of your payment amount.
        Details details = new Details();
        details.shipping = "1";
        details.subtotal = "5";
        details.tax = "1";

        // Specify your total payment amount and assign the details object
        Amount amnt = new Amount();
        amnt.currency = "USD";
        // Total = shipping tax + subtotal.
        amnt.total = "7";
        amnt.details = details;

        // Now make a transaction object and assign the Amount object
        Transaction tran = new Transaction();
        tran.amount = amnt;
        tran.description = "Description about the payment amount.";
        tran.item_list = itemList;
        tran.invoice_number = Guid.NewGuid().ToString().Replace("-", "");

        // Now, we have to make a list of transaction and add the transactions object
        // to this list. You can create one or more object as per your requirements

        List<Transaction> transactions = new List<Transaction>();
        transactions.Add(tran);

        // 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.credit_card = crdtCard;

        // The Payment creation API requires a list of FundingIntrument

        List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
        fundingInstrumentList.Add(fundInstrument);

        // Now create Payer object and assign the fundinginstrument list to the object
        Payer payr = new Payer();
        payr.funding_instruments = fundingInstrumentList;
        payr.payment_method = "credit_card";

        // finally create the payment object and assign the payer object & transaction list to it
        Payment pymnt = new Payment();
        pymnt.intent = "sale";
        pymnt.payer = payr;
        pymnt.transactions = transactions;

        try
        {
            //getting context from the paypal
            //basically we are sending the clientID and clientSecret key in this function
            //to the get the context from the paypal API to make the payment
            //for which we have created the object above.

            //Basically, apiContext object has a accesstoken which is sent by the paypal
            //to authenticate the payment to facilitator account.
            //An access token could be an alphanumeric string

            APIContext apiContext = PayPalConfiguration.GetAPIContext();

            //Create is a Payment class function which actually sends the payment details
            //to the paypal API for the payment. The function is passed with the ApiContext
            //which we received above.

            Payment createdPayment = pymnt.Create(apiContext);

            //if the createdPayment.state is "approved" it means the payment was successful else not

            if (createdPayment.state.ToLower() != "approved")
            {
                return View("FailureView");
            }
        }
        catch (PayPal.PayPalException ex)
        {
            return View("FailureView");
        }

        return View();
    }

我实现了这段代码,沙盒正在检索付款,所以这行得通,但我的问题是,我是否需要为这项服务支付贝宝,以允许用户在那里插入卡信息并提交?

上面写着网站支付专业版什么的。

【问题讨论】:

  • 您的银行是否允许您处理信用卡数据?一些银行的 API 允许企业客户提交信用卡付款。
  • @jdweng,是的,我也被告知按月支付费用,但是您必须每月支付 30 美元才能使用 paypal api 直接付款
  • 只是想知道使用 paypal api 直接付款是免费的还是付费的?
  • 如果它付了钱,那么我将使用快速结帐

标签: c# paypal


【解决方案1】:

像 Payments Pro、Payflow Pro 或更新更好的 Braintree Payments gateway 这样的网关当然可以选择,具有高级功能(您可能不需要)

根据您的需要,您可能会对最新的JavaScript PayPal Checkout 感到满意,它有一个可展开的黑色借记卡/信用卡按钮。

【讨论】:

  • 谢谢@Preston 信用卡/借记卡按钮只允许 PayPal 账户
猜你喜欢
  • 2015-04-21
  • 2015-06-11
  • 2016-11-29
  • 2017-03-25
  • 2011-05-10
  • 1970-01-01
  • 2014-09-05
  • 1970-01-01
  • 2017-06-03
相关资源
最近更新 更多