国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

信用卡支付网关Authorize.Net ARB模式主要的ubercart api

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。# Q: i; _; ?- @6 L

. q# M) Q7 Y( n# L* ]<?php$ c; R# g4 e+ d4 C- y' f& t2 e
( u  V+ Y8 X8 p# x( B: @

( i' S& r) R4 b. m$ U, ]//这个totalOccurrences 就是对这个续费操作的总共次数。
* v* o' y! q8 O
2 C9 Y. |! k$ u& B+ [5 K//创建一个arb , z5 K+ t  g0 P: G( B0 W4 F
function uc_authorizenet_arb_create($order, $fee) {}
; b; Z! {$ d8 ]( e, p8 w! }, h1 |! }' S6 _" |; E7 u
//更新一个arb
6 n! g; P+ T/ ?/ c1 [function uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}
" F9 `0 U8 h2 F  G: {" i3 c$ R$ \" R  G3 e$ ^# x. l/ w* z5 x
//取消arb,如果不取消,那会自动扣款的。
% b3 e$ k( E( _$ k/ M0 _) Z1 H8 `function uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {}
2 p5 K" D' T2 m+ n4 L( U?>

6 i% ~8 e; M4 }
7 C, A: U& d& j& \3 P$ i
) Z& m" K; j! e1 ]- P( ?( }' m. ~, a: j! \
) n4 F8 g2 I3 O5 i3 o$ k) o( K
! T- V* ~& e# U. h$ X& l* c# S
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  |7 T* w5 T4 l  y
2 @0 a, M& @8 c2 C" }! B信用卡支付网关Authorize.Net 续费之 CIM
2 ~! U- D4 h7 W) E& d* k' N0 a4 V6 W4 a4 F! z9 d  s+ h+ g) j7 ^

. Z2 C5 @, o( z$ l: Q' m$ J/ J! m. r$ o) ~% a7 U3 e5 `6 r* y
Authorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库
+ e' j3 w4 E8 Z1 ]1 Jdata字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。1 r( T6 ^( u- N1 Z& F$ L. @
+ }, a$ v" Y  ]* k4 I
<?php  s/ z0 O( [1 ^
// Main handler for processing credit card transactions." ?2 v3 p0 f  e5 f' d
function uc_authorizenet_charge($order_id, $amount, $data) {
$ T- S- d! ~. O" d  // Load the order.4 d" F4 P" V% @7 h8 t' A
  $order = uc_order_load($order_id);: ]" s, }: a- {/ `& P
* U! S/ c+ g$ s* J
  // Perform the appropriate action based on the transaction type.
( x8 Y4 ~# m3 b* @: Q6 D" E) N  switch ($data['txn_type']) {* a4 q5 @* _) I3 ~7 \
    // Reference transactions are handled through Authorize.Net's CIM. 4 j; @% s0 u, E" T1 O1 s
    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用
! ^4 S0 e2 y: {3 ^2 e6 O; I. ?& l      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费% M$ Y( }8 M, H( z1 L4 R

* F, w- a7 ?% e2 V    // Set a reference only.6 y# ^8 V# a9 j& ^- W* ^( |
    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息; o& B  D" d% Z2 n4 ]9 u
      // Return the error message if this failed.
' l9 P* L( c( u# {$ S. A      if ($message = _uc_authorizenet_cim_profile_create($order)) {
* L; P. P' n1 N        return array('success' => FALSE, 'message' => $message);) \2 T1 n. |; A% J
      }
" ]: M1 e. Q2 `, d      else {) e( L$ [9 n! M' y2 b( r3 @
        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));
  L$ g  ~0 s" }4 `      }6 ?$ U; \: _- _3 d
3 v  ~" i* F. q2 E$ |; G# P1 Y
    // Accommodate all other transaction types.! V" I3 _: e  H, L3 `# e# ~# Q, c
    default: // 其他的什么都在这里处理
3 `9 k- q5 L$ K' |6 Z      return _uc_authorizenet_charge($order, $amount, $data);  : \' n* q. r  p. S3 l2 ~
  }
% H" W5 M9 g1 X% ^; b}
* M' G, L4 b! q5 [9 u7 _' Q6 n* ^: t4 _
/**& K3 {1 ^7 f$ a; ^
* Get a CIM payment profile stored at auth.net./ n) h6 H% b2 i
  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,5 p  C; F2 ?4 B6 f) g% L
  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId% d# R# C5 ^% J6 A0 x5 U4 X
*/0 u0 K$ L3 Q4 Q' h5 b, s$ p' t9 S
function _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {5 @+ j2 S! S/ T; B
  $server = variable_get('uc_authnet_cim_mode', 'disabled');! r/ f7 B/ U8 m0 w
  $request = array(4 j: E. K3 f0 M9 ]* {* Z
    'customerProfileId' => $profile_id,8 ^( Y# t! V7 i0 M
        'customerPaymentProfileId' => $payment_profile_id // 额外添加, 2 b' t7 u: w, E; M
  );
! H$ e# u3 a# M' }, P) u& V  d
- c( ~0 H* ?( Q  // Request a profile from auth.net.% F( S( _' K: H) @. l2 q& e4 n) N
  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));
, K2 D# O' Q: j, N% R* A  H  // Parse the response.5 E9 e3 l. V  G/ L/ F, C6 [) _, g8 r
  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));: S# I" C( N- l/ e2 \
  return $response['resultCode'] == 'Error' ? FALSE : $response;
/ e/ n8 C4 w' \5 y; d) B}
% c, ]! x/ Y+ E; ^7 ??>
! Q( k" J- Q7 A" m; k1 i
. u* M9 {# h: x- C" E

8 D$ S8 y! e4 Z
" ~2 A; S$ V& \8 X$ E6 x* t7 L& E4 \3 q2 y/ }

% m. \+ @) o7 P2 D: o# |# O$ Y& Z: A, v

, v1 }$ V* n3 h! D

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 4-16-2025 12:59 , Processed in 0.408550 second(s), 105 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表