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

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

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

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。
6 @! ]* n( D( m+ N
# h/ U% b1 [7 p7 ?# c) z<?php0 S% g, l, E1 B* I. U

" L* g7 {) L1 _7 t, K/ m7 g$ Z' ]% z* R7 D6 ~
//这个totalOccurrences 就是对这个续费操作的总共次数。6 j# r  n6 @" j8 X% A: l
7 i' d" A! m8 w, Z: S
//创建一个arb
& |$ g' u+ z0 p! d8 ?function uc_authorizenet_arb_create($order, $fee) {}
( M0 r7 j. Y0 P1 @" w( u
0 @9 J4 U4 Z2 ~//更新一个arb
. P: b; ]9 F& v, }+ ^2 P* Xfunction uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}
3 |& R8 D# D+ \. L% F7 K; r7 m
//取消arb,如果不取消,那会自动扣款的。
+ S+ I- A" M% U, i- f) E1 H: Sfunction uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {} 5 Y7 w% D% d* i
?>

& h" w0 {; O7 O0 a6 S/ l; N( Y( M3 \, i8 ?7 G5 i
! p0 _7 _1 J! W% w# k
; h" O" m" x' s+ j; T- X7 v
5 x; ~' N$ A; d- E$ \2 z0 j' d! {
+ e- L/ u+ @6 S# C, a
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  X) m: F0 B3 P, A  f4 u

' ~. w% L) B$ Z1 o- j- T* r6 G信用卡支付网关Authorize.Net 续费之 CIM
3 h  @1 W. U+ L; l1 O6 u. Q+ l
# i5 @6 E2 H) S! s) |4 F* |( M5 ?+ n) F2 B2 @& W
5 |7 [* P% K, t# X7 x4 u8 @
Authorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库, z. O+ s8 m2 C8 ]$ j
data字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。. _+ C% I+ H) _  q. F2 p7 f) g

$ v5 j, d. ?% F5 z' r& }) m! ]  R3 j<?php% D( ?  F2 p9 v
// Main handler for processing credit card transactions.9 f( T9 ~1 Q! }8 \. k1 G% L0 E6 Y
function uc_authorizenet_charge($order_id, $amount, $data) {+ C0 D* |" M! d% D* Y. p
  // Load the order.
, {1 p# m8 W% D5 y+ U4 R: l! e  $order = uc_order_load($order_id);/ q  U- U5 H1 y* p, ^7 S

* y) Q/ C# ~7 }3 }  // Perform the appropriate action based on the transaction type.3 G: }' ?) P4 o5 }
  switch ($data['txn_type']) {
* @+ k- C2 x) P0 X    // Reference transactions are handled through Authorize.Net's CIM.
+ T8 {1 O3 F+ N    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用" r7 n* s; X) O7 U, q8 s! n
      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费( L/ i* e$ ~. s6 E) W
/ B+ l! y; u+ V1 P# v
    // Set a reference only.
* W) u" ]3 @9 H6 M$ C  Q% t5 r. u    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息" {2 [8 f& m2 _, V! F  X. I" x6 ~
      // Return the error message if this failed.
2 ]: P# @0 h- G      if ($message = _uc_authorizenet_cim_profile_create($order)) {
2 p: A' o! l. K& a# z  k  V        return array('success' => FALSE, 'message' => $message);) l! Z; G! X# X4 w8 Y
      }
7 w, }' Q, a7 u      else {
! N1 l8 ^+ X8 x        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));
8 r+ Q0 P; V: S9 M0 t& q8 q8 y      }3 u  b, a5 ?( J  }  N
7 z* n: z8 O/ K- a* F/ `
    // Accommodate all other transaction types.
* o" G; |- ^! l; J    default: // 其他的什么都在这里处理2 I- Y) E7 i7 R1 P$ S) H7 H) h( d
      return _uc_authorizenet_charge($order, $amount, $data);  
1 ~2 M; T" S" _% f& O5 ]+ f  }' L6 ^  F, g1 [6 Y0 ]5 R
}! \# ^! H0 w3 E' [, b- s! v$ E- ?

% z$ |0 T) U" ~. _, {/**
! d; p; i5 t& D: \* Get a CIM payment profile stored at auth.net.
& I& M5 s9 t7 ]+ l( s7 |  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,
" E7 z9 v( c7 |/ D, y  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId
5 j0 L7 F* E; q1 [7 v*/
& C5 ^) J; u$ t% ffunction _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {
- E6 R( {- N8 H+ |3 n$ Z  $server = variable_get('uc_authnet_cim_mode', 'disabled');7 d( R9 x# Q/ X: G* h+ d  ^
  $request = array(5 d& J0 q' Y9 a
    'customerProfileId' => $profile_id,- @& c( R" @% ^/ W4 Z2 p
        'customerPaymentProfileId' => $payment_profile_id // 额外添加, * G; ?3 V! e$ M
  );
2 B! ]9 U) P4 Z: u8 f- q( D) g1 n* q! Z9 _7 V4 A8 t, W- G
  // Request a profile from auth.net.
2 V& r4 r, ^# a& l- J5 S  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));! I8 i) l0 d: f  M
  // Parse the response.
! x7 b- D0 u% D  K# e+ B: N( T  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));
6 F. @8 e; q. d: i3 V1 i  R  return $response['resultCode'] == 'Error' ? FALSE : $response;
4 Y5 P+ `( @1 k) R" D' i}
' k+ N7 k* j, g?>
' b! c, }. m5 @# R
2 w* E3 ^% X( y) o+ K- L

( V! G- U1 c1 O) p
" }1 ^7 M* T0 N  m/ y1 K- s" \7 u- }' q

( E  `9 _+ Z7 C( }2 {7 Q/ @6 t: {$ n, U1 M% [8 Z& N# n7 X

* q5 Q- [1 y% G' I, G

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

GMT+8, 6-21-2025 19:18 , Processed in 0.346819 second(s), 104 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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