2011-02-15 42 views
5

我想知道如果贝宝有一个支付服务,允许用户在我的网站上输入他们的信用卡详细信息(用户甚至不知道他们是通过贝宝付款)。然后我需要确保它处理重复付款和退款。基本上我需要创建一个实现以下一个PayPal服务:贝宝付款提供商在C#

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; } 
} 

通常这是与其他其他支付提供商如找到付款(SOAP服务)和SagePay相当trivual。

阅读贝宝文档让我头痛,所以我想我会问这里。真的很感谢帮助。谢谢

+0

可能重复的[接收付款槽贝宝和信用卡](http://stackoverflow.com/questions/1707701/receiving-payments-trough-paypal-and-credit-card) – 2011-02-15 14:36:49

回答

2

是的,他们这样做。看看这个文档。

直接付款API允许您输入持卡人的信息,然后通过贝宝系统进行处理。

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

这里是多一点点的你...这是一个实际的生产现场,我对工作的实际代码通过PayPal支付需要

toResponse包含确认属性....所以你可以做类似

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 
} 
0

是的,PayPal在Website Payments Pro下提供此服务。你可以阅读更多关于它here

enter image description here

第一流量是直接支付和第二是快速结账。客户在直接付款下的网站上输入卡详情。