/** * @covers pay\Pay::createOrder * @todo Implement testCreateOrder(). */ public function testCreateOrder() { //扫码支付 $data = array('product_id' => '123', 'body' => '测试交易', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 520, 'spbill_create_ip' => '112.95.195.168', 'openid' => 'oK14vt-2cevUlgcPvuzZJOZqp7_k'); $this->object->instance->setMode(2); $result = $this->object->createOrder($data); $this->assertNotFalse($result); }
$object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_amount' => 0.01); try { $result = $object->createOrder($data); var_dump('alipay_qrcode:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_qrcode:' . $e->getMessage()); } //手机网站即时到账支付 $instance = Gateway::getPayment(['alipay' => 'wap']); $object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 0.01, 'show_url' => 'http://www.lohas100.com'); try { $result = $object->createOrder($data); var_dump('alipay_wap:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_wap:' . $e->getMessage()); } //即时到账支付 $instance = Gateway::getPayment(['alipay' => 'wap']); $object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 0.01); try { $result = $object->createOrder($data); var_dump('alipay_web:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_web:' . $e->getMessage()); }