test/alipay/service_test.rb in alipay-0.13.0 vs test/alipay/service_test.rb in alipay-0.14.0
- old
+ new
@@ -90,15 +90,14 @@
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>T</is_success>
</alipay>
EOF
- FakeWeb.register_uri(
+ stub_request(
:get,
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
- body: response_body
- )
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
+ ).to_return(body: response_body)
assert_equal response_body, Alipay::Service.close_trade(
out_order_no: '1'
)
end
@@ -142,15 +141,14 @@
</trade></response>
<sign>SIGN</sign>
<sign_type>MD5</sign_type>
</alipay>
EOF
- FakeWeb.register_uri(
+ stub_request(
:get,
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
- body: response_body
- )
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
+ ).to_return(body: response_body)
assert_equal response_body, Alipay::Service.single_trade_query(
out_trade_no: '1'
)
end
@@ -160,15 +158,14 @@
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>T</is_success>
</alipay>
EOF
- FakeWeb.register_uri(
+ stub_request(
:get,
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
- body: body
- )
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
+ ).to_return(body: body)
assert_equal body, Alipay::Service.send_goods_confirm_by_platform(
trade_no: 'trade_no',
logistics_name: 'example.com',
transport_type: 'DIRECT'
@@ -226,16 +223,30 @@
</response>
<sign>sign_data</sign>
<sign_type>MD5</sign_type>
</alipay>
EOF
- FakeWeb.register_uri(:get, %r|https://mapi\.alipay\.com/gateway\.do.*|, :body => body)
-
+ stub_request(
+ :get, %r|https://mapi\.alipay\.com/gateway\.do.*|
+ ).to_return(:body => body)
assert_equal body, Alipay::Service.account_page_query(
page_no: 1,
gmt_start_time: (Time.now - 1).strftime('%Y-%m-%d %H:%M:%S'),
gmt_end_time: Time.now.strftime('%Y-%m-%d %H:%M:%S')
)
+ end
+
+ def test_create_forex_trade_wap_url
+ options = {
+ out_trade_no: '20150401000-0001',
+ subject: 'Order Name',
+ merchant_url: 'http://example.com/itemback',
+ total_fee: '10.00', #or rmb_fee, only one
+ currency: 'USD',
+ return_url: 'https://example.com/orders/20150401000-0001',
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
+ }
+ assert_equal 'https://mapi.alipay.com/gateway.do?service=create_forex_trade_wap&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&out_trade_no=20150401000-0001&subject=Order+Name&merchant_url=http%3A%2F%2Fexample.com%2Fitemback&total_fee=10.00¤cy=USD&return_url=https%3A%2F%2Fexample.com%2Forders%2F20150401000-0001¬ify_url=https%3A%2F%2Fexample.com%2Forders%2F20150401000-0001%2Fnotify&sign_type=MD5&sign=f15d9e3d885c12f1a994048342c07bef', Alipay::Service.create_forex_trade_wap_url(options)
end
def test_batch_trans_notify_url
options = {
notify_url: 'https://example.com/orders/20150401000-0001/notify',