Class: UnionPei::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/unionpei/payment.rb

Class Method Summary collapse

Class Method Details

.b2b(req = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/unionpei/payment.rb', line 63

def b2b(req = {})
  req = default_b2b_req.merge(req)
  signature = UnionPei::AcpService.sign(req)
  req['signature'] = signature
  url = UnionPei::SDKConfig.instance.frontTransUrl
  UnionPei::AcpService.createAutoFormHtml(req, url)
end

.b2c(req = {}) ⇒ Object

【默认大于配置】哲学



30
31
32
33
34
35
36
# File 'lib/unionpei/payment.rb', line 30

def b2c(req = {})
  req = default_b2c_req.merge(req)
  signature = UnionPei::AcpService.sign(req)
  req['signature'] = signature
  url = UnionPei::SDKConfig.instance.frontTransUrl
  UnionPei::AcpService.createAutoFormHtml(req, url)
end

.default_b2b_reqObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/unionpei/payment.rb', line 38

def default_b2b_req
  {
    'version' => UnionPei::SDKConfig.instance.version,
    'encoding' => UnionPei::SDKConfig.instance.encoding,
    'signMethod' => UnionPei::SDKConfig.instance.signMethod,
    'frontUrl' => UnionPei::SDKConfig.instance.frontUrl,
    'backUrl' => UnionPei::SDKConfig.instance.backUrl,
    'txnType' => '01',
    'txnSubType' => '01',
    'bizType' => '000202', # 000201 是b2c / 000202 是 b2b,
    'channelType' => '07',
    'currencyCode' => '156',
    'txnAmt' => '881000',
    'merId' => '777290058189920',
    'orderId' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s,
    'txnTime' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s,
    'accessType' => '0',
    'payTimeout' => DateTime.parse((Time.now + 15 * 60 * 1000).to_s).strftime('%Y%m%d%H%M%S').to_s,
    'bizScene' => '110001',
    'payeeAcctNm' => 'xx商户',
    'payeeAcctNo' => '12345678',
    'payeeBankName' => 'xx行'
  }
end

.default_b2c_reqObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/unionpei/payment.rb', line 9

def default_b2c_req
  {
    'version' => UnionPei::SDKConfig.instance.version,
    'encoding' => UnionPei::SDKConfig.instance.encoding,
    'signMethod' => UnionPei::SDKConfig.instance.signMethod,
    'frontUrl' => UnionPei::SDKConfig.instance.frontUrl,
    'backUrl' => UnionPei::SDKConfig.instance.backUrl,
    'txnType' => '01',
    'txnSubType' => '01',
    'bizType' => '000201', # 000201 是b2c / 000202 是 b2b
    'channelType' => '07',
    'currencyCode' => '156',
    'txnAmt' => '881000',
    'merId' => '777290058189920',
    'orderId' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s,
    'txnTime' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s,
    'accessType' => '0'
  }
end

.default_trans_reqObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/unionpei/payment.rb', line 71

def default_trans_req
  {
    'version' => UnionPei::SDKConfig.instance.version,
    'encoding' => UnionPei::SDKConfig.instance.encoding,
    'bizType' => '000000',
    'txnTime' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s,
    'txnType' => '00',
    'txnSubType' => '00',
    'accessType' => '0',
    'signMethod' => UnionPei::SDKConfig.instance.signMethod,
    'merId' => '777290058189920',
    'orderId' => DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s
  }
end

.query_trans(req = {}) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/unionpei/payment.rb', line 88

def query_trans(req = {})
  req = default_trans_req.merge(req)
  signature = UnionPei::AcpService.sign(req)
  req['signature'] = signature
  url = UnionPei::SDKConfig.instance.singleQueryUrl
  UnionPei::AcpService.post(req, url)
end