Creating Charges
This section assumes you've already implemented a solution for collecting and tokenizing your customers' cards. If you haven't, see Collecting Card Details before proceeding.
GetzPay.js and your payment form alone do not create a charge. Combined, GetzPay.js and the HTML form fulfill the first half of the payment process, but server-side code is also necessary to complete the workflow.
Once the token has been successfully created with either GetzPay.js or mobile SDK, it must be submitted to your server where the card can be charged.
- After tokenization, the payment form should have a hidden field with the token ID, at which point the form should be submitted using JavaScript (as a reminder, the form's submission was prevented earlier so the script could wait for GetzPay to tokenize the card details).
- All of the form's data will be sent as a POST request to the URL in the form's action. If you have other form elements, such as the user's email address, that will be submitted as usual.
After you've securely collected and tokenized your customer's card details using GetzPay.js or mobile SDK, you can charge the card.
- Unlike collection, which occurs in the browser, charge attempts are made from your server, normally using our client library.
- On your server, grab the GetzPay token in the POST parameters submitted by your form. From there, it's one simple API call to charge the card:
Be sure to use your Secret API key instead of your Public API key here.
That's it! If the charge creation request succeeds, the card has been successfully charged.
Test Card Numbers
These test card numbers work only in development (test) mode.
- If no expiry date is provided, you can use any date after today's date
- If the CVN/CVV is required and not provided, you can use any 3-digit combination
Card Brand | Bank | Number |
---|---|---|
MasterCard | UOB | 5123 4500 0000 0008 |
MasterCard | UOB | 2223 0000 0000 0007 |
MasterCard | UOB | 5123 4567 8901 2346 |
Visa | UOB | 4440 0000 0990 0010 |
Visa | UOB | 4440 0000 4220 0014 |
Testing - Simulating Failed Charges
In Development mode, you can use these magic amounts to simulate failure responses when you create a charge. Enter in one of the amounts listed here as the amount to be charged.
FAILURE REASON | DEFINITION | MAGIC AMOUNT |
---|---|---|
EXPIRED_CARD | The card you are trying to capture is expired. | 10051 |
CARD_DECLINED | The card you are trying to capture has been declined by the issuing bank. | 10052 |
PROCESSOR_ERROR | The charge failed because there's an integration issue between the card processor and the bank. | 10053 |
INSUFFICIENT_BALANCE | The card you are trying to capture does not have enough balance to complete the capture. | 10054 |
STOLEN_CARD | The card you are trying to capture has been marked as stolen. | 10055 |
INACTIVE_CARD | The card you are trying to capture is inactive. | 10056 |
TEMPORARY_SYSTEM_ERROR | There is a temporary system error when the charge attempt happens. | 10057 |
CAPTURE_AMOUNT_LIMIT_ERROR | The amount capture is either below the minimum limit or above the maximum limit. | 10058 |
Next Steps
Check out our other : Refunds