HostedPaymentPageTransactionAPI Class

Global API Apex class for Salesforce Billing. Contains methods that customers can call to save a credit card with tokenization or make a transaction using a new credit card.

Namespace 

blng

Usage 

The HostedPaymentPageTransactionAPI class contains the chargeTransaction method, which allows users to make a transaction using a new credit card, and the savePaymentMethod method, which allows users to save a credit card with tokenization.

Inputs 

NameTypeDescriptionRequired or OptionalAvailable Version
addressLine1StringFirst line in the address of the user making the payment.Optional48.0
addressLine2StringSecond line in the address of the user making the payment.Optional48.0
cityStringCityOptional48.0
countryStringCountryOptional48.0
postalCodeStringPostal codeOptional48.0
stateStringStateOptional48.0
NameTypeDescriptionRequired or OptionalAvailable Version
cardHolderNameStringFull name of the card holder.Required48.0
cardNumberStringNumber of the credit card.Required48.0
cardTypeStringCard network type. Valid values are:
  • AmericanExpress
  • Discover
  • MasterCard
  • Visa
Required48.0
cvvStringCVVRequired48.0
expiryMonthIntegerCard expiration month.Required48.0
expiryYearIntegerCard expiration year.Required48.0
NameTypeDescriptionRequired or OptionalAvailable Version
addressStringAddress of the payment method holder.Required48.0
autopayBooleanDefines whether Salesforce Billing saves a record of the payment method to the customer’s account for use in future payment runs. One account can have only one payment method with autopay enabled.Optional48.0
emailStringEmail of the payment method holder.Optional48.0
firstNameStringFirst name of the payment method holder.Required48.0
lastNameStringLast name of the payment method holder.Required48.0
cardPaymentMethodcardPaymentMethodCard details for the payment method.Required48.0
paymentTypeStringType of payment method. Valid values are:
  • Credit Card
Required48.0
saveForFutureBooleanIndicates whether Salesforce saves a record of the payment method for future use.Optional48.0

HostedPaymentPageTransactionAPI Methods 

The following are methods for HostedPaymentPageTransactionAPI.

chargeTransaction(chargeRequest) 

Use this method to charge the desired amount from the buyer’s card.

Signature 

global static String chargeTransaction(String chargeRequest)

Parameters 

chargeRequest: Type: String Represents a charge request made to the payment gateway.

Return Value 

Type: String

Represents a charge transaction response.

Example 

Example format for a charge request input.

1{
2    "accountId": "0018A00000QcPDpQAN",
3    "gatewayId": "a1x8A000000OZG2",
4    "amount": 10,
5    "paymentMethod": {
6        "firstName": "Muneer Ahmed",
7        "lastName": "Shaik",
8        "email": "mas@sf.com",
9        "saveForFuture": true,
10        "autoPay": true,
11        "paymentType": "Credit Card",
12        "address": {
13            "addressLine1": "Address 1",
14            "addressLine2": "Address 2",
15            "city": "SF",
16            "state": "CA",
17            "country": "United States",
18            "postalCode": "41111"
19        },
20        "cardPaymentMethod": {
21            "cardHolderName": "Muneer Ahmed Shaik",
22            "cardType": "Visa",
23            "cardNumber": "4111111111111111",
24            "cvv": "111",
25            "expiryMonth": "2",
26            "expiryYear": "2021"
27        }
28    }    
29  }

savePaymentMethod(paymentMethodRequest) 

Use this method to save a payment method. Currently supports saving only credit cards.

Signature 

global static String savePaymentMethod(String paymentMethodRequest)

Parameters 

paymentMethodRequest: Type: String Represents a request to save a payment method.

Return Value 

Type: String

Represents a save payment method response.

Example 

Example format for a save payment method request input.

1{
2    "accountId": "0018A00000QcPDpQAN",
3    "gatewayId": "a1x8A000000OZG2",
4    "paymentMethod": {
5        "firstName": "Muneer Ahmed",
6        "lastName": "Shaik",
7        "email": "mas@sf.com",
8        "paymentType": "Credit Card",
9        "address": {
10            "addressLine1": "Address 1",
11            "addressLine2": "Address 2",
12            "city": "SF",
13            "state": "CA",
14            "country": "United States",
15            "postalCode": "41111"
16        },
17        "cardPaymentMethod": {
18            "cardHolderName": "Muneer Ahmed Shaik",
19            "cardType": "Visa",
20            "cardNumber": "4111111111111111",
21            "cvv": "111",
22            "expiryMonth": "2",
23            "expiryYear": "2021"
24        }
25    }
26  }