Managing Secupay Creditcards
A credit card is a payment card issued to users (cardholders) to enable the cardholder to pay a merchant for goods and services based on the cardholder's promise to the card issuer to pay them for the amounts so paid plus the other agreed charges. The card issuer (usually a bank) creates a revolving account and grants a line of credit to the cardholder, from which the cardholder can borrow money for payment to a merchant or as a cash advance . In other words, credit cards combine payment services with extensions of credit. See more
To Use credit cards transaction y our contract needs to be activated for this.
You can only cancel this payment transaction, no delete is possible. Update the payment transaction is very restricted only to some special fields.
Using the secuconnect API one can:
API uses following data structures:
Supported Actions
Create secupay creditcard transaction (paymentSecupaycreditcardsPost)
To create new SecupayTransactionProductModel when client uses creditcard, SecupayTransactionProductDTO need to be passed to PaymentSecupayCreditcardsApi :: paymentSecupaycreditcardsPost.
Example
// Build request object
$shippingItem
=
new
SecupayBasketItem();
$shippingItem
->setItemType(
'shipping'
)
->setName(
'standard delivery'
)
->setTax(
'19'
)
->setTotal(
'1324'
);
Here we create basket item of shipping type.
$articleItem
=
new
SecupayBasketItem();
$articleItem
->setItemType(
'article'
)
->setArticleNumber(
'3211'
)
->setQuantity(
'2'
)
->setName(
'Testname 1'
)
->setEan(
'4123412341243'
)
->setTax(
'19'
)
->setTotal(
'1324'
)
->setPrice(
'1000'
);
$articleItem2
=
new
SecupayBasketItem();
$articleItem2
->setItemType(
'article'
)
->setArticleNumber(
'48875'
)
->setQuantity(
'2'
)
->setName(
'Testname 2'
)
->setEan(
'4123412341236'
)
->setTax(
'19'
)
->setTotal(
'1324'
)
->setPrice(
'1000'
);
Here we create two basket items of article type.
//Please note that Basket is just ordinary array
$basket
= [];
$basket
[] =
$shippingItem
;
$basket
[] =
$articleItem
;
$basket
[] =
$articleItem2
;
Next we add items to basket. Please note that Basket is just ordinary array.
$transaction
=
new
SecupayTransactionProductDTO();
$transaction
->setAmount(
"100"
)
->setCurrency(
"EUR"
)
->setOrderId(
"ZZZZZZ"
)
->setAccrual(True)
->setCustomer(
'PCU_XYG3DHBX32MJ8DUFASAXVA4X4M3BA2'
)
->setBasket(
$basket
);
Finally we create SecupayTransactionProductDTO and fill fields we want.
// Make request
try
{
$api
=
new
PaymentSecupayCreditcardsApi();
$response
=
$api
->paymentSecupaycreditcardsPost(
$transaction
);
// Success. $response contain SecupayTransactionProductModel
}
catch
(\Secuconnect\Client\ApiException
$e
) {
//
print_r(
$e
->getResponseBody());
throw
$e
;
}
It's very straightforward code example. Most important is:
build request object to line 32 (of course it's just a simple example in real life it will look differently) - this request object contains information like: customer ID, amount, currency, order ID etc.
making a request to our API using PHP SDK on line 42 we create new object of PaymentSecupayCreditcardsApi and then sending the request using paymentSecupaycreditcardsPost method to create new credit card transaction
Response format
Success
If creation succeeded $response will contain instance of SecupayTransactionProductModel.
Error
If call failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductFormatException |
|
ProductNotAllowedException |
|
ProductDuplicateException |
|
Cancel secupay creditcard transaction
To cancel transaction it's ID is required. It will be returned as id property of SecupayTransactionProductModel after successful post call.
Example
$transactionId
= 'q...1;
// Make request
try
{
$api
=
new
PaymentSecupayCreditcardsApi();
// $transactionId contains id of previously created transaction
$response
=
$api
->paymentSecupaycreditcardsCancelById(
$transactionId
);
// Success. $response body contain only confirmation.
}
catch
(\Secuconnect\Client\ApiException
$e
) {
// Failure. $e->getResponseBody() contains ProductExceptionPayload
print_r(
$e
->getResponseBody());
throw
$e
;
}
To cancel a credit card transaction only thing we have to do is:
to fill transactionId that we want to cancel and then call paymentSecupaycreditcardsCancelById method of PaymentSecupayCreditcardsApi (line 8)
Response format
Success
On success API will return only confirmation.
Error
If call failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductNotAllowedException |
|
ProductNotFoundException |
|
ProductUpdateFailedException |
|
Get secupay creditcard transaction
Details of transaction can be retrieved by it's id.
Example
$transactionId
=
'q...1'
;
// Make request
try
{
$api
=
new
PaymentSecupayCreditcardsApi();
// $transactionId contains id of existing transaction
$response
=
$api
->paymentSecupaycreditcardsGetById(
$transactionId
);
// Success. $response contain SecupayTransactionDTO
}
catch
(\Secuconnect\Client\ApiException
$e
) {
// Failure. $e->getResponseBody() contains ProductExceptionPayload
print_r(
$e
->getResponseBody());
throw
$e
;
}
To get a credit card transaction only thing we have to do is:
to fill transactionId that we want to get and then call paymentSecupaycreditcardsGetById method of PaymentSecupayCreditcardsApi (line 8)
Response format
Success
On success API will return SecupayTransactionProductModel filled in with details of transaction.
Error
If call failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductNotFoundException |
|
ProductNotAllowedException |
|
ProductFormatException |
|