コード例 #1
0
ファイル: redenvelope.php プロジェクト: ff00x0/shopnc-api
<?php

/* *
 * Ping++ Server SDK
 * 说明:
 * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写, 并非一定要使用该代码。
 * 该代码仅供学习和研究 Ping++ SDK 使用,只是提供一个参考。
*/
require_once dirname(__FILE__) . '/../init.php';
/*
 * To set your key
 * key:the livekey or testkey from your app message from pingpp on the dashboard
 */
\Pingpp\Pingpp::setApiKey('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC');
try {
    /*
     * To Create RedEnvelope
     */
    $red = \Pingpp\RedEnvelope::create(array('subject' => 'Your Subject', 'body' => 'Your Body', 'amount' => 100, 'order_no' => '1234567890', 'currency' => 'cny', 'extra' => array('nick_name' => 'Nick Name', 'send_name' => 'Send Name'), 'recipient' => 'Openid', 'channel' => 'wx_pub', 'app' => array('id' => 'app_1Gqj58ynP0mHeX1q'), 'description' => 'Your Description'));
    echo $red;
} catch (\Pingpp\Error\Base $e) {
    header('Status: ' . $e->getHttpStatus());
    echo $e->getHttpBody();
}
コード例 #2
0
 /**
  * @return bool|\Pingpp\Charge|CodeAutoCompletion\Charge
  * @throws \Exception
  */
 public function create()
 {
     if ($this->validate()) {
         $extra = ['nick_name' => $this->nickname, 'send_name' => $this->sendName];
         if ($this->logo !== null) {
             $extra['logo'] = $this->logo;
         }
         if ($this->shareUrl !== null) {
             $extra['share_url'] = $this->shareUrl;
         }
         if ($this->shareContent !== null) {
             $extra['share_content'] = $this->shareContent;
         }
         if ($this->shareImg !== null) {
             $extra['share_img'] = $this->shareImg;
         }
         $this->_response = RedEnvelope::create(['order_no' => $this->order_no, 'app' => ['id' => $this->getComponent()->appId], 'channel' => $this->channel, 'amount' => $this->amount, 'currency' => $this->currency, 'subject' => $this->subject, 'body' => $this->body, 'extra' => $extra, 'recipient' => $this->recipient, 'description' => $this->description, 'metadata' => $this->metadata]);
         return true;
     }
     return false;
 }
コード例 #3
0
<?php

/* *
 * Ping++ Server SDK
 * 说明:
 * 以下代码只是为了方便商户测试而提供的样例代码,商户可根据自己网站需求按照技术文档编写, 并非一定要使用该代码。
 * 接入红包流程参考开发者中心:https://www.pingxx.com/docs/server/red-envelope ,文档可筛选后端语言和接入渠道。
 * 该代码仅供学习和研究 Ping++ SDK 使用,仅供参考。
*/
require dirname(__FILE__) . '/../init.php';
// api_key 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击管理平台右上角公司名称->开发信息-> Secret Key
$api_key = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC';
// app_id 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击你创建的应用->应用首页->应用 ID(App ID)
$app_id = 'app_1Gqj58ynP0mHeX1q';
\Pingpp\Pingpp::setApiKey($api_key);
try {
    $red = \Pingpp\RedEnvelope::create(array('subject' => 'Your Subject', 'body' => 'Your Body', 'amount' => 100, 'order_no' => date('YmdHis') . microtime(true) % 1 * 1000 . mt_rand(0, 9999), 'currency' => 'cny', 'extra' => array('send_name' => 'Send Name'), 'recipient' => 'Openid', 'channel' => 'wx_pub', 'app' => array('id' => $app_id), 'description' => 'Your Description'));
    echo $red;
    // 输出 Ping++ 返回的红包对象 Red_envelope
} catch (\Pingpp\Error\Base $e) {
    header('Status: ' . $e->getHttpStatus());
    echo $e->getHttpBody();
}
コード例 #4
0
ファイル: redenvelope.php プロジェクト: lanma121/superPrize
<?php

/* *
 * Ping++ Server SDK
 * 说明:
 * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写, 并非一定要使用该代码。
 * 该代码仅供学习和研究 Ping++ SDK 使用,只是提供一个参考。
*/
require_once dirname(__FILE__) . '/../init.php';
$input_data = json_decode(file_get_contents('php://input'), true);
if (empty($input_data['channel']) || empty($input_data['amount'])) {
    exit;
}
$channel = strtolower($input_data['channel']);
$amount = $input_data['amount'];
$orderNo = substr(md5(time()), 0, 12);
/*
 * To set your key
 * key:the livekey or testkey from your app message from pingpp on the dashboard
 */
\Pingpp\Pingpp::setApiKey('YOUR-KEY');
try {
    /*
     * To Create RedEnvelope
     */
    $red = \Pingpp\RedEnvelope::create(array('subject' => 'Your Subject', 'body' => 'Your Body', 'amount' => $amount, 'order_no' => $orderNo, 'currency' => 'cny', 'extra' => array('nick_name' => 'Nick Name', 'send_name' => 'Send Name'), 'recipient' => 'Openid', 'channel' => $channel, 'app' => array('id' => 'YOUR-APP-ID'), 'description' => 'Your Description'));
    echo $red;
} catch (\Pingpp\Error\Base $e) {
    header('Status: ' . $e->getHttpStatus());
    echo $e->getHttpBody();
}