如何将PHP支付gatway连接到ASP.net项目 [英] How to connect a PHP payment gatway to ASP.net project

查看:148
本文介绍了如何将PHP支付gatway连接到ASP.net项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



亲爱的所有朋友





请帮帮我



我正在开发一个基于nopcommerce的电子商务项目3.10



现在我的客户从 payplug.fr



他们甚至没有ASP.net的示例代码,



他们唯一的样品也是PHP。







他们有这个集成套件



任何帮助将非常感谢



谢谢你好

问候



Raj



他们只是有这个指南,这是在法语我已翻译如下



1简介

本文介绍了PayPlug支付系统集成的任何销售网站

通过付款网址排队。这种模式的目的是想要在电子商务网站上使用PayPlug或者b $ b希望为现有解决方案开发支付模块的开发人员(Magento,

Wordpress,WooCommerce,Prestashop ......)。

一般操作

PayPlug支付分为3个阶段:

1。您创建PayPlug付款的自定义URL,其中包括

,包括金额和后付款返回的URL

2。您将客户端指向网址,这是一个安全的支付页面

(例如https://www.payplug.fr/exemple)

3。付款完成后,PayPlug会将访问者带到通过创建付款指定返回

的URL

同时,PayPlug会向您的
包含交易数据的服务器,表示支付了



安全

PayPlug支持安全支付使用基于Open SSL库的公共/私有RSA密钥进行
加密。这个设备确保没有SSL的电子零售商没有SSL的安全等级,而是设置了一个HTTPS连接的复杂性。

设置HTTPS连接的复杂性。

服务器和您站点之间的所有数据交换都是PayPlug

之一,因此签名以证明数据未被修改。这个机制

在两种情况下发生:

1。将电子商务网站写的消息签到PayPlug

2。通过PayPlug(IPN)验证付款通知

4



























2帐户中的设置

您的申请需要多个配置在

之前设置以生成其第一个支付URL。这些参数与您的账户相关

PayPlug,如果您还没有账户,您可以在一分钟内注册

https://www.payplug.fr /铭文。

配置参数可通过配置URL获得:

https://www.payplug.fr/portal/ecommerce/autoconfig(使用您的
用户名和密码需要PayPlug)。此页面包含配置

a JSON对象,其中包含以下字段:

name

http响应状态代码(如果请求成功,则为200)。 br />
amount_min每笔交易的最低金额(欧元)。

amount_max每笔交易的最高金额(欧元)。

为您的账户货币授权的表币格式

ISO 4217(例如欧元的'EUR')。

url付款时应该指示用户的URL,

