Skip to content

Instantly share code, notes, and snippets.

@johndstein
Created May 24, 2018 14:46
Show Gist options
  • Save johndstein/71432e207c4017e0bd8883b75dd4151c to your computer and use it in GitHub Desktop.
Save johndstein/71432e207c4017e0bd8883b75dd4151c to your computer and use it in GitHub Desktop.
example
AuthorizeNetService ans = new AuthorizeNetService('**', '**', true);
AuthorizeNetModels.creditCardType creditCard = new AuthorizeNetModels.creditCardType();
creditCard.cardCode = '999';
creditCard.cardNumber = '5424000000000015';
creditCard.expirationDate = '2020-05';
AuthorizeNetModels.paymentType payment = new AuthorizeNetModels.paymentType();
payment.creditCard = creditCard;
List<AuthorizeNetModels.lineItemType> lineItems = new List<AuthorizeNetModels.lineItemType>();
AuthorizeNetModels.lineItemType lineItem = new AuthorizeNetModels.lineItemType();
lineItem.itemId = 'itemid';
lineItem.name = 'name';
lineItem.description = 'desc';
lineItem.quantity = 11;
lineItem.unitPrice = 10.00;
lineItems.add(lineItem);
AuthorizeNetModels.customerType customer = new AuthorizeNetModels.customerType();
customer.id = 'cust-10101';
AuthorizeNetModels.addressType address = new AuthorizeNetModels.addressType();
address.firstName = 'first';
address.lastName = 'last';
address.company = 'co';
address.address = 'adr';
address.city = 'cit';
address.state = 'st';
address.zip = 'zzzzz';
address.country = '12cccccc3';
AuthorizeNetModels.transactionRequestType tr = new AuthorizeNetModels.transactionRequestType();
tr.transactionType = 'authCaptureTransaction';
tr.amount = 10.00;
tr.payment = payment;
tr.lineItems = lineItems;
tr.poNumber = 'po 11';
tr.customer = customer;
tr.billTo = address;
tr.shipTo = address;
tr.customerIP = '12.12.12.12';
System.debug(tr.toXML());
AuthorizeNetModels.createTransactionResponse response = ans.createTransaction(tr, '123');
System.debug('XXXXXX' + response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment