简体   繁体   English

C#中的PayPal支付提供商

[英]PayPal Payment Provider in C#

I was wondering if PayPal has a payment service which allows the users to enter their credit card details on my site (the user wouldn't even be aware they are paying by paypal). 我想知道PayPal是否有支付服务允许用户在我的网站上输入他们的信用卡详细信息(用户甚至不知道他们是通过paypal支付)。 I then need to make sure it handles repeat payments and refunds. 然后我需要确保它处理重复付款和退款。 Basically i need to create a paypal service which implements the following: 基本上我需要创建一个实现以下功能的paypal服务:

public interface IPaymentService {
    Response ValidateCard(NetworkCredential credential, int transactionID, decimal amount, string ipAddress, CardDetails cardDetails, Address billingAddress, Options options);
    Response RepeatCard(NetworkCredential credential, int oldTransactionID, int newTransactionID, decimal amount);
    Response RefundCard(NetworkCredential credential, int refundedTransactionID, int newTransactionID, decimal amount);
}

public class Address {
    public virtual string Address1 { get; set; }
    public virtual string Address2 { get; set; }
    public virtual string Address3 { get; set; }
    public virtual string Town { get; set; }
    public virtual string County { get; set; }
    public virtual Country Country { get; set; }
    public virtual string Postcode { get; set; }
}

public class CardDetails {
    public string CardHolderName { get; set; }
    public CardType CardType { get; set; }
    public string CardNumber { get; set; }
    public int ExpiryDateMonth { get; set; }
    public int ExpiryDateYear { get; set; }
    public string IssueNumber { get; set; }
    public string Cv2 { get; set; }
}

public class Response {
    public bool IsValid { get; set; }
    public string Message { get; set; }
}

public class Options {
    public bool TestStatus { get; set; }
    public string Currency { get; set; }
}

Usually this is quite trivual with other other payment providers eg PayPoint (soap service) and SagePay. 通常,这与其他支付服务提供商(例如PayPoint(肥皂服务)和SagePay)非常微不足道。

Reading the paypal documentation is giving me a headache so i thought i'd ask here. 阅读paypal文档让我头疼,所以我想我会问这里。 Really appreciate the help. 真的很感激帮助。 Thanks 谢谢

Yes they do. 是的他们这样做。 Check out this documentation. 查看此文档。

The direct payment api allows you to enter the card holder's info and then process it through the paypal system. 直接付款api允许您输入持卡人的信息,然后通过paypal系统处理。

https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside

//process payment
            Paypal toPayment = new Paypal();
            toPayment.BillingAddress = new Address(txt_BillingAddr1.Text, txt_BillingAddr2.Text, txt_BillingCity.Text, ddl_BillingState.SelectedValue, txt_BillingZip.Text, "");
            toPayment.BillingCountry = com.paypal.soap.api.CountryCodeType.US;
            toPayment.BillingFName = txt_BillingFName.Text;
            toPayment.BillingLName = txt_BillingLName.Text;
            toPayment.BillingMName = txt_BillingMName.Text;
            toPayment.BillingPhoneNumber = txt_BillingPhone.Text;
            toPayment.BillingSuffix = txt_BillingSuffix.Text;
            toPayment.ContactPhoneNumber = txtPhone.Text;
            toPayment.CreditCardExpireMonth = Convert.ToInt32(ddl_CCExpireMonth.SelectedIndex + 1);
            toPayment.CreditCardExpireYear = Convert.ToInt32(ddl_CCExpireYear.SelectedValue);
            toPayment.CreditCardNumber = txt_CreditCard.Text;
            toPayment.CreditCardSecurityCode = txt_CCID.Text;
            switch (lst_CCTypes.SelectedValue)
            {
                case "Visa":
                    toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Visa;
                    break;
                case "MasterCard":
                    toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.MasterCard;
                    break;
                case "AmericanExpress":
                    toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Amex;
                    break;
                case "Discover":
                    toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Discover;
                    break;
            }
            toPayment.UserHostAddress = Request.UserHostAddress;
            toPayment.OrderTotal = StaticMethods.getDecimal(lbl_TotalPrice_cout.Text, 0);

            //set API Profile
            toPayment.APIProfile = Master.PayPal_API_Profile;

            DoDirectPaymentResponseType toResponse = new DoDirectPaymentResponseType();
            toResponse = toPayment.processDirectPaymentTransaction();

Here is a little bit more for you... this is actual code from an actual production site that i work on that takes payments via paypal 这里有一点对你来说......这是我工作的实际生产网站的实际代码,需要通过paypal付款

toResponse contains an Ack property.... so you can do something like toResponse包含一个Ack属性....所以你可以做类似的事情

switch(toResponse.Ack)
{
case AckCodeType.Failure;
     // The card is bad. void transaction.
     lblResponse = toResponse.Errors[0].LongMessage;
     Break;
case AckCodeType.Success
     // The card is good.  Go forward with process
}

Yes, PayPal offers this under Website Payments Pro . 是的,PayPal在Website Payments Pro下提供此功能。 You can read more about it here . 你可以在这里阅读更多相关信息。

在此输入图像描述

The first flow is of Direct Payment and second is Express Checkout. 第一个流程是直接付款,第二个流程是快速结账。 Customer enters card details on your website under Direct Payment. 客户在直接付款下在您的网站上输入卡详细信息。

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

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