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

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

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

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。/ R2 j$ A) D+ C
6 }2 h0 ^  I& H( O' \/ j
<?php* u6 b7 a2 d! d8 s4 G: ~

0 Y! m2 a/ _3 q/ A. x5 f# S% N
: t( ]; |% z8 W* n//这个totalOccurrences 就是对这个续费操作的总共次数。" B4 _4 t6 \: s$ m, _) u; O

2 S" R3 C$ y( C0 p8 q4 n" Y0 h//创建一个arb + A2 g; J6 Z# A! [- B0 {
function uc_authorizenet_arb_create($order, $fee) {} 5 u; n4 l% g5 \$ T% b, ]! O. H

: U2 C8 s$ J, b- x( E//更新一个arb
( G, j' Q4 t0 w1 Sfunction uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}5 X8 I; O& [0 |6 k  E% w9 h$ F8 _

' X5 ~/ n# t) W6 S//取消arb,如果不取消,那会自动扣款的。" N4 Q* B9 U4 C" G3 Z2 @- R
function uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {}
) o1 F; W) t# a- F1 d8 i?>

* c2 {! J; ?2 X- ~/ p9 @$ n! b
0 [2 n' _- c+ f3 c9 |# [! q- Q2 }5 X# ]

( t/ |. T# r" o
  m' x: V0 O, o5 O* G& e" W. x4 c9 A' P1 e+ W( k
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------4 F2 b1 N: g0 k4 b; r! a: }& b

7 g* b3 d0 i. Q8 w0 n信用卡支付网关Authorize.Net 续费之 CIM
4 w3 \5 m# o% L' U9 @" B& ^' L  o& L1 p1 z* t

0 F, S4 e$ n- z3 b% S. Q
& n  a' B* f" ~0 {+ q, rAuthorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库$ e9 p+ v) h/ X7 t2 n
data字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。; A5 r( W8 d2 Z' x3 i: k
! R; J3 W& L) Z/ ?. @
<?php) ~% ~( S3 v0 W* n' X5 k
// Main handler for processing credit card transactions.( m9 m2 z. t. E! h. H
function uc_authorizenet_charge($order_id, $amount, $data) {
2 [! z3 C) @& `/ n, u  // Load the order.
+ T" S$ ^  i- z$ p  $order = uc_order_load($order_id);
# w4 C  R! O6 s+ e0 }
6 J5 l1 [4 D1 ?( t- q  // Perform the appropriate action based on the transaction type.6 r  r! a$ I- t8 V- o4 |' I
  switch ($data['txn_type']) {4 v& t3 c5 p6 ]) E3 G6 S- a! u. t9 d
    // Reference transactions are handled through Authorize.Net's CIM.
1 a. U" _  B& i8 F  k    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用
% X" F5 J- U$ Q4 x      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费4 x/ x8 }' N( K9 Z- M4 t

% O' S8 @, K" U( f0 C; P5 O( _! m    // Set a reference only.+ @0 |9 A* @7 j( S
    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息
& A2 z& X1 h& q! H4 C" U      // Return the error message if this failed.
9 X6 k+ x3 f( d0 L      if ($message = _uc_authorizenet_cim_profile_create($order)) {* H( f4 M) Q6 k
        return array('success' => FALSE, 'message' => $message);( y. ?1 k- R' d3 Z, c9 l2 N
      }" ^4 ^9 j- Y% S5 i+ `; a9 s
      else {
9 a* \/ v, Y+ _% S! A1 K        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));; B4 L, A" v; y$ n! H( B  F8 K4 m
      }- ?  Y6 P/ O% o( X8 s2 ^
( P9 v' ?" n% i% j( H6 m/ U
    // Accommodate all other transaction types.
* V' ?7 R% o& e: d) F    default: // 其他的什么都在这里处理( F* ]; P4 U8 {7 u2 P
      return _uc_authorizenet_charge($order, $amount, $data);  
6 O4 \( d, c% u, u# u  }
% w$ O3 E" u, [+ I}$ c9 j. s' i- R% {

: C" u, R% G0 E# V+ G: G( ~9 U, U/**7 E/ q0 E/ H2 r/ r
* Get a CIM payment profile stored at auth.net.
+ Z4 ~6 Z6 R- g& U6 l7 U5 T  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,& m3 q+ ^+ v4 D
  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId- P9 B' C3 a: L3 U( m5 }
*/1 b! G; V3 ^/ G. d+ y1 w* [
function _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {: _, I2 G+ e2 z. _' ]
  $server = variable_get('uc_authnet_cim_mode', 'disabled');6 b. O' V6 }, \: l% ^5 R
  $request = array(
3 Y/ A! Q* v1 J% D; Z    'customerProfileId' => $profile_id,4 s' ?! G* \/ c) K9 S
        'customerPaymentProfileId' => $payment_profile_id // 额外添加, 0 R1 [! P( F; `3 }1 ?
  );8 \5 C* i7 ~! W$ I
8 o( \; f1 s) ?% G. ~
  // Request a profile from auth.net.
: u6 Q& s, Z- i2 [. w  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));  [: B3 h* Z. C
  // Parse the response.4 `2 N; l( k! q% p, i! w" T
  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));3 V& s0 k6 D: Z
  return $response['resultCode'] == 'Error' ? FALSE : $response;' s) H! h4 k& }7 ?6 D: |5 E* ^9 {
}
& E8 v/ r. H6 M" Z  m?>

& h; i5 [+ A+ M* j3 g3 n1 \1 p4 Q4 ?) v
  d3 g. F8 V" u  m- V: x) Y

, B5 g' x* a: z
3 D/ q5 H0 S5 i
* r( a  C" m) y3 w2 j+ S' m; I- E- H4 \0 p, i3 G1 o" t. i

% ?- i4 X9 c( w

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

GMT+8, 2-14-2025 23:37 , Processed in 0.297687 second(s), 104 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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