クレジットカード払いの承認

□未翻訳

□翻訳中

□翻訳完了(Yota Ichino)

■レビュー(Omi Chiba)

クレジットカード払いの承認

web2pyはクレジットカード払いの承認をあなたのアプリケーションへ組み込むための様々な方法を提供します。例えば:

web2py provides multiple ways for your application to accept credit card payments. For example:

Google Checkout Plugin

http://web2py.com/plugins/static/web2py.plugin.google_checkout.w2p

PayPal

http://www.web2pyslices.com/main/slices/take_slice/9

Authorize.Net

最初の2つの仕組みは外部のサービスへの受け取り人を証明するプロセスを上層に委任します。これがセキュリティにとって最良の方法であると同時に(あなたのアプリケーションは全てにおいてクレジットカード情報を取り扱わない)、それは面倒なプロセス(ユーザーは2回ログインする必要がある; 例えば、1度目はあなたのアプリケーション、もう1回はGoogleに)を生成しあなたのアプリケーションが自動化された方法で繰り返し支払処理するのを許可しません。

The first two mechanisms above delegate the process of authenticating the payee to an external service. While this is the best solution for security (your app does not handle any credit card information at all) it makes the process cumbersome (the user must login twice; for example, once with your app, and once with Google) and does not allow your app to handle recurrent payments in an automated way.

さらに制御が必要な場合があります。このため私たちはAuthorize.Net API(モジュールはJohn Condeによって開発され若干修正されています)との統合を既定で提供しています。ここに全ての変数を公開したワークフローの例を示します:

There are times when you need more control. For this reason we provide integration out of the box with the Authorize.Net API (the module was developed by John Conde and slightly modified). Here is an example of workflow and all the variables that are exposed:

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

17.

18.

19.

20.

21.

22.

23.

24.

25.

26.

27.

28.

29.

30.

31.

32.

33.

34.

35.

36.

37.

from gluon.contrib.AuthorizeNet import AIM

payment = AIM(login='cnpdev4289',

transkey='SR2P8g4jdEn7vFLQ',

testmod=True)

payment.setTransaction(creditcard, expiration, total, cvv, tax, invoice)

payment.setParameter('x_duplicate_window', 180) # three minutes duplicate windows

payment.setParameter('x_cust_id', '1324') # customer ID

payment.setParameter('x_first_name', 'Agent')

payment.setParameter('x_last_name', 'Smith')

payment.setParameter('x_company', 'Test Company')

payment.setParameter('x_address', '1234 Main Street')

payment.setParameter('x_city', 'Townsville')

payment.setParameter('x_state', 'NJ')

payment.setParameter('x_zip', '12345')

payment.setParameter('x_country', 'US')

payment.setParameter('x_phone', '800-555-1234')

payment.setParameter('x_description', 'Test Transaction')

payment.setParameter('x_customer_ip', socket.gethostbyname(socket.gethostname()))

payment.setParameter('x_email', 'you@example.com')

payment.setParameter('x_email_customer', False)

payment.process()

if payment.isApproved():

print 'Response Code: ', payment.response.ResponseCode

print 'Response Text: ', payment.response.ResponseText

print 'Response: ', payment.getResultResponseFull()

print 'Transaction ID: ', payment.response.TransactionID

print 'CVV Result: ', payment.response.CVVResponse

print 'Approval Code: ', payment.response.AuthCode

print 'AVS Result: ', payment.response.AVSResponse

elif payment.isDeclined():

print 'Your credit card was declined by your bank'

elif payment.isError():

print 'It did not work'

print 'approved',payment.isApproved()

print 'declined',payment.isDeclined()

print 'error',payment.isError()

コードの上部はダミー用テストアカウントを使用されていることに注意してください。Authorize.Netに登録(無料ではありません)し、あなたのlogin、transkey、testmode=TrueかFalseをAIMコンストラクタに渡す必要があります。

Notice the code above uses a dummy test account. You need to register with Authorize.Net (it is not a free service) and provide your own login, transkey, testmode=True or False to the AIM constructor.