完成了数据字段和签名(请参阅'创建付款'中的'参数

< base_url>')。

yourPrivateKey用于签署数据的私钥交易

您发送PayPlug。如果没有此签名,该服务将拒绝

交易请求(请参阅创建付款)。

payplugPublicKey允许您验证发送数据来源的密钥 PayPlug IPN
(参见'通知')。如果这个签名不好,那么你不应该考虑PayPlug提供的反馈,因为它可能已被中间人修改过了。

我们建议您一次从配置

应用程序访问此URL,并将设置保存到文件或数据库中,例如,您的应用程序数据。\\ br
。 />
注意:yourPrivateKey私钥和公钥payplugPublicKey

必须采用PEM格式(这是私钥的base-64表示

RSA) 。您可以在以下地址找到密钥格式的示例:

- 私钥:https://gist.github.com/splanquart/7827287

- 公钥:https ://gist.github.com/splanquart/7827462











3创建付款

要接受付款,您必须将网站访问者引导至URL

表格:< base_url> data =& sign =< signature> ? 。

PHP中的示例代码:

$ url = $ base_url。 ? data =。 $ data。 & sign =$签名。 ;

header(Location:$ url);

exit();

参数< base_url>

这是与您的帐户关联的URL,在配置页面上恢复。

参数

data参数包含您必须发送的交易数据

PayPlug。这些数据必须是base64编码,然后是URL。

PHP中的示例代码:

$ params = array('Amount'=> $ Amount,... );

$ url_params http_build_query =($ params);

$ data = urlencode(base64_encode($ url_params));

预期字段:

名称

金额以美分计算的交易金额(例如420.07兑换427.

货币使用的货币(仅接受欧元,表示'EUR')。

即时付款通知ipn_url:PayPlug服务器的网站网址

在交易提交或退款后立即调用。使

可以从Internet访问此URL。一般来说,它不是开发站(本地)的情况。

return_url(可选)PayPlug URL,如果成功则重定向客户端。

电子邮件(可选)客户的电子邮件地址。

firstname(可选)客户名称。

lastname(可选)客户名称。<数据库中的
order(可选)id命令

客户数据库中的客户(可选)id

custom_datas(可选)数据库中的其他数据







如果你留下一个电子邮件字段,名字,姓氏为空,他们将会

向客户收取费用。

当您拨打

ipn_url时,您将收到字段订单,客户和custom_datas,并允许您提交订单。它们允许您的数据与PayPlug平台上的数据进行简单的对比。

参数< signature>

参数是签名的签名RSA SHA1 +类型基于

字段数据的值(不在base64中编码,即我们的

示例中的变量$ url_params)。

签名的计算必须使用您在检索配置设置时保存的私钥

来完成。签名必须编码

然后base64编码为URL。

PHP中的示例代码:

/ * $ Value = pvkey yourPrivateKey you <通过检索配置设置保存
* /

$ privatekey = openssl_pkey_get_private($ pvkey);

openssl_sign($ url_params $ signature,$ privatekey,

OPENSSL_ALGO_SHA1);

$ signature = urlencode(base64_encode($ signature));

关于返回URL的警告

当客户端被定向到返回URL return_url时,您应该已经从我们的服务器收到了付款通知(IPN)

(参见下一节)。除了

还没有这种情况,我们建议您将订单下达到正在进行中状态

,以防止用户再次支付购物篮,同时不考虑

订单已付。您应该在几分钟内收到IPN。





















即时付款通知4(IPN)

当交易提交或退款时,PayPlug会在结账时向ipn_url字段中提供的URL发送HTTP请求

POST。

警告,您提供的URL必须可以从Internet访问,因此您可以接收POST请求PayPlug。
。这意味着你这样做

不能使用只能在本地访问或受防火墙保护的URL。

数据在请求的正文中,由PayPlug。请求的PayPlug - Signature标题字段中的

签名,以及

的计算方式与通过SHA1 + RSA的付款请求相同。

您应该在签署之前检查以考虑来自IPN的数据。对于

这个,使用公钥payplugPublicKey配置页面。

以下是PayPlug在此次调用中提供的参数:

name

transaction_id交易ID PayPlug。我们建议您保存并将您的网站与相关订单相关联。

status交易状态(0 =付款,还款= 4)

客户现场数据'客户'在结账时提供。

订单现场数据'订单'在结账时提供。

custom_datas字段数据'custom_datas在付款时提供。

PHP中的签名验证示例:

$ headers = getallheaders();

/ *为了增加安全性,将密钥置于大写并恢复
使用大写键的
签名:* /

$ headers = array_change_key_case($ headers,CASE_UPPER);

$ signature = base64_decode($ headers ['PAYPLUG SIGNATURE']);

/ *数据在POST请求格式的主体中发送

JSON(MIME类型= application / json)。示例:{status:0,customer:

2,transaction_id:4121,custom_datas:29,order:42} * / < br $>
$ body = file_get_contents('php:/ / input');

$ data = json_decode($ body,true);

/ * $ Pbkey =您从

页面配置参数中保存的PayPlug公钥* /

$ publicKey = openssl_pkey_get_public($ pbkey);

isSignatureValid openssl_verify = $($ body,$ signature,$ publicKey,

OPENSSL_ALGO_SHA1);

if($ isSignatureValid){/ *考虑到IPN * /}







5常见问题

如何测试我的集成?

在测试API时,我们没有测试环境或沙箱。

但是,我们邀请您进行实际交易并支付
以后付款:我们也退还佣金。这将允许

在实际条件下免费测试你的集成。

Getallheaders这个功能不存在,我该怎么办?

PHP getallheaders()函数是apache_request_headers()函数的别名,因此只有在你使用Apache作为服务器时它才有效(它还适用于带有FastCGI for PHP 5.4的
) )。在其他情况下,您可以找到以下地址的

代码示例:https://gist.github.com/splanquart/7826749。

如何调用来自PHP的autoconfig的url?

您可以使用curl_execPHP。一个例子可用

以下地址:https://gist.github.com/splanquart/7827949

谷歌翻译业务:翻译工具包网站翻译全球市场搜索
关闭即时翻译关于Google TranslateMobilePrivacyHelp发送反馈


Dear all friends


Please help me

I am working on an ecommerce project which is based on nopcommerce 3.10

Now my client has purchased a payment gateway from payplug.fr

They don't even have sample codes for ASP.net ,

The only sample they have is also in PHP .



They have this integration kit

Any help will be really appreciated

Thank You
Regards

Raj

They Just have this guide which is in french i have translated this below

1 Introduction
This paper describes the integration of payment system PayPlug any sales site
line through the payment URL . This mode is intended
developers who want to use PayPlug on an e- commerce site or
wish to develop a payment module for an existing solution ( Magento,
Wordpress, WooCommerce , Prestashop ...).
General Operation
PayPlug payment takes place in 3 stages:
1 . You create a custom URL to PayPlug payment , which includes
including the amount and the URL of post-paid return
2 . You direct your client to the url which is a secure payment page
(eg https://www.payplug.fr/exemple )
3 . Once payment completed PayPlug takes the visitor to the URL that return
you specified by creating payment
In parallel, PayPlug sends a notification IPN (Instant Payment Notification) to your
server containing the data of the transaction, indicating that the payment
was made.
security
PayPlug enables secure payments with Open SSL library based
encryption on a public / private RSA key . This device ensures that e-tailers
who do not have SSL secured a level of safety equivalent to SSL site but
the complexity of setting up an HTTPS connection.
All exchanges of data between the server and your site is one of PayPlug
therefore signed to certify that the data has not been modified. this mechanism
occurs in two situations:
1 . Signing messages written by the e- commerce site to PayPlug
2 . Verification of payment notifications from PayPlug (IPN)
4













2 Settings in your account
Your application requires a number of configuration settings before
to generate its first payment URL . These parameters are related to your account
PayPlug , if you do not have an account yet , you can register in one minute
on https://www.payplug.fr/inscription .
The configuration parameters are available through the configuration URL :
https://www.payplug.fr/portal/ecommerce/autoconfig ( authentication with your
username and password PayPlug required). This page contains configuration
a JSON object that contains the following fields :
name
http response status code (200 if the request succeeds) .
amount_min Minimum amount per transaction (in euros) .
amount_max maximum amount per transaction (in euros) .
Table currencies authorized for your account currency format
ISO 4217 (eg 'EUR' for euro ) .
url The URL where you should direct the user at the time of payment,
completed the data fields and signature ( see ' parameter
<base_url> ' in the' Create a payment ') .
yourPrivateKey Your private key used to sign the data transaction
you send PayPlug . Without this signature, the service refuses
transaction request (see ' Create a payment ') .
payplugPublicKey The key that allows you to verify the origin of data sent
by PayPlug IPN (see ' Notifications ') . If this signature is
not good, you should not take into account the feedback provided
by PayPlug as it might have been modified by an intermediary.
We suggest once to access this URL from your configuration
application, and save the settings to a file, or in the database
your application data for example.
Note: yourPrivateKey private key and public key payplugPublicKey
must be in PEM format (this is the base-64 representation of a private key
RSA ) . You can find examples of key format at the following addresses :
- Private Key: https://gist.github.com/splanquart/7827287
- Public Key: https://gist.github.com/splanquart/7827462





3 Creating a payment
To accept a payment, you must direct the site visitor to a URL
Form: <base_url> data = & sign = <signature> ? .
Example code in PHP:
$ url = $ base_url . ? " data = " . $ data . "& sign =" $ signature. ;
header ("Location : $ url ");
exit () ;
The parameter <base_url>
This is the URL associated with your account , recovered on the configuration page.
The parameter
The data parameter contains transaction data that you must send
PayPlug . These data must be base64 encoded and then as a URL .
Example code in PHP:
$ params = array ( 'Amount' => $ Amount , ...);
$ url_params http_build_query = ($ params ) ;
$ data = urlencode ( base64_encode ($ url_params ) ) ;
The expected fields :
name
Amount Amount of transaction in cents (eg 4207 for 42.07
euros) . Your application must ensure that this amount is between
the minimum and maximum amounts (see ' Configuration Settings ') .
currency The currency used (only the euro is accepted, indicate 'EUR' ) .
Instant Payment Notification ipn_url : URL of your site that PayPlug server
called as soon as the transaction is committed or refunded. Make
that this URL is accessible from the Internet. Generally, it is not
not the case for a development station (" local ").
return_url (optional) PayPlug URL that redirects the client if successful .
Email (optional) Email address of the customer.
firstname (Optional ) Name of the client.
lastname (Optional ) Name of the client.
order ( optional) id command in your database
customer (optional) id in your customer database
custom_datas (optional ) Additional data from your database



If you leave an email fields , firstname , lastname empty , they will
charged to the client .
Fields order , customer and custom_datas you are sent when a call on
ipn_url , and allow you to submit an order . They allow easy
reconciliation between your data and those available on the PayPlug platform.
The parameter <signature>
The parameter is a signed signature RSA SHA1 + type based on the value of
field data (not encoded in base64 ie the variable $ url_params in our
example below ) .
The calculation of the signature must be done with the private key that you saved
when retrieving configuration settings . The signature must be encoded
then base64 encoded as a URL .
Example code in PHP:
/ * $ Value = pvkey yourPrivateKey you
saved by retrieving configuration settings * /
$ privatekey = openssl_pkey_get_private ($ pvkey ) ;
openssl_sign ($ url_params $ signature, $ privatekey ,
OPENSSL_ALGO_SHA1 ) ;
$ signature = urlencode ( base64_encode ($ signature) ) ;
Warning about the return URL
When the client is directed to the return URL return_url , you should have already received
the Payment Notification ( IPN) from our server (see next section). Apart from
not yet the case , we recommend that you place the order to a state ' in progress '
to prevent the user to pay the basket again , while not considering
order as paid. You should receive the IPN in a few minutes.










Instant Payment Notification 4 (IPN)
When a transaction is committed or refunded PayPlug sends an HTTP request
POST to the URL provided in the ipn_url field during checkout.
Warning , the URL that you provide must be accessible from the Internet , so you
be able to receive POST request PayPlug . This means that you do
can not use a URL only accessible locally, or protected by a firewall.
The data is in the body of the request , which is signed by PayPlug . the
signature in the PayPlug - Signature header field of the request , and
is calculated in the same manner as the payment request via SHA1 + RSA .
You should check before signing to take into account data from the IPN . for
this, use the public key payplugPublicKey the configuration page.
Here are the parameters provided by PayPlug in this call :
name
transaction_id transaction ID PayPlug . We recommend that you
save and associate your site with the order concerned.
status The status of the transaction ( 0 = payment, repayment = 4 )
customer field data 'customer' provided at checkout.
order field data 'order' provided at checkout.
custom_datas field data ' custom_datas the supplied upon payment.
Example of signature verification in PHP:
$ headers = getallheaders ();
/ * For added security , put the keys in uppercase and recover
signature using the key in uppercase : * /
$ headers = array_change_key_case ( $ headers , CASE_UPPER ) ;
$ signature = base64_decode ( $ headers [' PAYPLUG SIGNATURE ']);
/ * The data is sent in the body of the POST request format
JSON ( MIME type = application / json ) . Example: { "status" : 0, "customer" :
" 2", " transaction_id " : 4121, " custom_datas ": " 29 ", " order" : "42" } * /
$ body = file_get_contents ( 'php :/ / input ');
$ data = json_decode ( $ body , true);
/ * $ Pbkey = PayPlug public key that you saved from the
page configuration parameters * /
$ publicKey = openssl_pkey_get_public ($ pbkey ) ;
isSignatureValid openssl_verify = $ ( $ body , $ signature, $ publicKey ,
OPENSSL_ALGO_SHA1 ) ;
if ($ isSignatureValid ) {/ * Take into account the IPN * /}



5 Frequently Asked Questions
How to test my integration?
On testing the API , we have no test environment or " sandbox ".
However, we invite you to make real transactions and to
pay later : we also refund the commissions. This will allow
test your integration in real conditions at no cost.
Getallheaders the function does not exist , what should I do?
PHP getallheaders () function is an alias of apache_request_headers () function, and
therefore only works if you are using Apache as a server ( it also works
with FastCGI for PHP 5.4). In other cases , you can find an example of
code to the following address : https://gist.github.com/splanquart/7826749 .
How to call the url of autoconfig from PHP?
You can use the " curl_exec " PHP . An example is available
the following address: https://gist.github.com/splanquart/7827949
Google Translate for Business:Translator ToolkitWebsite TranslatorGlobal Market Finder
Turn off instant translationAbout Google TranslateMobilePrivacyHelpSend feedback

推荐答案

url =


base_url。 ? data =。
base_url . ? " data = " .


数据。 & sign =
data . "& sign ="


这篇关于如何将PHP支付gatway连接到ASP.net项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