c# - C# 中的 PayPal 支付提供商

标签 c# paypal

我想知道 PayPal 是否有允许用户在我的网站上输入他们的信用卡详细信息的支付服务(用户甚至不知道他们是通过 paypal 支付的)。然后我需要确保它处理重复付款和退款。基本上我需要创建一个实现以下内容的 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; }
}

通常这对于其他支付服务提供商来说是非常微不足道的,例如 PayPoint(soap 服务)和 SagePay。

阅读 paypal 文档让我很头疼,所以我想在这里问一下。非常感谢您的帮助。谢谢

最佳答案

是的,他们有。查看此文档。

直接支付 api 允许您输入持卡人的信息,然后通过 paypal 系统处理它。

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();

这里还有一些给你的......这是来 self 工作的实际生产站点的实际代码,该站点通过 paypal 进行付款

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
}

关于c# - C# 中的 PayPal 支付提供商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5004925/

相关文章:

javascript - 弹出 Paypal 支付窗口 - 如何将数据发送回主窗口

php - Paypal 返回 true 或 false

c# - 在 C# 中抑制 "is never used"和 "is never assigned to"警告

c# - HTTP 错误 500.52 - URL 重写模块错误。名称属性

PayPal IPN - 自动返回

python - 将 Django 与 SSL 结合使用以集成 PayPal

php - webview android 中未显示 Paypal 支付页面 credicard 选项

c# - 如何将下拉列表值作为存储过程的参数传递

c# - UnityWebRequest 和 Azure Bot 问题

c# - 我们应该如何向现有变量添加实例化?