# require File.expand_path('../test_assistant', __FILE__) require "digest/md5" require 'pingpp' require 'test/unit' require 'shoulda/context' module Pingpp class ChargeReverseTest < Test::Unit::TestCase should "charge reverse" do Pingpp.api_base = "https://apidev.afon.ninja" Pingpp.api_key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC" order_no = Time.now.to_i.to_s[0,12] channel = "isv_wap" extra = { # 必须,终端号,1~8 位英文或数字,要求不同终端此号码不一样,会显示在对账单中。 :terminal_id => 'A0000007', # 必须,客户端软件中展示的条码值,扫码设备扫描获取。1~32 位字符串。 :pay_channel => 'alipay', :result_url => 'https://example.com', # 可选,商品列表,上送格式参照下面示例。 :goods_list => [ { 'goods_id' => 'iphone6s16G', # 商户定义商品编号(一般为商品条码)。 'unified_goods_id' => '1001', # 统一商品编号,可选。 'goods_name' => 'iPhone 6s 16G', # 商品名称。 'goods_num' => 1, # 商品数量。 'price' => 528800, # 商品价格,单位为分。 'goods_category' => 'smartphone', # 商品类目,可选。 'body' => '苹果手机 iPhone 6s 16G', # 商品描述信息,可选。 'show_url' => 'https://www.example.com', # 商品的展示网址,可选。 } ] } ch = Pingpp::Charge.create( :order_no => order_no, :app => { :id => "app_1Gqj58ynP0mHeX1q" }, :channel => channel,# 支付使用的第三方支付渠道取值,请参考:https://www.pingxx.com/api#api-c-new :amount => 100,# 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100) :client_ip => "127.0.0.1",# 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1 :currency => "cny", :subject => "Your Subject", :body => "Your Body", :extra => extra # extra 对应各渠道的取值规则请查看 charge_extra 相应方法内说明 ) puts ch ch = Pingpp::Charge.reverse(ch.id) puts ch assert ch.object == 'charge' assert ch.order_no == order_no end # should "settle_account update" do # u = Pingpp::SettleAccount.update(get_settle_account_id, {}, {:user => get_user_id}) # assert u.object == 'list' # assert u.data.count <= 3 # end # should "settle_account list" do # l = Pingpp::SettleAccount.list({:per_page => 3}, {:user => get_user_id}) # # assert l.object == 'list' # assert l.data.count <= 3 # end # should "settle_account delete" do # u = Pingpp::SettleAccount.delete(get_settle_account_id, {:user => get_user_id}) # assert u.object == 'deleted' # end end end