Saving a Transaction Id ( transactionId
) or Vault Id ( vaultId
) allows you to re-charge or refund an account at a later time without actually storing the account number.
There's two ways to "save a card" for future use with the PayJunction REST API.
- Charge an account and store the
transactionId
for future billing. - Create a Customer and save the account information in a Vault without charging the customer. Then, use the
vaultId
for future billing.
Charge an account and save the Transaction ID
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "action=CHARGE" \ -d "cardNumber=4444333322221111" \ -d "cardExpMonth=01" \ -d "cardExpYear=2020" \ -d "amountBase=1.00" \ "https://api.payjunction.com/transactions"
Response
{ "transactionId": 22953, "uri": "https://api.payjunction.com/transactions/22953", "terminalId": 1, "action": "CHARGE", "amountBase": "3.00", "amountTotal": "3.00", "status": "CAPTURE", "created": "2014-01-22T21:38:25Z", "lastModified": "2014-01-22T21:38:25Z", "response": { "approved": true, "code": "00", "message": "Approved", "processor": { "authorized": true, "approvalCode": "PJ20AP", "avs": { "status": "NOT_REQUESTED" }, "cvv": { "status": "NOT_REQUESTED" } } }, "settlement": { "settled": false }, "vault": { "type": "CARD", "accountType": "VISA", "lastFour": "1111" } }
Confirm that the transaction was approved, then save the transactionId
for future billing.
Re-billing the Account by Transaction ID
If you want to REFUND
or CHARGE
an account at a later time, then simply send the transactionId
, amount and action. If you only send the transactionId
, then the amount and action from the original transaction will be used.
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "action=CHARGE" \ -d "transactionId=22953" \ -d "amountBase=2.00" \ "https://api.payjunction.com/transactions"
Response
{ "transactionId": 22954, "uri": "https://api.payjunction.com/transactions/22954", "terminalId": 1, "action": "CHARGE", "amountBase": "3.00", "amountTotal": "3.00", "status": "CAPTURE", "created": "2014-01-22T21:38:25Z", "lastModified": "2014-01-22T21:38:25Z", "response": { "approved": true, "code": "00", "message": "Approved", "processor": { "authorized": true, "approvalCode": "PJ20AP", "avs": { "status": "NOT_REQUESTED" }, "cvv": { "status": "NOT_REQUESTED" } } }, "settlement": { "settled": false }, "vault": { "type": "CARD", "accountType": "VISA", "lastFour": "1111" } }
There is no need to update your system with the new transactionId
. Simply verify that the transaction was approved.
Creating a Vault Id. This Does Not Charge the Account.
Step 1: Add a customer.
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "firstName=John" \ -d "lastName=Smith" \ "https://api.payjunction.com/customers"
Response
{ "customerId": 2969, "uri": "https://api.payjunction.com/customers/2969", "firstName": "John", "lastName": "Smith", "created": "2014-01-22T22:34:47Z", "lastModified": "2014-01-22T22:34:47Z" }
Step 2: Create a Vault for the customer.
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "cardNumber=4444333322221111" \ -d "cardExpMonth=01" \ -d "cardExpYear=2020" \ "https://api.payjunction.com/customers/2969/vaults"
Response for CARD vault
{ "vaultId": 2078, "uri": "https://api.payjunction.com/customers/2969/vaults/2078", "type": "CARD", "accountType": "VISA", "lastFour": "1111", "cardExpMonth": 5, "cardExpYear": 2020, "created": "2014-01-22T22:36:27Z", "lastModified": "2014-01-22T22:36:27Z" }
Response for ACH vault
{ "vaultId": 2079, "uri": "https://api.payjunctionlabs.com/customers/2969/vaults/2079", "type": "ACH", "accountType": "CHECKING", "lastFour": "6789", "achRoutingNumber": "121000358", "achType": "PPD", "created": "2014-01-22T22:38:05Z", "lastModified": "2014-01-22T22:38:05Z" }
Last, store the vaultId
for future billing.
Recharge or Refund via Vault Id
If you want to re-bill the account ( CHARGE or REFUND ) at a later time, simply send the vaultId
, amount and action. You will always need to specify the baseAmount and action when re-billing by vaultId
.
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "action=CHARGE" \ -d "vaultId=14833" \ -d "amountBase=2.00" \ "https://api.payjunction.com/transactions"
Response
{ "transactionId": 22959, "uri": "https://api.payjunction.com/transactions/22959", "terminalId": 1, "action": "CHARGE", "amountBase": "1.00", "amountTotal": "1.00", "status": "CAPTURE", "created": "2014-01-22T22:39:38Z", "lastModified": "2014-01-22T22:39:38Z", "response": { "approved": true, "code": "00", "message": "Approved", "processor": { "authorized": true, "approvalCode": "PJ20AP", "avs": { "status": "NOT_REQUESTED" }, "cvv": { "status": "NOT_REQUESTED" } } }, "settlement": { "settled": false }, "vault": { "type": "CARD", "accountType": "VISA", "lastFour": "1111" }, "billing": { "firstName": "John", "lastName": "Smith" } }
The vaultId
will remain the same so there is no need to update the vaultId
.
Updating an Existing Vault
There may be cases where you want to update an existing Vault. For example, updating the billing address, or updating the expiration date of the card.
Production Request
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \ -d "cardExpMonth=11" \ -d "cardExpYear=2045" \ "https://api.payjunction.com/customers/2969/vaults/2078"
Response
{ "vaultId": 2078, "uri": "https://api.payjunctionlabs.com/customers/2969/vaults/2078", "type": "CARD", "accountType": "VISA", "lastFour": "1111", "cardExpMonth": 11, "cardExpYear": 2045, "created": "2014-01-22T22:36:27Z", "lastModified": "2014-01-22T22:36:27Z" }
The vaultId
will remain the same.