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

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

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

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。
& |% e" ?5 I+ t9 M. N* z4 d% ^( A" @( i+ [1 y8 Y
<?php! V/ s& x, [0 o: S# d
- ?: G7 P' a% K2 Q
# D" m* w& Y4 R& X
//这个totalOccurrences 就是对这个续费操作的总共次数。
5 Y: V' {: Y/ s- ?% k, j( B/ ]0 d
5 j: K; J  t/ V7 ]$ r, o3 k+ n//创建一个arb 3 x' G3 ^9 h# m
function uc_authorizenet_arb_create($order, $fee) {}
& t  m* o7 R) S* l$ B3 P0 o3 L0 v' T" E
//更新一个arb
9 a5 j2 A4 g4 i  Ufunction uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}8 L$ d/ }) A  g! i$ m
- ?& T  q% ^4 E5 A( I& A5 B7 `4 m
//取消arb,如果不取消,那会自动扣款的。  p" z. C5 x% [1 n
function uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {}   K. V. M0 b3 s# M7 C: o7 d8 X! e
?>

$ B$ Y& H5 ^( L
- J3 v2 E* }& l8 ^3 C% [9 g: O$ y# w6 u4 j
1 N1 W( Q; k6 ?2 B

2 w$ V+ A  P3 T) }; ~3 Q5 ^6 o# v# V: k# n. i& l+ y
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
& y7 ?9 i4 u9 D! o$ b4 j
! {5 G- B: v& _' r6 p/ l, V+ I: a信用卡支付网关Authorize.Net 续费之 CIM
  k0 ?' |6 [4 K: l1 U. O  |" S% ^0 F$ ~4 Z5 }$ Z0 Y! t

+ u2 l* h, ~2 |/ M! @
- n4 D2 p3 x9 T+ C  ~- p% OAuthorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库! d; r5 t4 e" @$ i' O$ }" ^- J0 M
data字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。& i. Z0 C$ E1 u. w  i! S3 h) J+ q+ I

; h2 ]* [, j& b; U2 u) @<?php2 A" I4 J6 z/ T: U! X9 A& v
// Main handler for processing credit card transactions.. ]# @) g. k9 o# i' r$ [$ k' K) [/ J
function uc_authorizenet_charge($order_id, $amount, $data) {9 G5 m4 j& e7 P8 u8 E6 `. j
  // Load the order.4 a0 I9 h4 Q1 w/ ~) t
  $order = uc_order_load($order_id);
& C1 b' w3 |6 v) n3 f5 e' [: `  o9 }: R. \
  // Perform the appropriate action based on the transaction type.
( W$ n1 `1 D) L" \* o1 w  switch ($data['txn_type']) {
( h- M/ G4 ^- v    // Reference transactions are handled through Authorize.Net's CIM.
2 k5 i5 |9 `& |* h0 A/ b    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用; U4 |' ]8 Q* S3 g5 T
      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费
! M% ~8 Z+ P" E0 d& e
( {# l7 U3 d  Z* S$ z7 K    // Set a reference only." R5 a2 A! r5 _% B; E$ V
    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息
$ ?7 ]8 c7 K2 \: U8 s      // Return the error message if this failed.0 W# V* G; j. ~6 t( `9 j
      if ($message = _uc_authorizenet_cim_profile_create($order)) {
9 D! z+ }+ F; [. b+ {        return array('success' => FALSE, 'message' => $message);
( s% ]* j0 W# T% B      }; C5 J0 @! W% h7 i7 `5 t& N
      else {- z! J$ i: K+ u) o. p  ?# p1 ^
        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));
3 d3 I  H. i! C" K6 U      }* w3 C9 ]% j! R% W# {" N: ?, G$ X. [
& v5 S2 T; M8 d: g6 n4 u: b
    // Accommodate all other transaction types.. @$ m: F* `% w* `7 G
    default: // 其他的什么都在这里处理' u8 n8 }- J' d! b8 ]3 A. }5 F
      return _uc_authorizenet_charge($order, $amount, $data);  
5 I4 G0 `4 F- g9 m  }
9 I: p  Y( U' J; O7 b}
! T/ ?* J% f5 |( J5 l' d/ r* ^6 \8 q) ~! r# n7 V7 x& Z
/**& J; N, Y" j5 V: e# k! B2 w
* Get a CIM payment profile stored at auth.net.: K8 O7 n& K7 }6 L
  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,
* w' S$ X% L. W1 z! S$ T- q/ z  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId
, f' ~+ y6 V- m( X0 k*/, x3 D7 N& `% k
function _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {' ^* D. Z( p( }% i* g6 a
  $server = variable_get('uc_authnet_cim_mode', 'disabled');
& n* `' ?# F: Y2 S  $request = array(
# H8 j6 J9 q. H- ~, P    'customerProfileId' => $profile_id,# z: A, b+ K/ K* M% q0 @
        'customerPaymentProfileId' => $payment_profile_id // 额外添加, * I% c0 D% R, P* M
  );
: X1 m3 g" s- E3 P8 B! Q! F/ D; O* Q, [# Z+ ~2 ~
  // Request a profile from auth.net.+ p# _* g5 ]* d$ {! h
  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));
1 u1 p+ D- h1 V3 [0 W  ~  // Parse the response.0 R6 o1 x1 |7 x( ^0 Z& F5 e0 o1 @
  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));1 g1 E5 B1 p  [: ?9 R) P8 Q
  return $response['resultCode'] == 'Error' ? FALSE : $response;: s' V* `9 h8 z4 j( i, K( z9 W
}
7 W+ v% \2 E$ o2 [?>

, x- r3 J! _: D( g
& v; l1 r3 }$ G
% M% j, i3 b9 V+ `2 v1 }' Z
' _( }  d% G8 P. N/ J: r# Q5 H% R6 N/ O
& o  B7 R1 D' F, s$ |' ]/ c4 r5 A1 x1 J, r8 R
( |* @& Q1 B4 h7 U

: r; {. \( d5 k5 g8 g9 z1 }

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

GMT+8, 12-6-2025 05:10 , Processed in 0.215091 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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