Contains functionality for use with Salesforce Payments. See Salesforce Payments documentation for how to
gain access and configure it for use on your sites.
Attaches the given payment method to the given customer. Use this method to attach a payment method of type
SalesforcePaymentMethod.TYPE_CARD to a shopper who registers as a customer after placing an order, and
has affirmatively elected to save their card as part of the registration process. This method will throw an error
if passed incompatible payment method and/or customer objects.
paymentIntentProperties
-
additional properties to pass to the create Payment Intent API
Returns:
Status 'OK' or 'ERROR'. Status detail 'paymentintent' contains the payment intent, if it is available in the Stripe response. Status detail 'error' contains the Stripe error information, if it is available in the response.
The payment intent must be in a status that supports capture. See the Stripe documentation for more details.
If amount is not specified, the default is the full amount available to capture. If specified, the
amount must be less than or equal to the amount available to capture.
Parameters:
paymentIntent
-
payment intent to capture
amount
-
optional amount to capture, defaults to amount available to capture
Returns:
Status 'OK' or 'ERROR'. Status detail 'error' contains the Stripe error information, if it is available in the response.
Throws:
Exception
-
if there was an error capturing the payment intent
Confirms a new payment intent using the given payment method, and associates it with the given order.
The order must be prepared to contain products, shipments, and any other necessary data, and must be calculated
to reflect the correct total amounts. If the order is not for the same Customer as the given
payment method, an error is thrown.
The specified payment method must be set up for off session future use or an error is thrown. iDeal and
Bancontact implement reuse differently than other payment methods, but they can't be reused themselves.
The following Payment Intent properties are supported:
cardCaptureAutomatic - optional true if the credit card payment should be
automatically captured at the time of the sale, or false if the credit card payment should be
captured later
If cardCaptureAutomatic is provided it is used to determine card capture timing, and otherwise the
default card capture timing set for the site is used.
If statementDescriptor is provided it is used as the complete description that appears on your
customers' statements for the payment, and if not a default statement descriptor is used. If a default statement
descriptor is set for the site it is used as the default, and otherwise the default statement descriptor for the
account will apply.
Parameters:
order
-
order to pay using Salesforce Payments
paymentMethod
-
payment method to use to pay
paymentIntentProperties
-
additional properties to pass to the create Payment Intent API
Returns:
Status 'OK' or 'ERROR'. Status detail 'paymentintent' contains the payment intent, if it is available in the Stripe response. Status detail 'error' contains the Stripe error information, if it is available in the response.
Throws:
Exception
-
if the parameter validation failed or there's an error confirming the payment intent
cardCaptureAutomatic - optional true if the credit card payment should be
automatically captured at the time of the sale, or false if the credit card payment should be
captured later
The stripeCustomerRequired must be set to true if the payment will be set up for future
usage, whether on session or off session. If true then if a Stripe Customer is associated with the
shopper then it will be used, and otherwise a new Stripe Customer will be created. The new Stripe Customer will
be associated with the shopper if logged into a registered customer account for the site.
If cardCaptureAutomatic is provided it is used to determine card capture timing, and otherwise the
default card capture timing set for the site is used.
If statementDescriptor is provided it is used as the complete description that appears on your
customers' statements for the payment, and if not a default statement descriptor is used. If a default statement
descriptor is set for the site it is used as the default, and otherwise the default statement descriptor for the
account will apply.
Parameters:
basket
-
basket to checkout and pay using Salesforce Payments
shipment
-
shipment to use for shipping information in the payment intent
zoneId
-
id of the payment zone
amount
-
payment amount
stripeCustomerRequired
-
true if a Stripe Customer must be associated with the payment intent, and would be created if it doesn't already exist, or false if a Stripe Customer does not have to be associated with the payment intent
paymentIntentProperties
-
properties to pass to the create Payment Intent API
Returns:
Status 'OK' or 'ERROR'. Status detail 'paymentintent' contains the payment intent, if it is available in the Stripe response. Status detail 'error' contains the Stripe error information, if it is available in the response.
Detaches the given payment method from its associated customer. Once detached the payment method remains
associated with payment intents in the payment account, but is no longer saved for use by the customer in future
orders.
Returns a collection containing the payment methods attached to the given customer. The collection will be empty
if there are no payment methods attached to the customer, or there was an error retrieving the attached payment
methods.
Returns a collection containing the payment methods for the given customer set up for future off session reuse.
The collection will be empty if there are no off session payment methods for the customer, or there was an
error retrieving the off session payment methods.
Parameters:
customer
-
customer whose off session payment methods to get
Returns:
collection of off session payment methods
Throws:
Exception
-
if the given customer is null or undefined, or there is an error getting the off session payment methods
Returns a collection containing the payment methods saved to be presented to the given customer for reuse in
checkouts. The collection will be empty if there are no payment methods saved for the customer, or there was an
error retrieving the saved payment methods.
Parameters:
customer
-
customer whose saved payment methods to get
Returns:
collection of saved payment methods
Throws:
Exception
-
if the given customer is null or undefined, or there is an error getting the saved payment methods
Handles the account registration of the shopper who placed the given order. Use this method to ensure the
registered customer profile is associated with the order in Salesforce Payments.
Parameters:
order
-
order paid using Salesforce Payments
Throws:
Exception
-
if there was an error attaching the payment method to the customer
Refunds previously captured funds for the given payment intent.
The payment intent must be in a state that supports refund. This includes its status as well as any previous
refunds. See the Stripe documentation for more details.
The following Payment Intent property is supported:
reason - optional payment intent refund reason
If amount is not specified, the default is the full amount available to refund. If specified, the
amount must be less than or equal to the amount available to refund.
Parameters:
paymentIntent
-
payment intent to refund
amount
-
optional amount to refund, defaults to amount previously captured
refundProperties
-
additional properties to pass to the refund API
Returns:
Status 'OK' or 'ERROR'. Status detail 'error' contains the Stripe error information, if it is available in the response.
Removes the given saved payment method so that it is no longer presented to the given customer for reuse in
checkouts. The payment method remains in the payment account, but is no longer saved for use by the customer.
Parameters:
paymentMethod
-
payment method to detach from customer
Throws:
Exception
-
if there was an error removing the saved payment method from its customer
Saves the given payment method to be presented to the given customer for reuse in subsequent checkouts. This
method will throw an error if passed incompatible payment method and/or customer objects.
Parameters:
customer
-
customer for which to save the payment method
paymentMethod
-
payment method to save for the customer
Throws:
Exception
-
if there was an error saving the payment method for the customer
cardCaptureAutomatic - optional true if the credit card payment should be
automatically captured at the time of the sale, or false if the credit card payment should be
captured later
If cardCaptureAutomatic is provided it is used to determine card capture timing, and otherwise the
default card capture timing set for the site is used.
If statementDescriptor is provided it is used as the complete description that appears on your
customers' statements for the payment, and if not a default statement descriptor is used. If a default statement
descriptor is set for the site it is used as the default, and otherwise the default statement descriptor for the
account will apply.
Parameters:
paymentIntent
-
payment intent to update
shipment
-
optional shipment to use to update shipping information in the payment intent
amount
-
optional new payment amount
orderNo
-
optional order no of Order to associate with the payment intent in metadata
paymentIntentProperties
-
optional additional properties to pass to the update Payment Intent API
Returns:
Status 'OK' or 'ERROR'. Status detail 'paymentintent' contains the payment intent, if it is available in the Stripe response. Status detail 'error' contains the Stripe error information, if it is available in the response.
Throws:
Exception
-
if the parameter validation failed or there's an error updating the payment intent