(ASP) ASP (2012)

My payment gateway for Inplat.ru

This is a project with gateway to payment by SMS from mobile phone.



Below some fragments of this project codes. Sorry, I have no time for more details description of this project.


   1:  <ServiceContract(ProtectionLevel:=Net.Security.ProtectionLevel.None)>
   2:  Public Interface IInPlatGateway
   3:   
   4:      <OperationContract()>
   5:      Function TST(ByVal value As Integer) As String
   6:   
   7:      <OperationContract()>
   8:      Sub PaymentCancellation(ByVal PaymentID As String, _
   9:                                   ByVal PaymentResult As Integer, _
  10:                                   ByVal PaymentResultStr As String, _
  11:                                   ByVal PayeeRegData As String, _
  12:                                   ByVal PayeeRegDataEx As String, _
  13:                                   ByVal ShopParams As String, _
  14:                                   ByVal Demo As Boolean)
  15:   
  16:      <OperationContract()>
  17:      Sub PaymentContract(ByVal PaymentID As String, _
  18:                               ByVal Account As String, _
  19:                               ByVal Currency As Integer, _
  20:                               ByVal PaymentTime As Date, _
  21:                               ByVal PayerAddress As String, _
  22:                               ByVal ShopParams As String, _
  23:                               ByVal UserParams As String, _
  24:                               ByVal Demo As Boolean, _
  25:                               ByRef Sum As Single, _
  26:                               ByRef PayeeRegData As String, _
  27:                               ByRef Contract As String, _
  28:                               ByRef PaymentDelay As Integer)
  29:   
  30:      <OperationContract()>
  31:      Sub PaymentAuthorization( _
  32:                      ByVal PaymentID As String, _
  33:                      ByVal PayeeRegData As String, _
  34:                      ByRef PayeeRegDataEx As String, _
  35:                      ByVal PaymentTime As Date, _
  36:                      ByVal Currency As Integer, _
  37:                      ByVal Sum As Single, _
  38:                      ByVal CreditSum As Single, _
  39:                      ByVal Account As String, _
  40:                      ByVal AccountEstimatedSum As Single, _
  41:                      ByVal PayerAccount As String, _
  42:                      ByVal AuthorizationTime As Date, _
  43:                      ByVal IsRepeat As Boolean, _
  44:                      ByVal ShopParams As String, _
  45:                      ByVal Demo As Boolean, _
  46:                      ByRef ReplyResource As String, _
  47:                      ByRef ReplyResourceIsFailure As Boolean, _
  48:                      ByRef ShopTime As Date)
  49:   
  50:      <OperationContract()>
  51:      Sub ArbitraryMessage(ByVal MessageType As String, _
  52:                                ByVal Message As String, _
  53:                                ByVal ShopParams As String, _
  54:                                ByRef ResponseMessage As String)
  55:   
  56:  End Interface
  57:   
  58:   


   1:  'http://localhost:1451/InPlatGateway.svc?wsdl
   2:   
   3:  <ServiceBehavior(InstanceContextMode:=System.ServiceModel.InstanceContextMode.PerCall)> _
   4:  <Activation.AspNetCompatibilityRequirements(RequirementsMode:=Activation.AspNetCompatibilityRequirementsMode.Allowed)> _
   5:  Public Class InPlatGateway
   6:      Implements IInPlatGateway
   7:   
   8:      Dim Postgres As PG1.SQL_Postgres
   9:   
  10:      Public Sub New()
  11:          If HttpContext.Current.Session("Postgres") Is Nothing Then
  12:              Postgres = New PG1.SQL_Postgres(System.Configuration.ConfigurationManager.ConnectionStrings("SQLServer_ConnectionStrings").ConnectionString)
  13:              HttpContext.Current.Session("Postgres") = Postgres
  14:          Else
  15:              Postgres = HttpContext.Current.Session("Postgres")
  16:          End If
  17:      End Sub
  18:   
  19:      Public Function TST(ByVal value As Integer) As String Implements IInPlatGateway.TST
  20:          Return "OK - " & value.ToString
  21:      End Function
  22:   
  23:      Public Sub PaymentContract(ByVal PaymentID As String, _
  24:                                 ByVal Account As String, _
  25:                                 ByVal Currency As Integer, _
  26:                                 ByVal PaymentTime As Date, _
  27:                                 ByVal PayerAddress As String, _
  28:                                 ByVal ShopParams As String, _
  29:                                 ByVal UserParams As String, _
  30:                                 ByVal Demo As Boolean, _
  31:                                 ByRef Sum As Single, _
  32:                                 ByRef PayeeRegData As String, _
  33:                                 ByRef Contract As String, _
  34:                                 ByRef PaymentDelay As Integer) Implements IInPlatGateway.PaymentContract
  35:          Try
  36:              Dim RequestNumber As Integer
  37:              Dim ResponseSum As String
  38:              Dim ResponsePayeeRegData As String
  39:              Dim ResponseContract As String
  40:              Dim ResponsePaymentDelay As String
  41:              Dim RDR1 As Npgsql.NpgsqlDataReader = Postgres.PG.ExecRDR("select * from payment where ""InitPayment_ResponseID""='" & PaymentID & "';")
  42:              If RDR1.Read Then
  43:                  RequestNumber = RDR1("i")
  44:                  ResponseSum = RDR1("PaymentContract_ResponseSum")
  45:                  ResponsePayeeRegData = RDR1("id").ToString
  46:                  ResponseContract = RDR1("PaymentContract_ResponseContract")
  47:                  ResponsePaymentDelay = RDR1("PaymentContract_ResponsePaymentDelay")
  48:              Else
  49:                  'нет такого реквеста - пишем ошибку
  50:                  Postgres.PG.ExecScalar("INSERT INTO ""InplatError""(crdate, status, txt) VALUES (now(), 0, 'PaymentContract: PaymentID=" & PaymentID & "');")
  51:                  Exit Sub
  52:              End If
  53:              'ответ
  54:              Sum = ResponseSum                     'сумма для оплаты оферты, с точностью не более копейки
  55:              PayeeRegData = ResponsePayeeRegData   'учётные данные Предприятия по платежу
  56:              Contract = ResponseContract           'описание оферты на оплату товара
  57:              PaymentDelay = ResponsePaymentDelay   'если указано значение 0, то устанавливается значение по умолчанию 86400 (сутки) 
  58:              Postgres.PG.ExecScalar("UPDATE payment SET ""PaymentContractAccount""='" & Account & "', " & _
  59:              """PaymentContractCurrency""='" & Currency & "', " & _
  60:              """PaymentContractPaymentTime""='" & PaymentTime & "', " & _
  61:              """PaymentContractPayerAddress""='" & PayerAddress & "', " & _
  62:              """PaymentContractShopParams""='" & ShopParams & "', " & _
  63:              """PaymentContractUserParams""='" & UserParams & "', " & _
  64:              """PaymentContractDemo""='" & Demo & "'  " & _
  65:              " where ""InitPayment_ResponseID""='" & PaymentID & "';")
  66:              '
  67:          Catch a As System.Web.Services.Protocols.SoapException
  68:              If Postgres IsNot Nothing And a.Detail.FirstChild IsNot Nothing Then
  69:                  Postgres.PG.ExecScalar("INSERT INTO ""InplatError""(crdate, status, txt) VALUES (now(), 0, 'PaymentContractError: " & a.Detail.FirstChild.InnerText.Replace("""", "").Replace("'", "") & "');")
  70:              End If
  71:          Catch ex As Exception
  72:              If Postgres IsNot Nothing And ex.Message IsNot Nothing Then
  73:                  Postgres.PG.ExecScalar("INSERT INTO ""InplatError""(crdate, status, txt) VALUES (now(), 0, 'PaymentContractError: " & ex.Message.Replace("""", "").Replace("'", "") & "');")
  74:              End If
  75:          End Try
  76:   
  77:   
  78:      End Sub
  79:   
  80:      Public Sub PaymentAuthorization(ByVal PaymentID As String, _
  81:                                      ByVal PayeeRegData As String, _
  82:                                      ByRef PayeeRegDataEx As String, _
  83:                                      ByVal PaymentTime As Date, _
  84:                                      ByVal Currency As Integer, _
  85:                                      ByVal Sum As Single, _
  86:                                      ByVal CreditSum As Single, _
  87:                                      ByVal Account As String, _
  88:                                      ByVal AccountEstimatedSum As Single, _
  89:                                      ByVal PayerAccount As String, _
  90:                                      ByVal AuthorizationTime As Date, _
  91:                                      ByVal IsRepeat As Boolean, _
  92:                                      ByVal ShopParams As String, _
  93:                                      ByVal Demo As Boolean, _
  94:                                      ByRef ReplyResource As String, _
  95:                                      ByRef ReplyResourceIsFailure As Boolean, _
  96:                                      ByRef ShopTime As Date) Implements IInPlatGateway.PaymentAuthorization
  97:          'ответ
  98:          PayeeRegDataEx = "ok1"
  99:          ReplyResource = "ok2"
 100:          ReplyResourceIsFailure = True
 101:          ShopTime = Now
 102:      End Sub
 103:   
 104:      Public Sub ArbitraryMessage(ByVal MessageType As String, _
 105:                                  ByVal Message As String, _
 106:                                  ByVal ShopParams As String, _
 107:                                  ByRef ResponseMessage As String) Implements IInPlatGateway.ArbitraryMessage
 108:          'ответ
 109:          ResponseMessage = "ok"
 110:      End Sub
 111:   
 112:      Public Sub PaymentCancellation(ByVal PaymentID As String, _
 113:                                     ByVal PaymentResult As Integer, _
 114:                                     ByVal PaymentResultStr As String, _
 115:                                     ByVal PayeeRegData As String, _
 116:                                     ByVal PayeeRegDataEx As String, _
 117:                                     ByVal ShopParams As String, _
 118:                                     ByVal Demo As Boolean) Implements IInPlatGateway.PaymentCancellation
 119:   
 120:      End Sub
 121:   
 122:  End Class
 123:   


   1:  Public Class Gate
   2:   
   3:      Dim ShopService1 As ru.inplat.merchant_remote.ShopService
   4:   
   5:      Public Sub New()
   6:          ShopService1 = New ru.inplat.merchant_remote.ShopService
   7:          Dim ShopServiceCert As System.Security.Cryptography.X509Certificates.X509Certificate2
   8:          Dim CertStore As System.Security.Cryptography.X509Certificates.X509Store = New System.Security.Cryptography.X509Certificates.X509Store
   9:          CertStore.Open(System.Security.Cryptography.X509Certificates.OpenFlags.MaxAllowed)
  10:          For Each OneCert As System.Security.Cryptography.X509Certificates.X509Certificate2 In CertStore.Certificates
  11:              If OneCert.SerialNumber = System.Configuration.ConfigurationManager.AppSettings("CertNumber") Then
  12:                  ShopServiceCert = OneCert
  13:                  GoTo OK1
  14:              End If
  15:          Next
  16:          Throw New Exception("No certificate " & System.Configuration.ConfigurationManager.AppSettings("CertNumber"))
  17:  OK1:    ShopService1.ClientCertificates.Add(ShopServiceCert)
  18:      End Sub
  19:   
  20:      Public Function InitPayment(ByVal Phone As String, ByVal SMS As String, ByVal ServiceNum As Integer, ByVal ServiceNumSpecified As Boolean, ByRef PaymentTime As Date, ByRef PaymentResult As Integer, ByRef PaymentResultStr As String)
  21:          Return ShopService1.InitPayment(Phone, SMS, ServiceNum, ServiceNumSpecified, PaymentTime, PaymentResult, PaymentResultStr)
  22:      End Function
  23:   
  24:      Public Sub SendMessage(ByVal Phone As String, ByVal Message As String)
  25:          Dim Prm1 As New ru.inplat.merchant_remote.SendMessage
  26:          Prm1.Phone = Phone
  27:          Prm1.Message = Message
  28:          ShopService1.SendMessage(Prm1)
  29:      End Sub
  30:   
  31:      Public Function GetPayment(ByVal PaymentID As String, ByRef PaymentResult As Integer, ByRef PaymentResultStr As String, ByRef PayeeRegData As String, ByRef Phone As String, ByRef Sum As Double, ByRef OperatorOrderId As String) As Date
  32:          Return ShopService1.GetPayment(PaymentID, PaymentResult, PaymentResultStr, PayeeRegData, Phone, Sum, OperatorOrderId)
  33:      End Function
  34:   
  35:      Public Function GetPayments(ByVal merchant_id As String, ByVal date_from As String, ByVal date_to As String) As String
  36:          Return ShopService1.GetPayments(merchant_id, date_from, date_to)
  37:      End Function
  38:   
  39:      Public Sub SendRoster(ByVal DateFrom As String, ByVal DateTo As String, ByVal MerchantID As String, ByVal XML As String)
  40:          Dim Prm1 As New ru.inplat.merchant_remote.SendRoster
  41:          Prm1.date_from = DateFrom
  42:          Prm1.date_to = DateTo
  43:          Prm1.merchant_id = MerchantID
  44:          Prm1.xml = XML
  45:          ShopService1.SendRoster(Prm1)
  46:      End Sub
  47:   
  48:      Public Sub ConfirmPayments(ByVal Payments As String, ByVal Signature As String)
  49:          Dim Prm1 As New ru.inplat.merchant_remote.ConfirmPayments
  50:          Prm1.Payments = Payments
  51:          Prm1.Signature = Signature
  52:          ShopService1.ConfirmPayments(Prm1)
  53:      End Sub
  54:   
  55:  End Class
  56:   


   1:  Public Class TestPaymentContract
   2:      Inherits System.Web.UI.Page
   3:   
   4:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   5:          If Not IsPostBack Then
   6:              If Request.QueryString("PaymentID") IsNot Nothing Then
   7:                  txPaymentID.Text = Request.QueryString("PaymentID")
   8:              End If
   9:          End If
  10:      End Sub
  11:   
  12:      Protected Sub btPaymentContract_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btPaymentContract.Click
  13:          Dim RetSum As Single
  14:          Dim RetSumSpecified As Boolean
  15:          Dim PayeeRegData As String = ""
  16:          Dim Contract As String = ""
  17:          Dim PaymentDelay As Integer
  18:          Dim PaymentDelaySpecified As Boolean
  19:          '
  20:          Try
  21:              Dim TestService As New ru.asp_net.calc.InPlatGateway
  22:              'Dim TestService As New localhost.InPlatGateway
  23:              TestService.PaymentContract(txPaymentID.Text, _
  24:              txAccount.Text, _
  25:              txAccount.Text, _
  26:              CBool(txCurrencySpecified.Text), _
  27:              CDate(txPaymentTime.Text), _
  28:              CBool(txPaymentTimeSpecified.Text), _
  29:              txPayerAddress.Text, _
  30:              txShopParams.Text, _
  31:              txUserParams.Text, _
  32:              CBool(txDemo.Text), _
  33:              CBool(txDemoSpecified.Text), _
  34:              RetSum, _
  35:              RetSumSpecified, _
  36:              PayeeRegData, _
  37:              Contract, _
  38:              PaymentDelay, _
  39:              PaymentDelaySpecified)
  40:              '
  41:              Lerr1.Text &= "RetSum=" & RetSum & "<br>" & _
  42:              "RetSumSpecified=" & RetSumSpecified & "<br>" & _
  43:              "PayeeRegData=" & PayeeRegData & "<br>" & _
  44:              "Contract=" & Contract.Replace("<", "&lt;").Replace(">", "&gt;") & "<br>" & _
  45:              "PaymentDelay=" & PaymentDelay & "<br>" & _
  46:              "PaymentDelaySpecified=" & PaymentDelaySpecified & "<br>"
  47:              '
  48:          Catch ex As Exception
  49:              Lerr1.Text = ex.Message
  50:          End Try
  51:      End Sub
  52:  End Class


Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19
Link to this page: http://www.vb-net.com/InplatGate/index.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <MAIL ME>  <ABOUT ME>  < THANKS ME>