setPrivateKeyPath() public static method

public static setPrivateKeyPath ( string $path )
$path string
Ejemplo n.º 1
0
 public function init()
 {
     \Pingpp\Pingpp::setApiKey($this->live ? $this->live_secret_key : $this->test_secret_key);
     if (!empty($this->private_key_path)) {
         if (file_exists($this->private_key_path)) {
             throw new InvalidConfigException('The private key file not exists.');
         }
         \Pingpp\Pingpp::setPrivateKeyPath($this->private_key_path);
     }
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $config = config('pingpp');
     $this->app->bind('pingpp', function () use($config) {
         Pingpp::setApiKey($config['live'] === true ? $config['live_secret_key'] : $config['test_secret_key']);
         if (!empty($config['private_key_path']) && file_exists($config['private_key_path'])) {
             Pingpp::setPrivateKeyPath($config['private_key_path']);
         }
         return new PingppCollertion();
     });
 }
Ejemplo n.º 3
0
 /**
  * @throws InvalidConfigException
  */
 public function init()
 {
     if ($this->apiKey === null) {
         throw new InvalidConfigException('The apiKey property must be set.');
     }
     if ($this->appId === null) {
         throw new InvalidConfigException('The appId property must be set.');
     }
     Pingpp::setApiKey($this->apiKey);
     if (!empty($this->privateKeyPath)) {
         $privateKeyFullPath = Yii::getAlias($this->privateKeyPath);
         if (!file_exists($privateKeyFullPath)) {
             throw new InvalidConfigException('The private key file not exists.');
         }
         Pingpp::setPrivateKeyPath($privateKeyFullPath);
     } elseif (!empty($this->privateKey)) {
         Pingpp::setPrivateKey($this->privateKey);
     }
 }
 public function promotion_pay()
 {
     $api_key = C('API_KEY');
     $api_id = C('API_ID');
     $input_data = json_decode(file_get_contents('php://input'), true);
     if (empty($input_data['channel']) || empty($input_data['amount'])) {
         echo 'channel or amount is empty';
         exit;
     }
     $channel = strtolower($input_data['channel']);
     $submission_id = $input_data['submission_id'];
     $amount = 0;
     $choice1 = $input_data['choice1'];
     if ($choice1 == '1a') {
         $amount = 3000;
     } elseif ($choice1 == '1b') {
         $amount = 8000;
     } elseif ($choice1 == '1c') {
         $amount = 12000;
     } elseif ($choice1 == '1d') {
         $amount = 18000;
     }
     $choice2 = $input_data['choice2'];
     $prices = [3000, 15000, 10000, 1000, 5000, 12000, 500, 200];
     $promotion = $choice1;
     for ($i = 0; $i < count($choice2); $i++) {
         $amount += $choice2[$i] * $prices[$i];
         $promotion .= ',' . $choice2[$i];
     }
     $amount *= 100;
     if ($_SESSION['urole'] == 2) {
         $amount = 1;
     }
     $orderNo = $input_data['order_no'];
     M('promotion')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'submission_id' => $submission_id, 'promotion' => $promotion, 'price' => $amount / 100, 'ispaied' => 0))->delete();
     M('promotion')->data(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'submission_id' => $submission_id, 'promotion_code' => $orderNo, 'promotion' => $promotion, 'timestamp' => time(), 'price' => $amount / 100))->add();
     \Pingpp\Pingpp::setPrivateKeyPath('Public/rsa_private_key.pem');
     /**
      * $extra 在使用某些渠道的时候,需要填入相应的参数,其它渠道则是 array()。
      * 以下 channel 仅为部分示例,未列出的 channel 请查看文档 https://pingxx.com/document/api#api-c-new
      */
     $extra = array();
     $extra['context'] = 'promotion';
     $extra['submission_id'] = $submission_id;
     switch ($channel) {
         case 'alipay_wap':
             $extra = array('success_url' => C('SITE_PREFIX') . U('Pay/promotion_pay_success', array('submission_id' => $submission_id, 'promotion_code' => $orderNo)), 'cancel_url' => C('SITE_PREFIX') . U('Pay/promotion_pay_cancel', array('submission_id' => $submission_id, 'promotion_code' => $orderNo)));
             break;
         case 'bfb_wap':
             $extra = array('result_url' => 'http://example.com/result', 'bfb_login' => true);
             break;
         case 'upacp_wap':
             $extra = array('result_url' => 'http://example.com/result');
             break;
         case 'wx_pub':
             $extra = array('open_id' => 'openidxxxxxxxxxxxx');
             break;
         case 'wx_pub_qr':
             $extra = array('product_id' => 'Productid');
             break;
         case 'yeepay_wap':
             $extra = array('product_category' => '1', 'identity_id' => 'your identity_id', 'identity_type' => 1, 'terminal_type' => 1, 'terminal_id' => 'your terminal_id', 'user_ua' => 'your user_ua', 'result_url' => 'http://example.com/result');
             break;
         case 'jdpay_wap':
             $extra = array('success_url' => 'http://example.com/success', 'fail_url' => 'http://example.com/fail', 'token' => 'dsafadsfasdfadsjuyhfnhujkijunhaf');
             break;
     }
     $subject = '成功设计大赛作品推广 ' . $submission_id;
     \Pingpp\Pingpp::setApiKey($api_key);
     try {
         $ch = \Pingpp\Charge::create(array('subject' => $subject, 'body' => '快来支付吧', 'amount' => $amount, 'order_no' => $orderNo, 'currency' => 'cny', 'extra' => $extra, 'channel' => $channel, 'client_ip' => get_client_ip(), 'app' => array('id' => $api_id)));
         echo $ch;
     } catch (\Pingpp\Error\Base $e) {
         // 捕获报错信息
         if ($e->getHttpStatus() != NULL) {
             header('Status: ' . $e->getHttpStatus());
             echo $e->getHttpBody();
         } else {
             echo $e->getMessage();
         }
     }
 }
