test/alipay/service_test.rb in alipay-0.3.1 vs test/alipay/service_test.rb in alipay-0.4.0
- old
+ new
@@ -79,9 +79,61 @@
assert_equal response_body, Alipay::Service.close_trade(
:out_order_no => 'the-out-order-no'
)
end
+ def test_single_trade_query
+ response_body = <<-EOF
+ <?xml version="1.0" encoding="utf-8"?>
+ <alipay>
+ <is_success>T</is_success>
+ <request>
+ <param name="trade_no">20150123123123</param>
+ <param name="_input_charset">utf-8</param>
+ <param name="service">single_trade_query</param>
+ <param name="partner">PARTNER</param>
+ </request>
+ <response>
+ <trade>
+ <additional_trade_status>DAEMON_CONFIRM_CLOSE</additional_trade_status>
+ <buyer_email>foo@gmail.com</buyer_email>
+ <buyer_id>BUYER_ID</buyer_id>
+ <discount>0.00</discount>
+ <flag_trade_locked>0</flag_trade_locked>
+ <gmt_close>2015-01-20 02:37:00</gmt_close>
+ <gmt_create>2015-01-20 02:17:00</gmt_create>
+ <gmt_last_modified_time>2015-01-20 02:37:00</gmt_last_modified_time>
+ <is_total_fee_adjust>F</is_total_fee_adjust>
+ <operator_role>B</operator_role>
+ <out_trade_no>OUT_TRADE_NO</out_trade_no>
+ <payment_type>1</payment_type>
+ <price>640.00</price>
+ <quantity>1</quantity>
+ <seller_email>bar@gmail.com</seller_email>
+ <seller_id>SELLER_ID</seller_id>
+ <subject>ORDER SUBJECT</subject>
+ <to_buyer_fee>0.00</to_buyer_fee>
+ <to_seller_fee>0.00</to_seller_fee>
+ <total_fee>640.00</total_fee>
+ <trade_no>TRADE_NO</trade_no>
+ <trade_status>TRADE_CLOSED</trade_status>
+ <use_coupon>F</use_coupon>
+ </trade></response>
+ <sign>SIGN</sign>
+ <sign_type>MD5</sign_type>
+ </alipay>
+ EOF
+ FakeWeb.register_uri(
+ :get,
+ %r|https://mapi\.alipay\.com/gateway\.do.*|,
+ :body => response_body
+ )
+
+ assert_equal response_body, Alipay::Service.single_trade_query(
+ :out_order_no => 'the-out-order-no'
+ )
+ end
+
def test_should_send_goods_confirm_by_platform
body = <<-EOF
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>T</is_success>