1 Star 0 Fork 3

hqj168 / Paypal-Stripe支付接口

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

支付接口文档(Paypal,Stripe)

开发环境

  • PHP version 7.2
  • Mysql version 5.7
  • PHP framework Thinkphp 5.1
  • IDE PHPStudy+SublimeText3

本接口主要集成了三种支付方式:

  • Paypal协议支付
  • Paypal常规支付
  • Stripe协议支付

接口地址

www.example.com/api/pay/index

调用流程

  • 带参数请求接口,失败会返回错误信息,成功返回支付页面地址与数据ID

示例

	// 请求参数
	$data = [
        'goods_title'   => '',
        'goods_desc'    => '',
        'goods_amount'  => ,
        'goods_unit'    => '',
        'type'     		=> 1,
        'user_id'       => '',

	];
	// post请求接口  curl函数请自行封装
	$res = curl("api_url", $data);

响应

	{
		"result":"success",
		"code":200,
		"message":"创建成功",
		"param":"",
		"data":
		{"url":"",
			"trade_id":""
		}
	}

错误代码

	[
		102 => '请求方式错误',
		103 => '请选择支付方式',
		104 => '参数缺失',
		105 => '参数格式错误',
		106 => '支付创建失败',
		199 => '服务器错误',
		200 => '创建成功',
	]
  • 访问页面地址,确认支付信息,进行支付

请将返回的url地址urlcode解码后再访问

示例

	get www.example.com?trade_id=1
  • 获取返回信息,完成支付

返回数据(示例)

	[
		// 响应状态 success/fail
	    'result'   => "success",
	    // 响应代码
	    'code'     => '',
	    // 文字信息
	    'message'  => '',
	    // 支付接口错误代码
	    'api_code' => '',
	    // 支付接口错误信息
	    'api_msg'  => '',
	    // 数据返回
	    'data'     => '',
	]

接口调用

调用接口需要配置好三个接口的秘钥参数,需要开发人员操作

参数说明

    [
        // 商品标题
        'goods_title'   => '',
        // 商品描述
        'goods_desc'    => '',
        // 支付价格
        'goods_amount'  => ,
        // 货币单位
        'goods_unit'    => '',
        // 支付方式 1:paypal协议支付 2:paypal常规支付 3:stripe支付
        'type'     => 1,
        // 业务方用户标识ID
        'user_id'         => "",
    ];

Paypal协议支付

简介

  • A reference transaction is a financial transaction from which subsequent transactions can be derived. For example, When a buyer makes a purchase on your site, PayPal generates a transaction ID, called a reference transaction ID. Later, you can use the reference ID to initiate another transaction

接口调用

调用接口时返回支付确认页面,用户确认后调用支付接口执行支付 若用户为第一次支付,会跳转到paypal授权页面进行授权支付 若已经获取到授权,会直接跳转到paypal支付确认页面

参数说明

    [
        // 商品标题
        'goods_title'   => '',
        // 商品描述
        'goods_desc'    => '',
        // 支付价格
        'goods_amount'  => ,
        // 货币单位
        'goods_unit'    => '',
        // 支付方式 1:paypal协议支付 2:paypal常规支付 3:stripe支付
        'type'          => 1,
        // 业务方用户标识ID
        'user_id'       => "",
    ];

接口响应

信息返回格式

	[
		// 响应状态 success/fail
	    'result'   => "success",
	    // 响应代码
	    'code'     => '',
	    // 文字信息
	    'message'  => '',
	    // 支付接口错误代码
	    'api_code' => '',
	    // 支付接口错误信息
	    'api_msg'  => '',
	    // 数据返回
	    'data'     => '',
	]

错误信息代码

	[
		102 => '请求方式错误',
		103 => '请求参数缺失',
		104 => '支付参数缺失',
		105 => '数据储存失败',
		106 => '授权取消',
		107 => '授权失败',
		108 => '支付失败',
		109 => '授权支付失败',
		199 => '服务器连接失败',
		200 => '支付成功',
	]

Paypal常规支付

简介

  • PayPal Checkout with Smart Payment Buttons gives your buyers a simplified and secure checkout experience. PayPal intelligently presents the most relevant payment types to your shoppers, automatically, making it easier for them to complete their purchase using methods like Pay with Venmo, PayPal Credit, credit card payments, iDEAL, Bancontact, Sofort, and other payment types.

接口调用

调用接口时返回支付确认页面,用户确认后调用支付接口执行支付 用户确认后新建浏览器窗口,需要用户登录paypal账号进行登录确认支付 支付成功后页面会有消息提示支付成功

请求参数

	[
		// 应用ID
	    'app_clientid' => '',
	    // 应用秘钥
	    'app_secret'   => '',
	    // 商品标题
	    'goods_title'  => '',
	    // 商品描述
	    'goods_desc'   => '',
	    // 交易金额
	    'goods_amount' => 6.66,
	    // 货币代码
	    'goods_unit'   => '',
        // 支付方式 1:paypal协议支付 2:paypal常规支付 3:stripe支付
        'type'     => 2,
        // 业务方用户标识ID
        'user_id'         => "",
	]

响应

该接口在客户端发起支付,要求客户登录并完成支付,因此,响应信息在页面提示

Stripe协议支付

简介

  • Once you’ve securely collected and tokenized your customer’s credit card using the legacy version of Checkout or Elements, you can charge the card immediately or save it for later. Unlike tokenization, which occurs in the browser, charge attempts are made from your server, normally using one of our client libraries. If you haven’t already, install the library for your favorite language now

接口调用

若用户第一次使用该支付方式,会返回支付信息页面,需要用户填写银行卡等信息,提交后再执行支付 若用户已经授权使用stripe支付,接口会直接执行支付操作,返回支付结果

请求参数

	[
        // 商品标题
        'goods_title'  => '',
        // 商品描述
        'goods_desc'   => '',
        // 商品金额
        'goods_amount' => 6.66,
        // 货币代码
        'goods_unit'   => 'USD',
        // 支付方式 1:paypal协议支付 2:paypal常规支付 3:stripe支付
        'type'     => 3,
        // 业务方用户标识ID
        'user_id'         => "",
    ]

接口响应

响应格式

	[
		// 响应状态 success/fail
	    'result'   => "success",
	    // 响应代码
	    'code'     => '',
	    // 文字信息
	    'message'  => '',
	    // 支付接口错误代码
	    'api_code' => '',
	    // 支付接口错误信息
	    'api_msg'  => '',
	    // 数据返回
	    'data'     => '',
	]

错误代码

	[
		102 => '请求方式错误',
		103 => '请求参数缺失',
		104 => '数据储存失败',
		105 => '银行卡注册失败',
		106 => '客户注册失败',
		107 => '支付发起失败',
		199 => '服务器连接失败',
		200 => '支付成功',
	]

参考链接

空文件

简介

暂无描述 展开 收起
PHP
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/hqj617/payapi.git
git@gitee.com:hqj617/payapi.git
hqj617
payapi
Paypal-Stripe支付接口
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891