提交 8faefaca 编写于 作者: T Terry

paypal 支付调整

上级 4c24b44e
......@@ -120,11 +120,18 @@ class OrderController extends AppapiTokenController
$orderStatusAllowArr = [
$orderService->payment_status_pending,
$orderService->payment_status_processing,
$orderService->payment_status_confirmed,
$orderService->payment_status_canceled,
$orderService->payment_status_complete,
$orderService->payment_status_holded,
$orderService->status_holded,
$orderService->payment_status_suspected_fraud,
$orderService->status_processing,
$orderService->status_dispatched,
$orderService->status_refunded,
$orderService->status_complete,
];
if (!in_array($order_status, $orderStatusAllowArr)) {
$error[] = '[order_status] value must be in array ['.implode(',',$orderStatusAllowArr).']';
}
......
......@@ -22,14 +22,18 @@ class ExpressController extends AppfrontController
public function actionStart()
{
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$data = $this->getBlock()->startExpress();
}
// 2.Review 从paypal确认后返回
public function actionReview()
{
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$_csrf = Yii::$app->request->post('_csrf');
if ($_csrf) {
if ($_csrf) {
$status = $this->getBlock('placeorder')->getLastData();
if ($status) {
return;
......@@ -46,8 +50,9 @@ class ExpressController extends AppfrontController
public function actionIpn()
{
\Yii::info('paypal ipn begin', 'fecshop_debug');
\Yii::info('paypal ipn begin express', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......
......@@ -23,20 +23,27 @@ class StandardController extends AppfrontController
public function actionStart()
{
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock()->startExpress();
}
// 2.Review 从paypal确认后返回
public function actionReview()
{
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$this->getBlock('placeorder')->getLastData();
}
public function actionIpn()
{
\Yii::info('paypal ipn begin', 'fecshop_debug');
\Yii::info('paypal ipn begin standard', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......
......@@ -22,12 +22,16 @@ class ExpressController extends AppfrontController
public function actionStart()
{
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$data = $this->getBlock()->startExpress();
}
// 2.Review 从paypal确认后返回
public function actionReview()
{
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$_csrf = Yii::$app->request->post('_csrf');
if ($_csrf) {
$status = $this->getBlock('placeorder')->getLastData();
......@@ -46,7 +50,8 @@ class ExpressController extends AppfrontController
public function actionIpn()
{
\Yii::info('paypal ipn begin', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......@@ -58,4 +63,9 @@ class ExpressController extends AppfrontController
Yii::$service->payment->paypal->receiveIpn($post);
}
}
public function actionCancel()
{
return Yii::$service->url->redirectByUrlKey('checkout/onepage');
}
}
......@@ -25,6 +25,8 @@ class StandardController extends AppfrontController
*/
public function actionStart()
{
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock()->startExpress();
}
/**
......@@ -32,6 +34,8 @@ class StandardController extends AppfrontController
*/
public function actionReview()
{
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$this->getBlock('placeorder')->getLastData();
}
/**
......@@ -40,7 +44,8 @@ class StandardController extends AppfrontController
public function actionIpn()
{
\Yii::info('paypal ipn begin', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......
......@@ -95,7 +95,9 @@ class Placeorder
}
}else{
$code = Yii::$service->helper->appserver->order_paypal_standard_payment_fail;
$data = [ ];
$data = [
'error' => Yii::$service->helper->errors->get(','),
];
$reponseData = Yii::$service->helper->appserver->getReponseData($code, $data);
return $reponseData;
......
......@@ -25,6 +25,8 @@ class ExpressController extends AppserverController
if(Yii::$app->request->getMethod() === 'OPTIONS'){
return [];
}
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock()->startExpress();
}
......@@ -34,6 +36,8 @@ class ExpressController extends AppserverController
if(Yii::$app->request->getMethod() === 'OPTIONS'){
return [];
}
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock()->getLastData();
}
// 3. 提交订单
......@@ -41,6 +45,8 @@ class ExpressController extends AppserverController
if(Yii::$app->request->getMethod() === 'OPTIONS'){
return [];
}
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock('placeorder')->getLastData();
}
/**
......@@ -52,7 +58,8 @@ class ExpressController extends AppserverController
return [];
}
\Yii::info('paypal ipn begin', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->express_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......
......@@ -28,6 +28,8 @@ class StandardController extends AppserverController
if(Yii::$app->request->getMethod() === 'OPTIONS'){
return [];
}
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock()->startExpress();
}
/**
......@@ -38,6 +40,8 @@ class StandardController extends AppserverController
if(Yii::$app->request->getMethod() === 'OPTIONS'){
return [];
}
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
return $this->getBlock('placeorder')->getLastData();
}
/**
......@@ -49,7 +53,8 @@ class StandardController extends AppserverController
return [];
}
\Yii::info('paypal ipn begin', 'fecshop_debug');
$payment_method = Yii::$service->payment->paypal->standard_payment_method;
Yii::$service->payment->setPaymentMethod($payment_method);
$post = Yii::$app->request->post();
if (is_array($post) && !empty($post)) {
$post = \Yii::$service->helper->htmlEncode($post);
......
......@@ -19,22 +19,28 @@ use Yii;
*/
class Order extends Service
{
public $requiredAddressAttr; // 必填的订单字段。
public $requiredAddressAttr; // 必填的订单字段。
// 下面是订单支付状态
// 等待支付状态
public $payment_status_pending = 'pending';
// 支付处理中,因为信用卡有预售,因此需要等IPN消息来确认是否支付成功
public $payment_status_processing = 'processing';
// 支付状态已确认,代表已经收到钱了
public $payment_status_confirmed = 'confirmed';
// 订单已取消
public $payment_status_canceled = 'canceled';
// 订单已完成,暂时没有用这个
public $payment_status_complete = 'complete';
// 订单被挂起
public $payment_status_holded = 'holded';
// 欺诈
public $payment_status_suspected_fraud = 'suspected_fraud';
// 等待付款状态
public $payment_status_pending = 'payment_pending';
// 付款处理中,(支付处理中,因为信用卡有预售,因此需要等IPN消息来确认是否支付成功)
public $payment_status_processing = 'payment_processing';
// 收款成功(支付状态已确认,代表已经收到钱了)
public $payment_status_confirmed = 'payment_confirmed';
// 欺诈【当paypal的返回金额和网站金额不一致【以及货币类型】的情况,就会判定该状态】
public $payment_status_suspected_fraud = 'payment_suspected_fraud';
// 订单支付已取消【用户进入paypal点击取消订单返回网站,或者payment_pending订单超过xx时间未支付被脚本取消,或者客服后台取消】
public $payment_status_canceled = 'payment_canceled';
// 订单审核中(订单收款成功后,进入erp,需要客服审核,才能开始发货流程,或者可能存在某些问题,被客服暂时挂起)
public $status_holded = 'holded';
// 订单备货处理中,从成功收款进入erp并客服审核成功后,进入备货流程 到 发货前的状态
public $status_processing = 'processing';
// 订单已发货【订单包裹被物流公司收取后】
public $status_dispatched = 'dispatched';
// 订单已退款【已收款订单因为某些原因进行退款,譬如:仓库无货,用户收到货后发现破损退款等】
public $status_refunded = 'refunded';
// 订单已完成,【用户收到货物xx时间后,未发起纠纷争端,订单状态标记为已完成】
public $status_complete = 'completed';
// 订单号格式。
public $increment_id = 1000000000;
// 将xx分钟内未支付的pending订单取消掉,并释放产品库存的设置
......@@ -82,11 +88,14 @@ class Order extends Service
return [
$this->payment_status_pending => $this->payment_status_pending,
$this->payment_status_processing => $this->payment_status_processing,
$this->payment_status_confirmed => $this->payment_status_confirmed,
$this->payment_status_canceled => $this->payment_status_canceled,
$this->payment_status_complete => $this->payment_status_complete,
$this->payment_status_holded => $this->payment_status_holded,
$this->payment_status_suspected_fraud => $this->payment_status_suspected_fraud,
$this->status_holded => $this->status_holded,
$this->status_processing => $this->status_processing,
$this->status_dispatched => $this->status_dispatched,
$this->status_refunded => $this->status_refunded,
$this->status_complete => $this->status_complete,
];
}
......
......@@ -149,28 +149,6 @@ class Payment extends Service
}
}
/** 废弃
* @property $payment_method | String 支付方式。
* @return string 得到跳转到第三方支付的url。
* #从配置信息中获取
*/
/*
public function getStandardPaymentUrl($payment_method = '')
{
if (!$payment_method) {
$payment_method = $this->getPaymentMethod();
}
if ($payment_method) {
$paymentConfig = $this->paymentConfig;
if (isset($paymentConfig['standard'][$payment_method]['payment_url'])) {
if (!empty($paymentConfig['standard'][$payment_method]['payment_url'])) {
return $paymentConfig['standard'][$payment_method]['payment_url'];
}
}
}
}
*/
/**
* @property $payment_method | String 支付方式。
* @return string 用户名
......@@ -297,6 +275,60 @@ class Payment extends Service
return false;
}
}
public function getStandardNvpUrl($payment_method = '')
{
if (!$payment_method) {
$payment_method = $this->getPaymentMethod();
}
if ($payment_method) {
$paymentConfig = $this->paymentConfig;
if (isset($paymentConfig['standard'][$payment_method]['nvp_url'])) {
if (!empty($paymentConfig['standard'][$payment_method]['nvp_url'])) {
return $paymentConfig['standard'][$payment_method]['nvp_url'];
}
}
}
}
/**
* @property $payment_method | String 支付方式。
* @return 返回进行数据交互的express的label。
*/
public function getStandardLabel($payment_method = '')
{
if (!$payment_method) {
$payment_method = $this->getPaymentMethod();
}
if ($payment_method) {
$paymentConfig = $this->paymentConfig;
if (isset($paymentConfig['standard'][$payment_method]['label'])) {
if (!empty($paymentConfig['standard'][$payment_method]['label'])) {
return $paymentConfig['standard'][$payment_method]['label'];
}
}
}
}
/**
* @property $payment_method | String 支付方式。
* @return 返回进行数据交互的express的signature。
*/
public function getStandardReturnUrl($payment_method = '')
{
if (!$payment_method) {
$payment_method = $this->getPaymentMethod();
}
if ($payment_method) {
$paymentConfig = $this->paymentConfig;
if (isset($paymentConfig['standard'][$payment_method]['return_url'])) {
if (!empty($paymentConfig['standard'][$payment_method]['return_url'])) {
return $this->getUrl($paymentConfig['standard'][$payment_method]['return_url']);
}
}
}
}
//###################
//# Express 部分 ##
......@@ -394,6 +426,8 @@ class Payment extends Service
}
}
}
/**
* @property $payment_method | String 支付方式。
......@@ -434,24 +468,7 @@ class Payment extends Service
}
/**
* @property $payment_method | String 支付方式。
* @return 返回进行数据交互的express的signature。
*/
public function getStandardReturnUrl($payment_method = '')
{
if (!$payment_method) {
$payment_method = $this->getPaymentMethod();
}
if ($payment_method) {
$paymentConfig = $this->paymentConfig;
if (isset($paymentConfig['standard'][$payment_method]['return_url'])) {
if (!empty($paymentConfig['standard'][$payment_method]['return_url'])) {
return $this->getUrl($paymentConfig['standard'][$payment_method]['return_url']);
}
}
}
}
/**
* @property $payment_method | String 支付方式。
......
......@@ -138,12 +138,17 @@ class Paypal extends Service
}
$urlParamStr .= '&cmd=_notify-validate';
$urlParamStr = substr($urlParamStr, 1);
$verifyUrl = Yii::$service->payment->getStandardApiUrl('paypal_standard');
$current_payment_method = Yii::$service->payment->getPaymentMethod();
if ($current_payment_method == $this->standard_payment_method) {
$verifyUrl = Yii::$service->payment->getStandardApiUrl($this->standard_payment_method);
} else {
$verifyUrl = Yii::$service->payment->getExpressApiUrl($this->express_payment_method);
}
$verifyUrl = $verifyUrl.'?'.$urlParamStr;
return $verifyUrl;
}
/**
* @property $url | string, 请求的url
* @property $i | 请求的次数,因为curl可能存在失败的可能,当
......@@ -412,12 +417,20 @@ class Paypal extends Service
*/
public function PPHttpPost5($methodName_, $nvpStr_, $i = 1)
{
$API_NvpUrl = Yii::$service->payment->getExpressNvpUrl($this->express_payment_method);
$API_Signature = Yii::$service->payment->getExpressSignature($this->express_payment_method);
$API_UserName = Yii::$service->payment->getExpressAccount($this->express_payment_method);
$API_Password = Yii::$service->payment->getExpressPassword($this->express_payment_method);
$ipn_url = Yii::$service->payment->getExpressIpnUrl($this->express_payment_method);
$current_payment_method = Yii::$service->payment->getPaymentMethod();
if ($current_payment_method == $this->standard_payment_method) {
$API_NvpUrl = Yii::$service->payment->getStandardNvpUrl($this->standard_payment_method);
$API_Signature = Yii::$service->payment->getStandardSignature($this->standard_payment_method);
$API_UserName = Yii::$service->payment->getStandardAccount($this->standard_payment_method);
$API_Password = Yii::$service->payment->getStandardPassword($this->standard_payment_method);
$ipn_url = Yii::$service->payment->getStandardIpnUrl($this->standard_payment_method);
} else {
$API_NvpUrl = Yii::$service->payment->getExpressNvpUrl($this->express_payment_method);
$API_Signature = Yii::$service->payment->getExpressSignature($this->express_payment_method);
$API_UserName = Yii::$service->payment->getExpressAccount($this->express_payment_method);
$API_Password = Yii::$service->payment->getExpressPassword($this->express_payment_method);
$ipn_url = Yii::$service->payment->getExpressIpnUrl($this->express_payment_method);
}
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
$nvpreq .= "&PAYMENTREQUEST_0_NOTIFYURL=".urlencode($ipn_url);
......@@ -508,7 +521,6 @@ class Paypal extends Service
public function getExpressCheckoutPaymentNvpStr($token)
{
$nvp_array = [];
$nvp_array['PAYERID'] = $this->getExpressPayerID();
$nvp_array['TOKEN'] = $this->getExpressToken();
$nvp_array['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册