Developer
Updated 2 days ago
Payment Center works perfectly within Salesforce as far as invoicing and collecting payments are concerned. But what if you have on your website a shopping cart and you want to charge your customers right there? Shopping carts normally have their standard integration with the different payment processors, and they work great except that they don’t normally have integration with Salesforce, leaving you with disconnected systems. That’s when the Payment Center API becomes handy. Instead of submitting the payment directly to your processor, you submit the payment to Payment Center and it will take care of processing the payment (through your processor) and recording the payment within Salesforce.
Before calling any API, you need to authenticate to get an access token. You use the access token to call the API. As part of authentication, you need a Client ID and a Client Secret. Please email support@kulturra.com to get those values. Below is an example of an authentication using the Username-Password flow:
curl -k https://<instance>.salesforce.com/services/oauth2/token \
--form client_id=<client ID> \
--form client_secret=<client secret> \
--form grant_type=password \
--form username=<username> \
--form password=<password><security token>
EXAMPLE REQUEST
curl -k https://na14.salesforce.com/services/oauth2/token \
--form client_id=3MVxxxZ.WNe6byQDxxxxKq5v.BvHAXxxTaCaP38yLxxPWxxxPbTlxxx6DqF_aIR5uo.gYxxxFmL9BXXxTOsL8 \
--form client_secret=3999599995229995998 \
--form grant_type=password \
--form username=apitest@kulturra.com \
--form password=apitestpwd999AXXhxXXx3Bq85rGSXXX9X9jN
EXAMPLE RESPONSE
{"id":"https://login.salesforce.com/id/00Dx0000000eqdXXXQ/005x0000000TqOcXXK",
"issued_at":"1419239900426",
"token_type":"Bearer",
"instance_url":"https://na14.salesforce.com",
"signature":"PxxR7F1XXXXE35z8jy9IoxXXXy/f4KxxxjE5LBqY+OY=",
"access_token":"00Dx0000000exxV!AXXXXXfcKqHB0czbxxxxxHkyo9gt41BxxxhWPxxZzaXxXxbAJxx9Ov4Hno..mu1Xi5XXXX8MWHVD81JVr6ShxxxxxorGv6Uy"}
The access token returned by the above request can then be used on succeeding API calls.
As its name suggest, this API submits payment to your processor. It also creates the corresponding payment record in Salesforce. You submit payment in the following form:
curl -v https://<instance>.salesforce.com/services/apexrest/fw1/v1/payments \
-H 'Authorization: Bearer <access token>' \
-H 'Content-Type: application/json' \
-X POST \
-d '{<arguments>}'
EXAMPLE REQUEST
curl -v https://na14.salesforce.com/services/apexrest/fw1/v1/payments \
-H 'Authorization: Bearer 00Dx0000000exxV!AXXXXXfcKqHB0czbxxxxxHkyo9gt41BxxxhWPxxZzaXxXxbAJxx9Ov4Hno..mu1Xi5XXXX8MWHVD81JVr6ShxxxxxorGv6Uy' \
-H 'Content-Type: application/json' \
-X POST \
-d '{"amount":9.99,
"credit_card_number":"4111111111111111",
"expiry_month":"08",
"expiry_year":"2018",
"first_name":"Jeff",
"last_name":"Johnson",
"billing_street":"12345 Jefferson St.",
"billing_city":"Torrance",
"billing_state":"CA",
"billing_zip":"90501",
"billing_country":"US"}'
EXAMPLE RESPONSE
{"Type":"Charge",
"Status":"Captured",
"Salesforce_Payment_ID":"a0Ad000000MXxZxXXL",
"Processor_Transaction_ID":"2219157406",
"Processor":"Authorize.Net",
"Payment_Date":"2014-09-09T04:20:23.563Z",
"Message":"This transaction has been approved.",
"IsSuccessful":true,
"CVV2_Match":null,
"AVS_Code":null,
"Amount_Currency":"USD",
"Amount":9.99}
IsSuccessful indicates whether or not the payment was successful. If payment was not successful, the corresponding error message will be listed in Message. If payment was successful, Salesforce_Payment_ID will contain the ID of the payment record created in Salesforce.
COMPLETE LIST OF ARGUMENTS
amount – required, a positive decimal number, i.e. 9.99
credit_card_number – required
expiry_month – required, 2-digit month, i.e. 01 for January
expiry_year – required, 4-digit year
first_name – required, first name as it appears on the card
last_name – required, last name as it appears on the card
billing_street – required, billing street associated with the card
billing_city – required, billing city associated with the card
billing_state – required, billing state associated with the card. This is not required for non-US addresses
billing_zip – required, billing zip associated with the card
billing_country – required, billing country associated with the card
trans_type – optional, values could be Charge or Authorization. If not sent, the default value from settings will be used
processor – optional, name of your processor as defined in your settings. If not sent, the default will be used.
payment_name – optional, any name to identify your payment. If not sent, a name will be created for you.
reference – optional, any reference related to your payment, i.e. order number, invoice number, etc.
amount_currency – optional, 3-letter ISO code for currency, i.e USD, EUR, etc. If not sent, the default value from settings will be used
shipping_street – optional, customer shipping street
shipping_city – optional, customer shipping city
shipping_state – optional, customer shipping state
shipping_zip – optional, customer shipping zip
shipping_country – optional, customer shipping country
email – optional, customer email address. This is required if your processor is CyberSource
This feature is available in the September 2014 release of Payment Center.