Skip to main content

This SDK provides an organized way to connect and consume Croeminc payment gateway, card storage, and customer management service

Project description

Croeminc Gateway Python SDK

This SDK provides an organized way to connect and consume Croeminc payment gateway, card storage, and customer management services.

v0.6 - Release Notes

  • Adding Preauthorization and Adjustment features

v0.54 - Release Notes

  • Setting up production credentials

v0.53 - Release Notes

  • Clean up of sample code.
  • Cleanup of integration with API

v0.52 - Release Notes

This release contains the basic markup of the future release. You may use the current code to understand how your application would need to interact with the SDK. This SDK performs real communication with the test Gateway API. Following are the definition improvements in this release that allows the SDK to:

  • Create a gateway object with simplified encryption logic
  • Utilize basic transaction operations such as Sale
  • Search for customers
  • Create customers and manage their payment methods
  • Update customers and their cards

Sample Code:

This code is also available in the Sample folder inside of SDK

#Initializing Gateway object with Merchant details and environment
sdk = CroemincGateway("", "", "", "", "")
print("SDK Version " + str(sdk.SDKVersion))

#Initializing Transaction Manager
trx = TransactionManager(sdk)
#Initializing Card Manager
cus = CustomerManager(sdk)


#Creating Customer With Unique Identification
customer = Customer()
customer.Company = "Sigma"
customer.Email = "customer@sigmaprocessing.net"
customer.Fax = "50712345678"
customer.FirstName = "John"
customer.LastName = "Snow"
customer.Phone = "50712345679"
customer.UniqueIdentifier = str(random.randrange(00000, 99999, 1))
customer.Website = "http://www.sigmaprocessing.net"
customer.CustomerId = "0"
#Adding Extra detail to Customer Model
customer.CustomFields = dict()
customer.CustomFields["Profession"] = "Software Developer"
#Adding Shipping Address to Customer Model
customer.ShippingAddress = list()
ShippingAddress = Address()
ShippingAddress.AddressId = "0"
ShippingAddress.AddressLine1 = "Collin Road"
ShippingAddress.AddressLine2 = "Suite XYZ"
ShippingAddress.City = "PA"
ShippingAddress.CountryName = "PA"
ShippingAddress.SubDivision = "XYZ"
ShippingAddress.State = "PA"
ShippingAddress.ZipCode = "123456"
customer.ShippingAddress.append(ShippingAddress)
#Adding Billing Address to Customer Model
customer.BillingAddress = list()
BillingAddress = Address()
BillingAddress.AddressId = "0"
BillingAddress.AddressLine1 = "Collin Road"
BillingAddress.AddressLine2 = "Suite XYZ"
BillingAddress.City = "PA"
BillingAddress.CountryName = "PA"
BillingAddress.SubDivision = "XYZ"
BillingAddress.State = "PA"
BillingAddress.ZipCode = "123456"
customer.BillingAddress.append(BillingAddress)
customerRe = cus.SaveCustomer(customer);

print("\r\n* Create Customer *")
if(customerRe.ResponseDetails.IsSuccess):
    print("New Customer added successfully")
else:
    print(customerRe.ResponseDetails.ResponseSummary)


#Adding Card to Customer Model
cc = CreditCard()
cc.CardholderName="John Snow"
cc.Status = "Active"
cc.ExpirationDate ="0128"
cc.ExpirationMonth = "01"
cc.ExpirationYear="28"
cc.Number="4111111111111111"
cc.CustomerId = customerRe.CustomerId
cardRe = cus.UpdateCard(cc);

print("\r\n* Adding Card to Customer *")
if(cardRe.ResponseDetails.IsSuccess):
    print("Card Added/Updatted successfully")

#Processing Sale Request
transRequest = Transaction()
transRequest.Amount = 1
transRequest.CustomerId = customerRe.CustomerId
transRequest.PaymentMethodToken = cardRe.Token.upper()
transRequest.TerminalId = "100177001"
transRequest.TransactOptions = TransactionOptions()
transRequest.TransactOptions.Operation = "Sale"
sale_response = trx.Sale(transRequest)

print("\r\n* Sale *")
print("Response: " + sale_response.ResponseDetails.ResponseSummary)
print("Authorization #: " + sale_response.ResponseDetails.AuthorizationNumber)

#Processing Reversal Request
transRequest = Transaction()
transRequest.Amount = 1
transRequest.TransactionId = sale_response.ResponseDetails.TransactionId
transRequest.TransactOptions = TransactionOptions()
transRequest.TransactOptions.Operation = "Refund"
transRequest.TerminalId = "100177001"
refund_response = trx.Refund(transRequest)

print("\r\n* Refund *")
print("Response: " + refund_response.ResponseDetails.ResponseSummary)
print("Authorization #: " + refund_response.ResponseDetails.AuthorizationNumber)

#Searching for Transaction Record by Filters
searchFilter = TransactionSearch()
searchFilter.Amount = AmountRangeFilter()
searchFilter.Amount.Between(1, 2)
searchFilter.DateCreated = DateRangeFilter()
searchFilter.DateCreated.Between("2015-09-22","2015-09-30")
transactionlst = trx.SearchTransaction(searchFilter)

print("\r\n* Transaction Search *")
print("Total "+ str(len(transactionlst)) + " transaction found matching search filters")

#Searching for Customer
customerFilters = CustomerSearch()
customerFilters.FirstName = TextFilter()
customerFilters.FirstName.StartsWith("John")
response_customers = cus.SearchCustomer(customerFilters)
print("\r\n* Searching Customer *")
print("Total "+ str(len(response_customers)) + " customer found matching search filters")

Todos

  • Define structure for recurring payments
  • Define structure for web hooks
  • Define structure to select and use a default payment method
  • Delete customers and payment methods
  • Define card validation, i.e. card has money and then void transaction
  • Define card owner validation, i.e.e card belongs to the customer by making token transaction and then validating.

License

MIT

Support

For details, improvements and requests please contact support@croeminc.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

croemincsdk-0.1.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CroemincSDK-0.1.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file croemincsdk-0.1.2.tar.gz.

File metadata

  • Download URL: croemincsdk-0.1.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for croemincsdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 83825f86a497e7dcfc70ed082610d61ed3aac7591f112da4a4d1e35dcbb74bf5
MD5 09d76a1b66d6812560b0f9dd9510ff38
BLAKE2b-256 c40048f8fa62e6f3a22a740d4ebe53c7de5a1d815f71460d68e0e7b39ba615d4

See more details on using hashes here.

File details

Details for the file CroemincSDK-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: CroemincSDK-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for CroemincSDK-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8fa848ab8cfad5cddc9b2e7f1e6056e4a83edf7fe0fe11b9825ebbee3c65b9ec
MD5 678b57cf2c534abc7922f93993e13b0b
BLAKE2b-256 78cf7478b03e40253bec818588e26e9512603534011e1add48c60c1ca9f4c2f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page