Migrated from Redmine #1229 | Author: Anonymous
Status: Feedback | Priority: High, I’m very impatient | Created: 2024-05-07
Hey,
We are building custom payment processor(Vipps), on response from our payment gateway I have to update order status based on payment capture status. I am calling sbpay approve api as per documentation it throws error Invalid timestamp.
I am passing sbpay timestamp comes after calling custom payment processor.
Message:
{“message”:“Validation error”,“data”:{“errors”:[{“path”:“timestamp”,“error”:“Invalid timestamp”}]}}
Timestamp:
$data = array(
‘algo’ => ‘sha256’,
‘id’ => 1832,
‘paymentMethod’ => ‘Custom’,
‘transactionId’ => ‘’,
‘reason’ => ‘Custom’,
‘zeroAmount’ => true,
‘timestamp’ => ‘2024-05-06T00:00:00+00:00’
);
// Set headers
$headers = array(
‘X-Merchant: oncallfysioterapi’,
‘X-Auth-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’,
‘X-Signature: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’,
‘Content-Type: application/json’
);
Dmytro Bondarev wrote:
Hi, you should pass correct current timestamp (including time).
If difference is too big it will be invaid.
Anonymous wrote:
We tried got this error: order id is 1833
Created date/time:
May 6, 2024 8:25 PM
$data = array(
‘algo’ => ‘sha256’,
‘id’ => 1833,
‘paymentMethod’ => ‘custom’,
‘transactionId’ => ‘’,
‘reason’ => ‘custom’,
‘zeroAmount’ => true,
‘timestamp’ => ‘2024-05-06T20:26:00+00:00’
);
‘timestamp’ => ‘2024-05-06T20:26:00+00:00’
it’s only 1min’
Can you send an example of a working timestamp?
Dmytro Bondarev wrote:
You are passing+00:00. Are you sure you are in GTM timezone?
Please just make sure that you are passing current timestamp. The format is correct.
Anonymous wrote:
Hey Dmytro,
Thanks for the quick reply
We are a company based in norway so should we user the norwigian UTC/GMT +2 hours.
or is there something else we should add and is it possible to give us the correct GMT?
Heres our result testing + 2:
‘timestamp’ => ‘2024-05-06T23:26:00+02:00’
Anonymous wrote:
Another question is do you know where is the order_id?
Anonymous wrote:
Order_id: Screenshot by Lightshot
Anonymous wrote:
Will transaction status will update from pending to received if i use approved API?
Anonymous wrote:
Can you please check this code and if possible can you send the correct code?:
<?php
$order_id = 1833;
$signature = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// set approved in sbpay
$data = array(
'algo' => 'sha256',
'id' => $order_id,
'paymentMethod' => 'custom',
'transactionId' => '',
'reason' => 'custom',
'zeroAmount' => true,
'timestamp' => '2024-05-06T23:26:00+02:00'
);
// Set headers
$headers = array(
'X-Merchant: oncallfysioterapi',
'X-Auth-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'X-Signature: '. $signature,
'Content-Type: application/json'
);
// Initialize cURL session
$approve_url = "https://app.sbpay.me/api/order/".$order_id."/approve";
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $approve_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
// Check for errors
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
// Print response
echo $response;
}
?>
system
May 7, 2024, 11:16am
10
Dmytro Bondarev wrote:
Hi, order_id will come to your server on init payment. (it is not a reference id).
Code looks correct, however you can use SDK , it could be easier: sbpay/sdk - Packagist.org
system
May 7, 2024, 11:25am
11
Anonymous wrote:
Thanks for the clarification another question is.
I have 2 questions
Is it possible for you to send the correct timestamp gmt?
Will transaction status update from pending to received if we use approved API?
Screenshot by Lightshot
Is it possible to add a Vipps logo for the custom payment prossesorcheckout page?
system
May 7, 2024, 11:39am
13
Anonymous wrote:
Ok thank you so much for the quick and concise reply.
On question 3 how does the custom ccs for adding the logo look?
Again,
Thank you so much for your help.
system
May 7, 2024, 12:03pm
14
Dmytro Bondarev wrote:
It depends on your theme.
Something like this:
#sb_invoice_payment_systems_container > div.payment-system.v2.payment-system-custom > div.img {
background-image: url(....your image url....);
width: 100px;
height: 100px;
}
#sb_invoice_payment_systems_container > div.payment-system.v2.payment-system-custom > div.img img {
display: none;
}
system
May 7, 2024, 12:33pm
15
Anonymous wrote:
Hey again we are having problems with adding paymentMethod field in sbpay:
[id] => 1191
[merchantReferenceId] => 1814
[transactionId] =>
[paymentSystemReferenceId] =>
[description] =>
[paymentSystem] => custom
[paymentMethod] =>
[currency] => NOK
[amount] => 1.25
[amountInBaseCurrency] =>
[currencyRate] =>
[createdDateTime] => 2024-05-05T02:13:03+00:00
[lastChangeDateTime] => 2024-05-07T12:09:45+00:00
[status] => pending
[type] => online
[paymentRefundedByPaymentSystem] =>
[paymentConfirmedManually] =>
Question is how do we add paymentMethod in sbpay?
system
May 7, 2024, 12:37pm
16
Dmytro Bondarev wrote:
Please explain what do you mean?
system
May 7, 2024, 12:39pm
17
Anonymous wrote:
We do not know where/how to add (paymentMethod) in sbpay? hopefully that clarifies it: