调整app支付
This commit is contained in:
parent
5586293955
commit
845c9a2c09
@ -215,7 +215,7 @@ class WeChatPayService extends BasePayService
|
|||||||
]);
|
]);
|
||||||
$result = $response->toArray(false);
|
$result = $response->toArray(false);
|
||||||
$this->checkResultFail($result);
|
$this->checkResultFail($result);
|
||||||
return $result['prepay_id'];
|
return $this->configForPayment($result['prepay_id'], $appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -390,8 +390,36 @@ class WeChatPayService extends BasePayService
|
|||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function configForPayment($prepayId, $appId)
|
||||||
|
{
|
||||||
|
$config = [
|
||||||
|
'appId' => $appId,
|
||||||
|
'timeStamp' => strval(time()),
|
||||||
|
'nonceStr' => uniqid(),
|
||||||
|
'package' => "prepay_id=$prepayId",
|
||||||
|
'signType' => 'RSA',
|
||||||
|
];
|
||||||
|
$message = $config['appId'] . "\n" .
|
||||||
|
$config['timeStamp'] . "\n" .
|
||||||
|
$config['nonceStr'] . "\n" .
|
||||||
|
$config['package'] . "\n";
|
||||||
|
openssl_sign($message, $raw_sign, $this->getPrivateKey(), 'sha256WithRSAEncryption');
|
||||||
|
$sign = base64_encode($raw_sign);
|
||||||
|
|
||||||
|
$config['paySign'] = $sign;
|
||||||
|
$config['timestamp'] = $config['timeStamp'];
|
||||||
|
unset($config['timeStamp']);
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPrivateKey()
|
||||||
|
{
|
||||||
|
if (!file_exists($this->config['private_key'])) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"SSL certificate not found: {$this->config['private_key']}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return openssl_pkey_get_private(file_get_contents($this->config['private_key']));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user