1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?php
class PayEaseB2B extends PayEase {
public $v_mid; protected $key;
protected $user_payment_endpoint = array( "B2B" => "http://pay.yizhifubj.com/business/gb/pay_bank.jsp", );
protected $ref_version = "1.0";
protected function generateCustomizedData($args, $payment_method) { $data = []; switch (strtoupper($payment_method)) { case 'B2B': $customer = $this->invoice->customer->decrypt();
$data['v_tag'] = _($this->invoice->code); $data['v_branch'] = _("-1"); $data['v_idtype'] = _("06"); $data['v_idnumber'] = _($customer->identity_id); $data['v_idname'] = _($customer->first_name); $data['v_idcountry'] = _($customer->country_code); $data['v_idaddress'] = _($customer->addresses()->where('address_type', 'BILLING_ADDRESS')->first()->decrypt()->toString2()); $data['v_merdata1'] = _("0652"); $data['v_merdata2'] = _("170"); $data['v_merdata3'] = _("110000"); $data['v_merdata4'] = _("N"); $data['v_merdata5'] = _("Product1"); $data['v_merdata8'] = _("0000"); break;
default: throw new Exception("Error Processing Payment Type: {$payment_method}", 1); }
// $data = array_merge(parent::generateCustomizedData($payment_method), $data); return $data; }
protected function generateSignature($args) { return [ "v_md5info" => $this->_msg_sign("{$args['v_moneytype']}{$args['v_ymd']}{$args['v_amount']}{$args['v_oid']}{$args['v_mid']}{$args['v_branch']}{$args['v_url']}"), // "v_mac" => $this->_msg_sign("{$args['v_oid']}{$args['pmode']}{$args['v_amount']}{$args['v_rcvname']}{$args['v_oid']}{$args['v_mid']}{$args['v_url']}"), ]; }
public function paymentVerify($v_oid, $v_pmode, $v_pstatus, $v_pstring, $v_md5info, $v_amount, $v_moneytype, $v_md5money, $v_sign, &$messages = array()) {
$result = true;
// verify md5info if (!$this->_msg_validate("{$v_oid}{$v_pstatus}{$v_amount}{$v_moneytype}", $v_md5info)) { $result = false; $messages[] = "INVALID MD5INFO"; }
switch ($v_pstatus) { case '1': $messages[] = "PENDING"; // $result = true; break; case '20': $messages[] = "ACCEPTED"; // $result = true; break; case '30': default: $messages[] = "DECLINED"; $result = false; break; } if ($v_pstring) { $messages[] = $v_pstring; }
ApiLog::create([ 'type' => get_class($this), 'endpoint' => __FUNCTION__, 'request' => func_get_args(), 'response' => json_encode($messages), 'status' => $v_pstatus, 'is_success' => $result, ]);
return $result; }
// public function mer_payment_submit_utf8($v_data, $v_version=null){ // $param = array( // 'v_mid' => $this->v_mid, // 'v_data' => $v_data, // 'v_mac' => $this->_msg_sign(_("{$this->v_mid}{$v_data}")), // 'v_version' => $v_version ?: $this->ref_version, // ); // // vdump($this->v_mid, $v_data, $this->_msg_sign("{$this->v_mid}{$v_data}"), $this->_msg_sign(_("{$this->v_mid}{$v_data}"))); // return self::_excute($this->mer_payment_submit_utf8_endpoint, $param); // }
public static function testVerify() { $v_oid = "20060124-888-152331"; $v_pstatus = "1"; $v_pstring = "支付完成"; $v_pmode = "工商銀行企業銀行"; $v_md5info = "47beeb0455d8b8fdfd14307f4a09d9ce"; $v_amount = "0.01"; $v_moneytype = "0"; $v_sign = "3edf00e0570543d8d7f179846cf5ab2f98d4389010eea2ed1b406588a318d19f614eb808bc5f9dc202d842272b1218679dde3623a196b3dc8eff2a7e314cbd356d7de13ae6d0e8120ee4e0859725aaf2315b24d66c869096085df64b483009385451e8f6e7ec14b0c2d48d452e2071553367e04b8860b6e270e96e8ba1d354c7";
$payease = new self(); vdump( $payease->payment_verify($v_oid, $v_pmode, $v_pstatus, $v_pstring, $v_md5info, $v_amount, $v_moneytype, $v_md5info, $v_sign, $messages), $messages ); } }
|