云豹直播系统源码-处理谷歌支付回调的教程
云豹直播系统源码功能齐全,源码原生并全部提供给客户,受到了国内外广大用户的好评,随着国外用户的增加,国外支付接口的增加是势在必行的,上次我们介绍了贝宝支付的添加,这次来介绍下谷歌支付回调。
以下直播系统源码来自云豹科技,是根据PhalApi(派框架)的写法做的简单介绍,是针对直播系统源码web端的,实际应用中,还应结合直播App开发组人员的协助配合来共同完成,
以下是对PHP直播系统源码web端代码的简单介绍,仅供参考:
<?php
class Api_Charge extends Api_Common {
public function getRules() {
return array(
'getGoogleNotify' => array(
'signed_data' => array('name' => 'signed_data', 'type' => 'string', 'desc' => '签名数据'),
'signature' => array('name' => 'signature', 'type' => 'string', 'require' => true, 'desc' => '签名'),
'google_orderid' => array('name' => 'google_orderid', 'type' => 'string', 'require' => true, 'desc' => '谷歌订单号'),
'orderid' => array('name' => 'orderid', 'type' => 'string', 'require' => true, 'desc' => '订单号'),
),
);
}
/**
* 谷歌支付:回调
* @desc 用于谷歌支付 获取订单号
* @return int code 操作码,0表示成功
* @return array info
* @return string info[0].orderid 订单号
* @return string msg 提示信息
*/
public function getGoogleNotify() {
$rs = array('code' => 0, 'msg' => '', 'info' => array());
$signed_data=htmlspecialchars_decode($this->checkNull($this->signed_data)); //谷歌支付返回的签名数据
$google_orderid=$this->checkNull($this->google_orderid); //谷歌支付订单号
$signature=$this->signature; //谷歌支付签名
$orderid=$this->checkNull($this->orderid); //订单号(自己生成的)
$public_key_base64 = '谷歌支付的key'; //谷歌key
$key = "-----BEGIN PUBLIC KEY-----\n".
chunk_split($public_key_base64, 64,"\n").
'-----END PUBLIC KEY-----';
//using PHP to create an RSA key
$key = openssl_get_publickey($key);
//$signature should be in binary format, but it comes as BASE64.
//So, I'll convert it.
$signature = base64_decode($signature);
//using PHP's native support to verify the signature
$result = openssl_verify(
$signed_data,
$signature,
$key,
OPENSSL_ALGO_SHA1);
//file_put_contents('./getGoogleNotify.txt',date('y-m-d H:i:s').' 提交参数信息 result:'.json_encode($result)."\r\n",FILE_APPEND);
if ($result ==0) {
$rs['code']=1001;
$rs['msg']="失败";
return $rs;
}else if (1 != $result){
$rs['code']=1002;
$rs['msg']="失败";
return $rs;
}else {
//订单状态修改---处理逻辑
}
$rs['msg']="成功";
return $rs;以上就是本文的基本内容,谷歌支付一般适用于国外用户,国内用户使用支付宝支付、微信支付才是主流,在关于国外支付接口的接入和调用上,我们也写过相应的文章《直播APP源码,Android APP接入Gooale Pay》点击即可查看。
声明:以上内容为云豹科技作者本人原创,未经作者本人同意,禁止转载,否则将追究相关法律责任www.yunbaokj.com






鲁公网安备 37090202000844号

