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

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

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

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。
" k8 }% I: D- X6 O
" B: ~: O/ V+ C<?php8 ~1 T7 F6 O( _  h
% t9 t* {* M0 k) l  b
1 z# K9 r2 X3 f2 C
//这个totalOccurrences 就是对这个续费操作的总共次数。
( J9 A7 b: C# W$ F' D% U3 C  t, S- x) E6 i$ `) |9 M& O& f; }  D) f
//创建一个arb
/ r3 s5 V  a7 E5 S% C) O8 K1 I: Sfunction uc_authorizenet_arb_create($order, $fee) {}
  ?! P  W  m. O8 w2 [
6 `' w9 X6 W; X+ U: g0 E//更新一个arb
. _& S+ d0 B7 h2 h- G: M7 h$ kfunction uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}/ k- u: X( s* h2 c4 B

# T7 V4 ^* b2 ]4 q$ e9 V//取消arb,如果不取消,那会自动扣款的。
# ]2 X, B8 N2 G4 Lfunction uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {}
  P- [) K+ ^. P0 Z8 N" s& G( t: G9 |?>
, F1 v9 `5 V' D/ Y
+ S  Z$ @" ~4 V$ a/ P" f; R! T
& G6 Z$ @- B% c3 F# n
  N( g1 B8 v$ X# T8 R

2 i2 t* ]# ]# ^2 C0 G7 z5 d5 ]0 z) \1 m$ b, q* u
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
( O& [6 J1 o8 F' D  \; Z5 k1 r' ~/ R
信用卡支付网关Authorize.Net 续费之 CIM, N2 h& ?$ _7 z" X4 N' h1 x

* s+ ~4 A* m" L: E9 T& w% n% e

  Y7 v! I5 E' s; q, N3 h9 c7 XAuthorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库* f5 l2 n' ]' ^# [$ k9 A+ F
data字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。
; S" @5 ~0 c  U
8 A9 C7 j; ]9 m# U<?php
/ F2 f+ F+ ]8 X+ n5 L4 d// Main handler for processing credit card transactions.
* R8 Q" f, m' ufunction uc_authorizenet_charge($order_id, $amount, $data) {( @$ z5 z& P( l7 p2 c6 c$ z8 z
  // Load the order.
. s  h# @4 Z" A; i: |  $order = uc_order_load($order_id);
' O$ B* S% i% {0 {- `1 r
) P9 k4 N. F2 Q3 P7 Z: v  // Perform the appropriate action based on the transaction type.
/ j2 C# ]& r2 Q9 F0 ]  switch ($data['txn_type']) {
1 |) ~. h! Y; ]* \, O    // Reference transactions are handled through Authorize.Net's CIM.   Y+ p2 j8 L0 ?. w* a$ c. v
    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用, h9 k/ S: }0 K: R1 S
      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费
2 P) d8 n' G8 Y8 A' w
  W+ ?& `& ?  y. Y    // Set a reference only.
( d5 [7 U5 H; }4 _& J0 X. X    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息" X; K# b$ {. `+ K2 W
      // Return the error message if this failed.
, ?" n1 n1 w# V      if ($message = _uc_authorizenet_cim_profile_create($order)) {
/ M9 `$ G3 e0 |' `# u        return array('success' => FALSE, 'message' => $message);
# H4 c$ O5 C3 j5 W/ Y      }
: ^: y3 M3 l. a' [' f- z      else {1 ~( h: e% @2 }/ x9 X6 R1 |
        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));( Z+ ~" l" ^9 s6 T
      }
$ U4 G1 F( o4 B6 l0 G9 x4 \' j) T' V  W( {7 t5 q% J2 L4 @
    // Accommodate all other transaction types.7 [$ K1 m( R* `+ o
    default: // 其他的什么都在这里处理
) s( K. m% S4 W5 n& M      return _uc_authorizenet_charge($order, $amount, $data);    ]. f5 C8 [. b+ T  Y2 p7 [( [
  }
$ v7 {  y0 a" S6 M) V- a! |# S' @}
/ w8 d1 K9 t; [! l8 s% s2 z* L9 [' F# G; L2 ^
/**
" A6 P7 L9 I7 N7 V. O, X, Y* Get a CIM payment profile stored at auth.net.$ `9 |* d/ |+ X
  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,
4 `' A* `# Z2 ^2 D' F7 j1 c  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId; O2 I/ N' x( e* `
*/
: [$ d8 C$ p2 o! Ffunction _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {, ?8 d2 W, U' k% p! j  Z# x
  $server = variable_get('uc_authnet_cim_mode', 'disabled');# F) f/ t0 v" I# m; S5 S8 V. Y9 x
  $request = array(  j2 P+ R% v+ A* u8 r
    'customerProfileId' => $profile_id,
8 R# |: B. h- r        'customerPaymentProfileId' => $payment_profile_id // 额外添加,
9 W( }$ N9 f+ y6 K$ t  );' C. V* F- R. {% A, p) [$ S" b

2 a3 B# {% l7 W% t: r  // Request a profile from auth.net.6 I- `5 m- F- v( h, {) E
  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));) |3 b6 v8 p( i. L! a4 i4 p
  // Parse the response.
; G+ N  H$ G( B" Q  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));
$ E  d( w! H5 u1 z+ @! k1 c8 h$ C5 Q) B  return $response['resultCode'] == 'Error' ? FALSE : $response;
, f3 B3 K) A) E}7 t/ l  ~$ k6 V9 h- _0 q8 q
?>

( ?" s* g7 K7 @$ _0 s7 y0 {& }3 C* G9 m6 j) X% c! i
/ `; }9 W3 }7 `! ^  S

3 X" b" N4 |& [. r' F$ A: s4 w$ R1 ~9 G# F, O3 H& r

7 |) D9 s$ _' _# I  A( n) S; R! ]3 b  h8 V
# r9 \1 ^% k) {

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

GMT+8, 7-6-2025 08:45 , Processed in 0.371967 second(s), 104 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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