2011-02-15 56 views
5

Me preguntaba si PayPal tiene un servicio de pago que permite a los usuarios ingresar los datos de su tarjeta de crédito en mi sitio (el usuario ni siquiera se da cuenta de que están pagando con PayPal). Entonces necesito asegurarme de que maneje los pagos y reembolsos repetidos. Básicamente necesito para crear un servicio de paypal que implementa el siguiente:Proveedor de pago de PayPal en 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; } 
} 

Por lo general, esto es bastante trivual con otros otros proveedores de pago por ejemplo PayPoint (servicio de jabón) y SagePay.

Leer la documentación de paypal me está dando dolor de cabeza, así que pensé en preguntar aquí. Realmente aprecio la ayuda. Gracias

+0

posible duplicado de [Recepción de pagos a través de PayPal y tarjeta de crédito] (http://stackoverflow.com/questions/1707701/receiving-payments-trough-paypal-and-credit-card) –

+0

@George Stocker - Eso no es un duplicar. La pregunta a la que se vinculó es PHP y esta pregunta es C#. –

Respuesta

2

Sí lo hacen. Mira esta documentación.

La aplicación de pago directo le permite ingresar la información del titular de la tarjeta y luego procesarla a través del sistema 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(); 

Aquí es un poco más para usted ... este es el código real de un lugar de producción real que yo trabajo en el que se lleva a pagos a través de PayPal

toResponse contiene una propiedad Ack .... para que pueda hacer algo como

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

Sí, PayPal ofrece esto bajo Website Payments Pro. Puede leer más al respecto here.

enter image description here

El primer flujo es de pago directo y el segundo es exprés. El cliente ingresa los detalles de la tarjeta en su sitio web bajo Pago directo.

Cuestiones relacionadas