Ejemplo n.º 5
0
$input_data = json_decode(file_get_contents('php://input'), true);
if (empty($input_data['channel']) || empty($input_data['amount'])) {
    echo 'channel or amount is empty';
    exit;
}
$channel = strtolower($input_data['channel']);
$amount = $input_data['amount'];
$orderNo = substr(md5(time()), 0, 12);
/**
 * 设置请求签名密钥,密钥对需要你自己用 openssl 工具生成,如何生成可以参考帮助中心:https://help.pingxx.com/article/123161;
 * 生成密钥后,需要在代码中设置请求签名的私钥(rsa_private_key.pem);
 * 然后登录 [Dashboard](https://dashboard.pingxx.com)->点击右上角公司名称->开发信息->商户公钥(用于商户身份验证)
 * 将你的公钥复制粘贴进去并且保存->先启用 Test 模式进行测试->测试通过后启用 Live 模式
 */
// 设置私钥内容方式1
\Pingpp\Pingpp::setPrivateKeyPath(__DIR__ . '/your_rsa_private_key.pem');
// 设置私钥内容方式2
// \Pingpp\Pingpp::setPrivateKey(file_get_contents(__DIR__ . '/your_rsa_private_key.pem'));
/**
 * $extra 在使用某些渠道的时候,需要填入相应的参数,其它渠道则是 array()。
 * 以下 channel 仅为部分示例,未列出的 channel 请查看文档 https://pingxx.com/document/api#api-c-new;
 * 或直接查看开发者中心:https://www.pingxx.com/docs/server/charge;包含了所有渠道的 extra 参数的示例;
 */
$extra = array();
switch ($channel) {
    case 'alipay_wap':
        $extra = array('success_url' => 'http://example.com/success', 'cancel_url' => 'http://example.com/cancel');
        break;
    case 'bfb_wap':
        $extra = array('result_url' => 'http://example.com/result', 'bfb_login' => true);
        break;