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

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

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

[复制链接]
发表于 10-13-2011 01:52 | 显示全部楼层 |阅读模式
authorizenet 主要的信用卡支付网关,国外用的比较多。最近做项目使用到,顺便看了一下。结合ubercart使用。如果使用自动续费功能,那authorizenet也是支持的。
* F0 w; ~/ E* L7 a6 P
  e* t4 c( {2 s$ S8 u0 Q) m' J<?php
) n( J0 `9 }  Y+ T* l: ^4 w3 J5 |- E

; m$ F) E' G1 r6 ~//这个totalOccurrences 就是对这个续费操作的总共次数。
- W# k6 h2 a. t6 A2 W* r- Z$ e1 d3 N6 \
//创建一个arb 1 \$ F) C6 N9 R
function uc_authorizenet_arb_create($order, $fee) {}
/ D" t9 k* |: ?$ k4 j4 W% u
! g( L. a% j- m6 n//更新一个arb 8 x% g! b" U& p5 {6 g+ C3 h
function uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {}
: p$ e3 h# {8 W0 h. r( Y, _& s0 F: E* p( x$ N; ^1 u& I4 F  }% ~4 {. a/ E
//取消arb,如果不取消,那会自动扣款的。) ^. u- z7 n" \- L8 v
function uc_authorizenet_arb_cancel($subscription_id, $order_id = NULL, $fee = array()) {}
6 I! T0 ]" U: B6 D?>

' W4 z7 I4 c: T
% P0 W& O. G4 S+ R; \
7 L2 v% v5 m6 R- T9 Y! _: D: O1 J- u' F) Q* q' j: k& _4 U# I8 j$ g
/ x" g5 E  V' k1 E/ [+ c
$ X0 J  \: r- z
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# |1 ~2 d& y- x. }7 ?, T( d9 P$ W1 h
信用卡支付网关Authorize.Net 续费之 CIM
. D& ?% i4 @/ f  G7 h5 N, h
: p! N" \/ m& J! z4 K/ f3 R. `, c6 k% _- S  h5 A

' q' m" _7 I; P( p+ f( ZAuthorize.net网关还可以通过CIM来实现续费。本地只要保存一个CIM的customerProfileId你可以读取想要的信息。ubercart的支付网关模块 Authorize还没完善。运行简单的机制,订单下好,在订单order数据库
! x9 p% S5 i; j. Sdata字段里面保存customerProfileId等信息。当要需要使用信用卡信息的时候在通过author网关通过customerProfileId来读取进行续费操作。, Y1 a0 w0 U( Y0 o3 G$ s
7 S. U' F# b4 J4 ~
<?php
1 O, G2 X( n" U8 C" Z1 ?. x// Main handler for processing credit card transactions.
7 I: _9 \; f. M% Y% _; _function uc_authorizenet_charge($order_id, $amount, $data) {( C- a2 r7 T+ f: X
  // Load the order.
7 \  Y9 Z+ f! E' @& N9 a* t3 F  $order = uc_order_load($order_id);% f) _8 w( n1 x7 u0 G9 o3 u9 V

2 c0 [6 I% R' C' \, }# o. k4 M  // Perform the appropriate action based on the transaction type.8 }: \5 l. f/ @) Y' `( F
  switch ($data['txn_type']) {
  x) R1 {( l1 H! G$ y    // Reference transactions are handled through Authorize.Net's CIM. ( o& M) h( d( S. a. f7 [
    case UC_CREDIT_REFERENCE_TXN: // 第一种交易模式,通过CIM来处理交易费用
& q9 N* B& J$ U. \8 a3 L4 N) H      return _uc_authorizenet_cim_profile_charge($order, $amount, $data); // 通过cim续费( o+ |6 h& Q8 H3 K& X
, C# u' o) F7 Z! r' T0 L
    // Set a reference only.7 {" z, z& n" l5 W1 f
    case UC_CREDIT_REFERENCE_SET: //另一模式,只建立一个CIM信息
$ O, Z- W2 c+ [# g      // Return the error message if this failed.  c! f( |6 C. Y
      if ($message = _uc_authorizenet_cim_profile_create($order)) {
5 b& U% i, P5 F' H  C. B8 L        return array('success' => FALSE, 'message' => $message);7 Y0 i  S. U; P
      }
1 D) |  O8 V! E9 U2 `4 Q  K2 _& S      else {* k9 U! x) j3 [2 X+ N( ^0 M
        return array('success' => TRUE, 'message' => t('New customer profile created successfully at Authorize.Net.'));
! n! I. i4 I; a; G& X7 y      }
. J# o( O2 J! V* J' r
1 q- v$ z6 W( O- k1 t7 {/ b    // Accommodate all other transaction types.8 C* [" _5 j8 F! L/ T& ?
    default: // 其他的什么都在这里处理
  A/ n7 R. E1 c      return _uc_authorizenet_charge($order, $amount, $data);    B& }: h9 E4 q6 h; V) T
  }6 Y. k3 n* L9 p1 I  w% u3 [; K
}
3 V7 y& ~% c6 M! E
* K/ d- h8 J5 u& k/**2 ]1 s* s  H% Z+ U/ z' w
* Get a CIM payment profile stored at auth.net.7 {. {9 Y/ q, D, A! K
  从auth.net 得到cim payment 信息。现有的版本好像还没试用到到这个函数,估计作者后期要加上一些功能,
( h& S1 t7 ?6 {5 w  这个函数还不完善。从auth的提供最新的网关接口信息来测试,会出错,因为少加了一个参数customerPaymentProfileId
! `. f; [' d$ }  m9 F" G: ?*/" X( e9 {2 q1 p8 Y
function _uc_authorizenet_cim_payment_profile_get($order, $profile_id, $payment_profile_id) {
! W! ~/ T' E3 e0 D8 ~; P0 {6 M6 i) @  $server = variable_get('uc_authnet_cim_mode', 'disabled');9 T' d4 s' T1 _0 R& z7 W4 o9 ^
  $request = array() Z$ i" r& J0 G% |% v" Z
    'customerProfileId' => $profile_id,0 \. v; L4 i- [8 z+ M
        'customerPaymentProfileId' => $payment_profile_id // 额外添加, % o% K! Q% F3 L$ l
  );
. B! K+ p  N. ?- Q; R
' z& z9 D( b  D  // Request a profile from auth.net.- ?! O6 N- k$ m& W: e
  $xml = _uc_authorizenet_xml_api_wrapper('getCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));
% P- H6 @% R  P+ v1 s# u. I% n  // Parse the response.# ^+ @: b( \0 M. M2 ^! e* P
  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));
4 m" i' z; ]/ c! `  e; t* Y  return $response['resultCode'] == 'Error' ? FALSE : $response;
$ W9 |% z' k! e}
: O% T( }# v; e, T& W8 ]?>

1 _" q" K) }; j
- U2 u5 ?* w. |
" f, z5 ]3 k  |6 w- e# W7 C9 M. ~% c& a# g4 |
4 O% i- z$ p; ~' v

5 V- v! u2 q1 u$ l! D) |: o; o( |/ k
( S# e) e7 C) Q& I! D0 u. w; t9 i2 s! i) K

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

GMT+8, 5-1-2025 12:04 , Processed in 0.325496 second(s), 103 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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