authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。/ n4 Z$ j9 W% p4 T- U2 Z
9 G2 d) \) ~- M; Z
<?php. d5 z- L0 E6 i. a
2 \* n9 T1 ]$ G9 c* h+ W, w3 W
; `8 ]' F( q! d1 K//这个totalOccurrences 就是对这个续费操作的总共次数。: z Z% P3 e2 N6 Q3 T w' E. S
2 M2 q' U' h* L- l' W3 ?) V//创建一个arb
2 n, `% a' @! @4 J6 [% i6 u% Lfunction uc_authorizenet_arb_create($order, $fee) {}
4 m; _3 J/ I G" C) y1 k
. V; o! h& P* p8 i1 H$ T//更新一个arb - C1 F6 `2 \/ M
function uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}$ H, Q7 R) w' [; W. q
/ H! B) L# A" J1 V//取消arb,如果不取消,那会自动扣款的。
' {. e2 ` d. F7 S `" Ufunction uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {} ! b# b; G+ y S: k, @: P+ }
?>
- H6 A: h, }8 k5 x8 _. `* a. J
5 j$ J7 J. j# \ X
* f" ?/ E7 X: y4 r# T6 o* G
- t7 O% t5 k6 h
( R% |3 u2 N, u) u* N$ p$ D! Y! T6 v$ t
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
O# ]: ^# K, k" l( J* D/ Y; ~! g+ h: a# P' F
信用卡支付网关Authorize.Net 续费之 CIM
) w+ _3 |% Q7 g* f8 ]) ]/ t c. n- M
( |2 F& t5 [& ~2 \- T
- f- Q1 g' `6 XAuthorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库
; ^2 C9 L. W! R: jdata字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。( T0 _- s9 l7 `7 T9 x$ t
+ E+ P6 X% F0 N/ a& m4 f/ ?
<?php0 g6 q+ n9 t3 r6 n4 l+ J/ S
// Main handler for processing credit card transactions.. W4 o, `. x% {5 ]9 g
function uc_authorizenet_charge($order_id, $amount, $data) {1 X, Y3 R0 b) l# l
// Load the order. d! B: h2 P, I% K7 [4 p
$order = uc_order_load($order_id);
' s/ D- \ z+ r4 @, h# X
- w( @+ d- y" C5 K+ W9 J7 W1 h // Perform the appropriate action based on the transaction type.# X' U T! t) Q' c/ S4 O) Q5 w
switch ($data['txn_type']) {
5 ]7 D3 i* B3 W: G# Y% P8 L4 _ // Reference transactions are handled through Authorize.Net's CIM. * [$ l1 L _% d7 A1 I
case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用
5 y# m- R8 c( Y, k' h0 m- a4 k+ v$ D& d return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费
8 t9 v, O, N1 W6 L. T$ K6 `8 s2 ^+ s& s& k0 p4 `7 z0 k% w. ]" F
// Set a reference only.
8 w, A( A3 D% z- B case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息
9 Y, }* x6 i; R* [! e( J // Return the error message if this failed.$ l+ H9 Y& n1 D p2 \
if ($message = _uc_authorizenet_cim_profile_create($order)) {6 Q; a2 O8 B$ v. ?( }6 ~
return array('success' => FALSE, 'message' => $message);
* @* u: B2 F' ~) m8 {/ D; y. C }& o ]+ t' ^. f! o7 y/ p
else {3 [* M, c, I' t# D
return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));6 W: k' q* \# Z+ r1 x h& V- {* p
}
* I" ^+ _ Q! [( Y% r- k1 C6 ?5 Q# x
// Accommodate all other transaction types.
8 o8 y) \. t& [1 V) P1 k4 [ default: // 其他的什么都在这里处理- o1 o$ H+ ` t/ \# G) K
return _uc_authorizenet_charge($order, $amount, $data); 6 \0 I0 f* r' H$ S2 L3 t
}
8 c- c5 K% T6 D4 W. `}* k8 X& n7 r/ R, C
& R. F+ H2 m7 H% ^5 ?6 ~% M
/**0 k' T m/ s, e
* Get a CIM payment profile stored at auth.net.
4 X9 o' ?- S5 w3 |3 Q; U1 u 从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,; {/ _( Q5 [4 \- [+ b3 e) d
这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId3 D! W% a6 W% y
*/
1 [( f' F1 M3 ]2 Xfunction _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {" F d3 ^* A# R4 v) I; `
$server = variable_get('uc_authnet_cim_mode', 'disabled');
7 W. Y1 I# }' w $request = array($ o7 Y% U4 G _2 L1 f. h& D
'customerProfileId' => $profile_id, i4 ?7 ^$ B S
'customerPaymentProfileId' => $payment_profile_id // 额外添加,
( D( q: u+ C) F$ t5 U$ X );& B1 X. C' A& }! |. F/ o# E5 i2 L
7 v1 M3 z4 O( \( ~; V
// Request a profile from auth.net.! M6 F# o4 s9 m+ i. f
$xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));/ x+ J) i# q1 {7 ]9 t. z2 {/ g5 Q7 R% z' I
// Parse the response., {2 z3 \1 w9 y# a O
$response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));( N5 C3 Q9 t* S- a- X
return $response['resultCode'] == 'Error' ? FALSE : $response;
3 R. G# G3 X8 ~; z9 L9 c0 ? Q}" c2 E1 m0 f" [$ R
?>
: {% G: ~# ]# L- k+ u
. t& @3 I* g6 t& V ] , l9 u- u y3 m4 w3 `) A7 \0 c

6 |$ A, E3 I1 {9 f; f4 i
1 I. b0 W) D5 c2 D4 B$ G8 y" M6 _3 W* w
3 \; _4 Y' \; ?& X
, E# J8 o8 j2 J& ?- o/ D/ x. t |
|