private static function connectionCheck() { try { \Pingpp\Pingpp::setApiKey(static::$apiKey); \Pingpp\Charge::retrieve(static::$exampleChargeId); } catch (Exception $e) { if ($e instanceof \Pingpp\Error\ApiConnection) { throw $e; } } }
<?php /* * * Ping++ Server SDK * 说明: * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写, 并非一定要使用该代码。 * 该代码仅供学习和研究 Ping++ SDK 使用,只是提供一个参考。 */ require dirname(__FILE__) . '/../init.php'; \Pingpp\Pingpp::setApiKey('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'); $ch = \Pingpp\Charge::retrieve('ch_a9CmfHTGGaz1urHiL8m5OiX1'); echo $ch;
<?php /* * * Ping++ Server SDK * 说明: * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写, 并非一定要使用该代码。 * 该代码仅供学习和研究 Ping++ SDK 使用,只是提供一个参考。 */ require_once dirname(__FILE__) . '/../init.php'; \Pingpp\Pingpp::setApiKey('YOUR-KEY'); $ch = \Pingpp\Charge::retrieve('CHARGE_ID'); $ch->refunds->create(array('amount' => 10, 'description' => 'Your Descripton'));
/** * [check_charge 查询支付] * @param [type] $charge_id [支付id] * @return [type] [description] */ private function check_charge($charge_id) { try { $charge = \Pingpp\Charge::retrieve($charge_id); $charge = json_decode($charge); if (isset($charge->paid)) { if ($charge->paid) { return $charge; } } return FALSE; } catch (\Pingpp\Error\Base $e) { return FALSE; } }
/** * @author : Comer * @date : 2015/4/20 16:20 * * @desc 通过charge的ID查询支付状态 * @param * @return null */ public function getPaystateById($chargeId) { //引入ping++类库文件 require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/pingpp-php-master/init.php'; \Pingpp\Pingpp::setApiKey(C('MYLINE_KEY')); $Charge = \Pingpp\Charge::retrieve($chargeId); $input_data = json_decode($Charge, true); if ($input_data['object'] == 'charge' && $input_data['paid'] == true) { return true; } else { if ($input_data['object'] == 'charge' && $input_data['paid'] == false) { return false; } } }
/** * @param $chId * @return \Pingpp\Collection */ protected function getRefunds($chId) { return Charge::retrieve($chId)->refunds; }
<?php /* * * Ping++ Server SDK * 说明: * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写, 并非一定要使用该代码。 * 该代码仅供学习和研究 Ping++ SDK 使用,只是提供一个参考。 */ require dirname(__FILE__) . '/../init.php'; \Pingpp\Pingpp::setApiKey('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'); $ch = \Pingpp\Charge::retrieve('ch_ejbLGCCaDWjT0ijzDSybL0mT');
public function refund($chargeId, $orderprice, $description) { $charge = Charge::retrieve($chargeId); $charge->refunds->create(array('amount' => $orderprice, 'description' => $description)); return $charge; }
function isPaid() { $chargeId = $this->post_data->chargeId; try { $res = \Pingpp\Charge::retrieve($chargeId); $isPaid = $res->__toArray()['paid']; if ($isPaid) { $this->echo_msg(true); } else { $this->echo_msg(false, 'UNPAID'); } } catch (Exception $e) { $this->echo_msg(false); } }