Skip to content

Commit fe12dba

Browse files
committed
Update to v0.0.22
1 parent 26877da commit fe12dba

14 files changed

+587
-16
lines changed

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22
sudo: false
33

44
python:
5+
- "2.7"
56
- "3.4"
67
- "3.5"
78
- "3.6"
@@ -17,11 +18,15 @@ matrix:
1718
- python: 3.7
1819
dist: xenial
1920
sudo: true
21+
- python: 3.8
22+
dist: xenial
23+
sudo: true
2024
allow_failures:
2125
- python: "pypy"
2226
- python: "pypy3"
2327
# pypy will just crash due to an incompatibility with lxml.
2428
# Newer versions of pypy seem to crash also, so we probably have to fix with a newer version of lxml
29+
- python: "2.7"
2530
- python: "3.4"
2631
- python: "3.5"
2732

sample_code_runner.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
FILECOUNT=0
3+
SAMPLECOUNT=1
34
find samples -print | grep -i -e "\.py$" > list.txt
45

56
echo > output.log
@@ -9,15 +10,17 @@ while IFS="" read -r p || [ -n "$p" ]
910
do
1011
if [[ "$p" =~ $(echo ^\($(sed 's/[[:blank:]]//g' sampleCodeIgnoreList.txt | paste -sd '|' /dev/stdin)\)$) ]]; then
1112
printf '\n\n#### SKIPPED - %s ####\n' "$p"
12-
printf '\n\n#### SKIPPED - %s ####\n' "$p" >> output.log
13+
printf '\n\n#### SKIPPED - %s ####\n' "$p" >> output.log
1314
else
1415
printf '\n\n**** RUNNING - %s ****\n' "$p"
15-
printf '\n\n**** RUNNING - %s ****\n' "$p" >> output.log
16+
printf '\n\n%s **** RUNNING - %s ****\n' "$SAMPLECOUNT" "$p" >> output.log
1617
python "$p" >> output.log
1718
printf '\n\n**** END RUNNING - %s ****\n' "$p" >> output.log
18-
FILECOUNT=$((FILECOUNT+1))
19+
FILECOUNT=$((FILECOUNT+1))
1920
fi
21+
22+
SAMPLECOUNT=$((SAMPLECOUNT+1))
2023
done < list.txt
21-
printf '\n\n**** %s Sample Codes ran successfully ****\n' "$FILECOUNT"
24+
printf '\n\n**** %s Sample Codes ran successfully ****\n' "$SAMPLECOUNT"
2225
printf '\n\n**** %s Sample Codes ran successfully ****\n' "$FILECOUNT" >> output.log
2326
rm -f list.txt

samples/Invoicing/InvoiceSettings/updateinvoicesettings.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ def updateinvoicesettings():
2929

