Click here to Skip to main content
15,898,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I integrate with chinaUnion Payment system, It is a simily to Paypal but only for china.

And I do add the assembly into my references.

But the sample code is writen in .net2.0, and my project writen in .net4.5,

problems is
NetPayClientClass npc = new NetPayClientClass(); 

will show error:Interop type 'ChinaPay_Net.NetPayClientClass' cannot be embedded.

Here is the the code:
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ChinaPay_Net;

namespace Epay
{
   public class Chinapay
    {
       string  strUrl = HttpContext.Current.Request.PhysicalApplicationPath;
      
       public string getSign(string MerId, string OrdId, string TransAmt, string CuryId, string TransDate, string TransType)
       {
           NetPayClientClass npc = new NetPayClientClass(); 
           //npc.setMerKeyFile("Bin/MerPrK.key");         
           npc.setMerKeyFile(strUrl + "\\key\\MerPrK.key");
           string strChkValue = "";                        
           strChkValue = npc.sign(MerId, OrdId, TransAmt, CuryId, TransDate, TransType);
           return strChkValue.Trim();
       }

       public string signData(string MerId, string SignMsg)
       {
           NetPayClientClass npc = new NetPayClientClass(); 
           //npc.setMerKeyFile("Bin/MerPrK.key");         
           npc.setMerKeyFile(strUrl + "\\key\\MerPrK.key");
           string strChkValueData = "";
           strChkValueData = npc.signData(MerId, SignMsg);
           return strChkValueData.Trim();
       }

       public bool getCheck(string MerId, string OrdId, string TransAmt, string CuryId, string TransDate, string TransType, string OrderStatus, string CheckValue)
       {
           NetPayClientClass npc = new NetPayClientClass(); 
           //npc.setPubKeyFile("Bin/PgPubk.key");          //chinapay d:\\PgPubk.key
           npc.setPubKeyFile(strUrl + "\\key\\PgPubk.key");
           string strFlag = "";
           bool bolFlag = false;
           strFlag = npc.check(MerId, OrdId, TransAmt, CuryId, TransDate, TransType, OrderStatus, CheckValue); 
           if (strFlag == "0") //"0"meaning succeed
           {
               bolFlag = true;
           }
           return bolFlag;
       }

       public bool checkData(string PlainData, string CheckValue)
       {
           NetPayClientClass npc = new NetPayClientClass(); //NetPay
           //npc.setPubKeyFile("Bin/PgPubk.key");          //chinapay d:\\PgPubk.key
           npc.setPubKeyFile(strUrl + "\\key\\PgPubk.key");
           string strFlagData = "";
           bool bolFlagData = false;
           strFlagData = npc.checkData(PlainData, CheckValue);
           if (strFlagData == "true")
           {
               bolFlagData = true;
           }
           return bolFlagData;
       }
    }
}

<pre>
Posted

First, Jon Skeet may have solved your problem: [^]: ".NET 4.0 allows primary interop assemblies (or rather, the bits of it that you need) to be embedded into ... open the Properties tab for the assembly in Visual Studio 2010 and set "Embed Interop Types" to "False." "

Note that (amazingly) Skeet didn't quite get this right: you set this Property in the References Node of the Solution Explorer by right-clicking on the specific reference.

If you get an error that mentions "use the applicable interface" as well as "embed interop" see: [^].

If that doesn't work: if you have the source for an application written with .NET 2.0 that is working: make copies of it, and see which later versions of .NET you can convert it to without error. Start by trying to convert to .NET 3.0, for example.

Does ChinaPay have tech support for developers ?
 
Share this answer
 
Thanks BillWoodruff, I just found another assembly to work with the China-Union-Pay.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900