本文整理汇总了Python中PythonNetBanxSDK.OptimalApiClient.OptimalApiClient.hosted_payment_service_handler方法的典型用法代码示例。如果您正苦于以下问题:Python OptimalApiClient.hosted_payment_service_handler方法的具体用法?Python OptimalApiClient.hosted_payment_service_handler怎么用?Python OptimalApiClient.hosted_payment_service_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonNetBanxSDK.OptimalApiClient.OptimalApiClient
的用法示例。
在下文中一共展示了OptimalApiClient.hosted_payment_service_handler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SampleTest_Hosted
# 需要导入模块: from PythonNetBanxSDK.OptimalApiClient import OptimalApiClient [as 别名]
# 或者: from PythonNetBanxSDK.OptimalApiClient.OptimalApiClient import hosted_payment_service_handler [as 别名]
class SampleTest_Hosted(object):
'''
classdocs
'''
_api_key = 'devcentre4628'
_api_password = 'B-qa2-0-548ef25d-302b0213119f70d83213f828bc442dfd0af3280a7b48b1021400972746f9abe438554699c8fa3617063ca4c69a'
_account_number = '89983472'
def __init__(self):
'''
Constructor
'''
# OptimalApiClient Object
self.optimalApiCli = OptimalApiClient(self._api_key,
self._api_password,
"TEST",
self._account_number)
def hosted_payment_monitor(self):
'''
Hosted Payment Monitor
'''
self._optimal_obj = OptimalApiClient(api_key=self._api_key,
api_password=self._api_password, env="TEST",
account_number=self._account_number)
response_object = self._optimal_obj.hosted_payment_service_handler(
).monitor()
print ("response object : ")
print (response_object.status)
def create_order(self):
'''
Create Order
27CIQ2AQY2G5JY31LQ
8d1457c5-d3be-4ebe-919c-accded13a568
'''
order_obj = Order(None)
order_obj.customerIp("14.140.42.67")
order_obj.merchantRefNum(str(RandomTokenGenerator().generateToken()))
order_obj.currencyCode("USD")
order_obj.totalAmount("1125")
order_obj.customerNotificationEmail("[email protected]")
profile_obj = Profile(None)
profile_obj.merchantCustomerId(str(RandomTokenGenerator().generateToken()))
profile_obj.firstName("Jane")
profile_obj.lastName("Smythe")
order_obj.profile(profile_obj)
self._optimal_obj = OptimalApiClient(api_key=self._api_key,
api_password=self._api_password, env="TEST",
account_number=self._account_number)
response_object = self._optimal_obj.hosted_payment_service_handler(
).create_order(order_obj)
print ("Create Order Response: ")
print (response_object.__dict__)
def create_profile_with_order(self):
'''
Create Profile with Order
'''
order_obj = Order(None)
order_obj.merchantRefNum(str(RandomTokenGenerator().generateToken()))
order_obj.currencyCode("USD")
order_obj.totalAmount(1000)
profile_obj = Profile(None)
profile_obj.merchantCustomerId(str(RandomTokenGenerator().generateToken()))
profile_obj.firstName("Jane")
profile_obj.lastName("Smythe")
order_obj.profile(profile_obj)
self._optimal_obj = OptimalApiClient(api_key=self._api_key,
api_password=self._api_password, env="TEST",
account_number=self._account_number)
response_object = self._optimal_obj.hosted_payment_service_handler(
).create_order(order_obj)
print ("Create Order Response: ")
print (response_object.__dict__)
def silent_post(self):
'''
Create Order
27CIQ2AQY2G5JY31LQ
8d1457c5-d3be-4ebe-919c-accded13a568
'''
order_obj = Order(None)
order_obj.customerIp("14.140.42.67")
order_obj.merchantRefNum(str(RandomTokenGenerator().generateToken()))
order_obj.currencyCode("USD")
order_obj.totalAmount("1125")
order_obj.customerNotificationEmail("[email protected]")
profile_obj = Profile(None)
#.........这里部分代码省略.........
示例2: OptimalApiClient
# 需要导入模块: from PythonNetBanxSDK.OptimalApiClient import OptimalApiClient [as 别名]
# 或者: from PythonNetBanxSDK.OptimalApiClient.OptimalApiClient import hosted_payment_service_handler [as 别名]
from PythonNetBanxSDK.OptimalApiClient import OptimalApiClient
from Config import Config
from RandomTokenGenerator import RandomTokenGenerator
optimal_obj = OptimalApiClient(Config.api_key, Config.api_password, Config.environment, Config.account_number)
order_obj = Order(None)
order_obj.customerIp("14.140.42.67")
order_obj.merchantRefNum(str(RandomTokenGenerator().generateToken()))
order_obj.currencyCode("USD")
order_obj.totalAmount("1125")
order_obj.customerNotificationEmail("[email protected]")
profile_obj = Profile(None)
profile_obj.merchantCustomerId(str(RandomTokenGenerator().generateToken()))
profile_obj.firstName("Jane")
profile_obj.lastName("Smythe")
order_obj.profile(profile_obj)
response_object = optimal_obj.hosted_payment_service_handler().create_order(order_obj)
print ('Content-Type: text/html')
print ()
print ('<html>')
print ('<head><title>Hosted Payment - Create Order</title></head>')
print ('<body>')
print (response_object.__dict__)
print ('</body></html>')
示例3: get_transaction_parameters
# 需要导入模块: from PythonNetBanxSDK.OptimalApiClient import OptimalApiClient [as 别名]
# 或者: from PythonNetBanxSDK.OptimalApiClient.OptimalApiClient import hosted_payment_service_handler [as 别名]
def get_transaction_parameters(self, basket, request=None):
"""
Generate a dictionary of signed parameters CyberSource requires to complete a transaction.
Arguments:
basket (Basket): The basket of products being purchased.
Keyword Arguments:
request (Request): A Request object which could be used to construct an absolute URL; not
used by this method.
Returns:
dict: CyberSource-specific parameters required to complete a transaction, including a signature.
"""
parameters = {
'access_key': self.access_key,
'profile_id': self.profile_id,
'transaction_uuid': uuid.uuid4().hex,
'signed_field_names': '',
'unsigned_field_names': '',
'signed_date_time': self.utcnow().strftime(ISO_8601_FORMAT),
'locale': self.language_code,
'transaction_type': 'sale',
'reference_number': basket.order_number,
'amount': str(basket.total_incl_tax),
'currency': basket.currency,
'consumer_id': basket.owner.username,
'override_custom_receipt_page': '{}?orderNum={}'.format(self.receipt_page_url, basket.order_number),
'override_custom_cancel_page': self.cancel_page_url,
}
'''
# XCOM-274: when internal reporting across all processors is
# operational, these custom fields will no longer be needed and should
# be removed.
single_seat = self.get_single_seat(basket)
if single_seat:
parameters['merchant_defined_data1'] = single_seat.attr.course_key
parameters['merchant_defined_data2'] = getattr(single_seat.attr, 'certificate_type', '')
amount = 0
# Level 2/3 details
if self.send_level_2_3_details:
parameters['amex_data_taa1'] = '{}'.format(get_current_request().site.name)
parameters['purchasing_level'] = '3'
parameters['line_item_count'] = basket.lines.count()
# Note (CCB): This field (purchase order) is required for Visa;
# but, is not actually used by us/exposed on the order form.
parameters['user_po'] = 'BLANK'
for index, line in enumerate(basket.lines.all()):
parameters['item_{}_code'.format(index)] = line.product.get_product_class().slug
parameters['item_{}_discount_amount '.format(index)] = str(line.discount_value)
# Note (CCB): This indicates that the total_amount field below includes tax.
parameters['item_{}_gross_net_indicator'.format(index)] = 'Y'
parameters['item_{}_name'.format(index)] = line.product.title
parameters['item_{}_quantity'.format(index)] = line.quantity
parameters['item_{}_sku'.format(index)] = line.stockrecord.partner_sku
parameters['item_{}_tax_amount'.format(index)] = str(line.line_tax)
parameters['item_{}_tax_rate'.format(index)] = '0'
parameters['item_{}_total_amount '.format(index)] = str(line.line_price_incl_tax_incl_discounts)
# Note (CCB): Course seat is not a unit of measure. Use item (ITM).
parameters['item_{}_unit_of_measure'.format(index)] = 'ITM'
parameters['item_{}_unit_price'.format(index)] = str(line.unit_price_incl_tax)
amount = amount + line.unit_price_incl_tax
# Sign all fields
signed_field_names = parameters.keys()
parameters['signed_field_names'] = ','.join(sorted(signed_field_names))
parameters['signature'] = self._generate_signature(parameters)
parameters['payment_page_url'] = self.payment_page_url
'''
# Netbanx object creation
## Move this to the right config file
environmenet = "TEST"
optimal_obj = OptimalApiClient(self.access_key, self.secret_key, environment, self.profile_id)
# 'payment_page_url' seems the only important parameter, as seen with the paypal processor
ip = request.META.get('REMOTE_ADDR')
order_obj = Order(None)
order_obj.customerIp(ip) # Not sure this works
order_obj.merchantRefNum(basket.order_number)
order_obj.currencyCode(basket.currency)
order_obj.totalAmount(basket.total_incl_tax)
# Redirection in case of success
redirect = [{
"rel":'on_success',
'returnKeys': [basket.order_number],
'uri': urljoin(get_ecommerce_url(), reverse('netbanx_notify'))
}]
order_obj.redirect(redirect)
callback_def = [{
'format': 'json',
'uri': urljoin(get_ecommerce_url(), reverse('netbanx_notify')),
'retries': 1,
}]
order_obj.callback(callback_def)
response_object = optimal_obj.hosted_payment_service_handler().create_order(order_obj)
#.........这里部分代码省略.........