3030
invoiceSettingsInformationDeliveryLanguage = "en-US"
3131
invoiceSettingsInformationDefaultCurrencyCode = "USD"
32-
invoiceSettingsInformation = InvoicingV2InvoiceSettingsGet200ResponseInvoiceSettingsInformation(
32+
invoiceSettingsInformationPayerAuthenticationInInvoicing = "enable"
33+
invoiceSettingsInformation = Invoicingv2invoiceSettingsInvoiceSettingsInformation(
3334
merchant_logo = invoiceSettingsInformationMerchantLogo,
3435
merchant_display_name = invoiceSettingsInformationMerchantDisplayName,
3536
custom_email_message = invoiceSettingsInformationCustomEmailMessage,
3637
enable_reminders = invoiceSettingsInformationEnableReminders,
3738
header_style = invoiceSettingsInformationHeaderStyle.__dict__,
3839
delivery_language = invoiceSettingsInformationDeliveryLanguage,
39-
default_currency_code = invoiceSettingsInformationDefaultCurrencyCode
40+
default_currency_code = invoiceSettingsInformationDefaultCurrencyCode,
41+
payer_authentication_in_invoicing = invoiceSettingsInformationPayerAuthenticationInInvoicing
4042
)
4143

4244
requestObj = InvoiceSettingsRequest(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
from CyberSource import *
2+
import os
3+
import json
4+
from importlib.machinery import SourceFileLoader
5+
6+
config_file = os.path.join(os.getcwd(), "data", "Configuration.py")
7+
configuration = SourceFileLoader("module.name", config_file).load_module()
8+
9+
# To delete None values in Input Request Json body
10+
def del_none(d):
11+
for key, value in list(d.items()):
12+
if value is None:
13+
del d[key]
14+
elif isinstance(value, dict):
15+
del_none(value)
16+
return d
17+
18+
def authorization_with_instrument_identifier_token_creation():
19+
clientReferenceInformationCode = "TC50171_3"
20+
clientReferenceInformation = Ptsv2paymentsClientReferenceInformation(
21+
code = clientReferenceInformationCode
22+
)
23+
24+
25+
processingInformationActionList = []
26+
processingInformationActionList.append("TOKEN_CREATE")
27+
28+
processingInformationActionTokenTypes = []
29+
processingInformationActionTokenTypes.append("instrumentIdentifier")
30+
processingInformationCapture = False
31+
processingInformationCommerceIndicator = "internet"
32+
processingInformation = Ptsv2paymentsProcessingInformation(
33+
action_list = processingInformationActionList,
34+
action_token_types = processingInformationActionTokenTypes,
35+
capture = processingInformationCapture,
36+
commerce_indicator = processingInformationCommerceIndicator
37+
)
38+
39+
paymentInformationCardNumber = "4111111111111111"
40+
paymentInformationCardExpirationMonth = "12"
41+
paymentInformationCardExpirationYear = "2031"
42+
paymentInformationCardSecurityCode = "123"
43+
paymentInformationCard = Ptsv2paymentsPaymentInformationCard(
44+
number = paymentInformationCardNumber,
45+
expiration_month = paymentInformationCardExpirationMonth,
46+
expiration_year = paymentInformationCardExpirationYear,
47+
security_code = paymentInformationCardSecurityCode
48+
)
49+
50+
paymentInformation = Ptsv2paymentsPaymentInformation(
51+
card = paymentInformationCard.__dict__
52+
)
53+
54+
orderInformationAmountDetailsTotalAmount = "102.21"
55+
orderInformationAmountDetailsCurrency = "USD"
56+
orderInformationAmountDetails = Ptsv2paymentsOrderInformationAmountDetails(
57+
total_amount = orderInformationAmountDetailsTotalAmount,
58+
currency = orderInformationAmountDetailsCurrency
59+
)
60+
61+
orderInformationBillToFirstName = "John"
62+
orderInformationBillToLastName = "Doe"
63+
orderInformationBillToAddress1 = "1 Market St"
64+
orderInformationBillToLocality = "san francisco"
65+
orderInformationBillToAdministrativeArea = "CA"
66+
orderInformationBillToPostalCode = "94105"
67+
orderInformationBillToCountry = "US"
68+
orderInformationBillToEmail = "[email protected]"
69+
orderInformationBillToPhoneNumber = "4158880000"
70+
orderInformationBillTo = Ptsv2paymentsOrderInformationBillTo(
71+
first_name = orderInformationBillToFirstName,
72+
last_name = orderInformationBillToLastName,
73+
address1 = orderInformationBillToAddress1,
74+
locality = orderInformationBillToLocality,
75+
administrative_area = orderInformationBillToAdministrativeArea,
76+
postal_code = orderInformationBillToPostalCode,
77+
country = orderInformationBillToCountry,
78+
email = orderInformationBillToEmail,
79+
phone_number = orderInformationBillToPhoneNumber
80+
)
81+
82+
orderInformationShipToFirstName = "John"
83+
orderInformationShipToLastName = "Doe"
84+
orderInformationShipToAddress1 = "1 Market St"
85+
orderInformationShipToLocality = "san francisco"
86+
orderInformationShipToAdministrativeArea = "CA"
87+
orderInformationShipToPostalCode = "94105"
88+
orderInformationShipToCountry = "US"
89+
orderInformationShipTo = Ptsv2paymentsOrderInformationShipTo(
90+
first_name = orderInformationShipToFirstName,
91+
last_name = orderInformationShipToLastName,
92+
address1 = orderInformationShipToAddress1,
93+
locality = orderInformationShipToLocality,
94+
administrative_area = orderInformationShipToAdministrativeArea,
95+
postal_code = orderInformationShipToPostalCode,
96+
country = orderInformationShipToCountry
97+
)
98+
99+
orderInformation = Ptsv2paymentsOrderInformation(
100+
amount_details = orderInformationAmountDetails.__dict__,
101+
bill_to = orderInformationBillTo.__dict__,
102+
ship_to = orderInformationShipTo.__dict__
103+
)
104+
105+
requestObj = CreatePaymentRequest(
106+
client_reference_information = clientReferenceInformation.__dict__,
107+
processing_information = processingInformation.__dict__,
108+
payment_information = paymentInformation.__dict__,
109+
order_information = orderInformation.__dict__
110+
)
111+
112+
113+
requestObj = del_none(requestObj.__dict__)
114+
requestObj = json.dumps(requestObj)
115+
116+
117+
try:
118+
config_obj = configuration.Configuration()
119+
client_config = config_obj.get_configuration()
120+
api_instance = PaymentsApi(client_config)
121+
return_data, status, body = api_instance.create_payment(requestObj)
122+
123+
print("\nAPI RESPONSE CODE : ", status)
124+
print("\nAPI RESPONSE BODY : ", body)
125+
126+
return return_data
127+
except Exception as e:
128+
print("\nException when calling PaymentsApi->create_payment: %s\n" % e)
129+
130+
if __name__ == "__main__":
131+
authorization_with_instrument_identifier_token_creation()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
from CyberSource import *
2+
import os
3+
import json
4+
from importlib.machinery import SourceFileLoader
5+
6+
config_file = os.path.join(os.getcwd(), "data", "Configuration.py")
7+
configuration = SourceFileLoader("module.name", config_file).load_module()
8+
9+
# To delete None values in Input Request Json body
10+
def del_none(d):
11+
for key, value in list(d.items()):
12+
if value is None:
13+
del d[key]
14+
elif isinstance(value, dict):
15+
del_none(value)
16+
return d
17+
18+
def authorization_with_instrument_identifier_token_id():
19+
clientReferenceInformationCode = "TC50171_3"
20+
clientReferenceInformation = Ptsv2paymentsClientReferenceInformation(
21+
code = clientReferenceInformationCode
22+
)
23+
24+
processingInformationCapture = False
25+
processingInformationCommerceIndicator = "internet"
26+
processingInformation = Ptsv2paymentsProcessingInformation(
27+
capture = processingInformationCapture,
28+
commerce_indicator = processingInformationCommerceIndicator
29+
)
30+
31+
paymentInformationCardExpirationMonth = "03"
32+
paymentInformationCardExpirationYear = "2031"
33+
paymentInformationCardType = "001"
34+
paymentInformationCard = Ptsv2paymentsPaymentInformationCard(
35+
expiration_month = paymentInformationCardExpirationMonth,
36+
expiration_year = paymentInformationCardExpirationYear,
37+
type = paymentInformationCardType
38+
)
39+
40+
paymentInformationInstrumentIdentifierId = "7010000000016241111"
41+
paymentInformationInstrumentIdentifier = Ptsv2paymentsPaymentInformationInstrumentIdentifier(
42+
id = paymentInformationInstrumentIdentifierId
43+
)
44+
45+
paymentInformation = Ptsv2paymentsPaymentInformation(
46+
card = paymentInformationCard.__dict__,
47+
instrument_identifier = paymentInformationInstrumentIdentifier.__dict__
48+
)
49+
50+
orderInformationAmountDetailsTotalAmount = "200"
51+
orderInformationAmountDetailsCurrency = "usd"
52+
orderInformationAmountDetails = Ptsv2paymentsOrderInformationAmountDetails(
53+
total_amount = orderInformationAmountDetailsTotalAmount,
54+
currency = orderInformationAmountDetailsCurrency
55+
)
56+
57+
orderInformationBillToFirstName = "John"
58+
orderInformationBillToLastName = "Deo"
59+
orderInformationBillToAddress1 = "900 Metro Center Blvd"
60+
orderInformationBillToLocality = "Foster City"
61+
orderInformationBillToAdministrativeArea = "CA"
62+
orderInformationBillToPostalCode = "48104-2201"
63+
orderInformationBillToCountry = "US"
64+
orderInformationBillToEmail = "[email protected]"
65+
orderInformationBillToPhoneNumber = "9321499232"
66+
orderInformationBillTo = Ptsv2paymentsOrderInformationBillTo(
67+
first_name = orderInformationBillToFirstName,
68+
last_name = orderInformationBillToLastName,
69+
address1 = orderInformationBillToAddress1,
70+
locality = orderInformationBillToLocality,
71+
administrative_area = orderInformationBillToAdministrativeArea,
72+
postal_code = orderInformationBillToPostalCode,
73+
country = orderInformationBillToCountry,
74+
email = orderInformationBillToEmail,
75+
phone_number = orderInformationBillToPhoneNumber
76+
)
77+
78+
orderInformation = Ptsv2paymentsOrderInformation(
79+
amount_details = orderInformationAmountDetails.__dict__,
80+
bill_to = orderInformationBillTo.__dict__
81+
)
82+
83+
requestObj = CreatePaymentRequest(
84+
client_reference_information = clientReferenceInformation.__dict__,
85+
processing_information = processingInformation.__dict__,
86+
payment_information = paymentInformation.__dict__,
87+
order_information = orderInformation.__dict__
88+
)
89+
90+
91+
requestObj = del_none(requestObj.__dict__)
92+
requestObj = json.dumps(requestObj)
93+
94+
95+
try:
96+
config_obj = configuration.Configuration()
97+
client_config = config_obj.get_configuration()
98+
api_instance = PaymentsApi(client_config)
99+
return_data, status, body = api_instance.create_payment(requestObj)
100+
101+
print("\nAPI RESPONSE CODE : ", status)
102+
print("\nAPI RESPONSE BODY : ", body)
103+
104+
return return_data
105+
except Exception as e:
106+
print("\nException when calling PaymentsApi->create_payment: %s\n" % e)
107+
108+
if __name__ == "__main__":
109+
authorization_with_instrument_identifier_token_id()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from CyberSource import *
2+
import os
3+
import json
4+
from importlib.machinery import SourceFileLoader
5+
6+
config_file = os.path.join(os.getcwd(), "data", "Configuration.py")
7+
configuration = SourceFileLoader("module.name", config_file).load_module()
8+
9+
process_payment_path = os.path.join(os.getcwd(), "samples", "Payments", "Payments", "electronic-check-debits.py")
10+
process_payment = SourceFileLoader("module.name", process_payment_path).load_module()
11+
12+
# To delete None values in Input Request Json body
13+
def del_none(d):
14+
for key, value in list(d.items()):
15+
if value is None:
16+
del d[key]
17+
elif isinstance(value, dict):
18+
del_none(value)
19+
return d
20+
21+
def electronic_check_followon_refund():
22+
api_payment_response = process_payment.electronic_check_debits()
23+
id = api_payment_response.id
24+
25+
clientReferenceInformationCode = "TC50171_3"
26+
clientReferenceInformation = Ptsv2paymentsClientReferenceInformation(
27+
code = clientReferenceInformationCode
28+
)
29+
30+
processingInformation = Ptsv2paymentsidrefundsProcessingInformation(
31+
)
32+
33+
paymentInformationPaymentTypeName = "CHECK"
34+
paymentInformationPaymentType = Ptsv2paymentsPaymentInformationPaymentType(
35+
name = paymentInformationPaymentTypeName
36+
)
37+
38+
paymentInformation = Ptsv2paymentsidrefundsPaymentInformation(
39+
payment_type = paymentInformationPaymentType.__dict__
40+
)
41+
42+
orderInformationAmountDetailsTotalAmount = "100"
43+
orderInformationAmountDetailsCurrency = "USD"
44+
orderInformationAmountDetails = Ptsv2paymentsidcapturesOrderInformationAmountDetails(
45+
total_amount = orderInformationAmountDetailsTotalAmount,
46+
currency = orderInformationAmountDetailsCurrency
47+
)
48+
49+
orderInformation = Ptsv2paymentsidrefundsOrderInformation(
50+
amount_details = orderInformationAmountDetails.__dict__
51+
)
52+
53+
requestObj = RefundPaymentRequest(
54+
client_reference_information = clientReferenceInformation.__dict__,
55+
processing_information = processingInformation.__dict__,
56+
payment_information = paymentInformation.__dict__,
57+
order_information = orderInformation.__dict__
58+
)
59+
60+
61+
requestObj = del_none(requestObj.__dict__)
62+
requestObj = json.dumps(requestObj)
63+
64+
65+
try:
66+
config_obj = configuration.Configuration()
67+
client_config = config_obj.get_configuration()
68+
api_instance = RefundApi(client_config)
69+
return_data, status, body = api_instance.refund_payment(requestObj, id)
70+
71+
print("\nAPI RESPONSE CODE : ", status)
72+
print("\nAPI RESPONSE BODY : ", body)
73+
74+
return return_data
75+
except Exception as e:
76+
print("\nException when calling RefundApi->refund_payment: %s\n" % e)
77+
78+
if __name__ == "__main__":
79+
electronic_check_followon_refund()

0 commit comments

Comments
 (0)