Managing Secupay Invoices
invoice billing
Invoice billing is a → payment method. The goods are delivered against an invoice to be paid later. This means more risk and should only be provided to trusted buyers.
Invoice billing must not be mixed up with the invoice itself.
So this payment is a forms of trade credit which specify that the net amount (the total outstanding on the invoice) is expected to be paid in full and received by the seller within 10 days after the goods are dispatched or service is completed so the payer can transfer the money after he has received the product or the service.
To use this payment method your contract needs to be activated for this payment method.
Using the secuconnect API one can:
API uses following data structures:
Supported Actions
Create secupay invoices transaction (paymentSecupayinvoicesPost)
To create new SecupayTransactionProductModel when client uses invoice, SecupayTransactionProductDTO need to be passed to PaymentSecupayInvoicesApi :: paymentSecupayinvoicesPost.
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
PaymentSecupayInvoicesApi();
$response
=
$api
->paymentSecupayinvoicesPost(
$transaction
);
// Success. $response contain SecupayTransactionProductModel
}
catch
(\Secuconnect\Client\ApiException
$e
) {
//
print_r(
$e
->getResponseBody());
throw
$e
;
}
We are making request to our API using PHP SDK on line 42 we create new object of PaymentSecupayInvoicesApi and then sending the request using paymentSecupayinvoicesPost method to create new invoices transaction
Response format
Success
On success API will return SecupayTransactionProductModel filled in with details of transaction.
Error
If cancelation failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductFormatException |
|
ProductNotAllowedException |
|
ProductDuplicateException |
|
Cancel secupay invoices transaction
To cancel transaction it's ID is required. It will be returned as id property of SecupayTransactionProductModel after successful post call.
Example
$transactionId
= 's...2;
// Make request
try
{
$api
=
new
PaymentSecupayInvoicesApi();
// $transactionId contains id of previously created transaction
$response
=
$api
->paymentSecupayinvoicesCancelById(
$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 invoices transaction only thing we have to do is:
to fill transactionId that we want to cancel and then call paymentSecupayinvoicesCancelById method of PaymentSecupayInvoicesApi (line 8)
Response format
Success
On success API will return only confirmation.
Error
If cancelation failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductNotAllowedException |
|
ProductNotFoundException |
|
ProductUpdateFailedException |
|
Get secupay invoices transaction
Details of transaction can be retrieved by it's id.
Example
$transactionId
= 's...2;
// Make request
try
{
$api
=
new
PaymentSecupayInvoicesApi();
// $transactionId contains id of existing transaction
$response
=
$api
->paymentSecupayinvoicesGetById(
$transactionId
);
// Success. $response contain SecupayTransactionDTO
}
catch
(\Secuconnect\Client\ApiException
$e
) {
// Failure. $e->getResponseBody() contains ProductExceptionPayload
print_r(
$e
->getResponseBody());
throw
$e
;
}
To get a invoices transaction only thing we have to do is:
to fill transactionId that we want to get and then call paymentSecupayinvoicesGetById method of PaymentSecupayInvoicesApi (line 8)
Response format
Success
On success API will return SecupayTransactionDTO filled in with details of transaction.
Error
If cancelation failed, $e→getResponseBody will contain ProductExceptionPayload with following possible errors:
Error |
Possible reasons |
ProductNotFoundException |
|
ProductNotAllowedException |
|
ProductFormatException |
|