[#1231] How can I add paymentMethod in custom payment(vipps)

Migrated from Redmine #1231 | Author: Anonymous
Status: Feedback | Priority: Immediate, there is BUG! | Created: 2024-05-08


Hello,

I am going to add paymentMethod with custom payment(vipps)
I can see paymentMethod params in approveOrder() functions
public function approveOrder(
int $id, string $reason, string $paymentMethod, ?string $transactionId = null,
?string $paymentMethodReferenceId = null, ?string $paymentMethodName = null
): void;

Please check this.

You can see approve function in here.
I supported sb support team for paymentMethod.
They said me, PaymentMethod will add if I inserted all fields in custom payment.

But paymentMethod is not registered yet.
I checked paymentMethod using getOrder() function.
$client = new \SBPay\SBPayClient(
SBPAY_TOKEN, SBPAY_SECRET,
SBPAY_MERCHANT, SBPAY_HOST
);
print_r($client->payments()->getOrder(1263));
Result is like this.

Please help me how to add paymentMethod in custom payment.
Thank you

Redmine Admin wrote:

hi, please check this tickets #1228 #1185

Dmytro Bondarev wrote:

Hi, you can store customer’s payment method and in this case you have to pass paymentMethodInfo parameter, which contains
paymentMethodReferenceId - token or reference from your payment system. it will be used to charge subsequent payments.
paymentMethodName - name of payment method (last 4 digits of card, account name, etc.).

Please note that this is required only for recurring and vaulted payments.

Anonymous wrote:

I tried several time for get paymentMethod.

$client = new \SBPay\SBPayClient(
SBPAY_TOKEN, SBPAY_SECRET,
SBPAY_MERCHANT, SBPAY_HOST
);
print_r($client->payments()->getOrder(1263));
Result is like this.

order_id is 1263
But PaymentMethod is null in result

Dmytro Bondarev wrote:

Hi, Did you see payment method in sbpay? Did you pass pass $paymentMethodReferenceId and $paymentMethodName?

Anonymous wrote:

  1. I didn’t see payment method in sbpay.
  2. How to pass paymentMethodReferenceId and paymentMethodName?

Dmytro Bondarev wrote:

As I said before:
you can store customer’s payment method and in this case you have to pass paymentMethodInfo parameter, which contains
paymentMethodReferenceId - token or reference from your payment system. it will be used to charge subsequent payments.
paymentMethodName - name of payment method (last 4 digits of card, account name, etc.).

If you use SDK then you should pass $paymentMethodReferenceId, $paymentMethodName parameters.

Please note that this is required only for recurring and vaulted payments.

Anonymous wrote:

How can I see payment method? Can you show me example thru screen or url?

Anonymous wrote:

And How can I get paymentMethodReferenceId and paymentMethodName in sbpay?

Dmytro Bondarev wrote:

Sorry, I don’t understand you.
If you pass it, you will see it later. if you don’t pass you will not see it later.

How to pass you can see above.

Anonymous wrote:

Payment method is custom in here?

Transaction details

What is paymentMethodReferenceId and paymentMethodName in above screen?

Dmytro Bondarev wrote:

There’s no payment method info because you haven’t passed. You have never called approve method for this payment. That is why you are not able to see it.

Anonymous wrote:

It’s custom payment(vipps)
Then how can I call approve method for this payment?(custom payment)

Dmytro Bondarev wrote:

Please check example.
When you received notification about successful payment on your side you should call approveOrder of SDK or SBPay.me - Single place for all payment processors API method.

Dmytro Bondarev wrote:

Please have a look sbpay-sdk/example/custom_payment_processor/callback.php at main · dimkasb/sbpay-sdk · GitHub

Anonymous wrote:

As I said you, payment status is pending about custom payment.
I received a payment in vipss.
But payment status is pending.
I need to change status from pending to received using sbpay API or SDK.
I thought, payment status will change from pending to received if I use approveOrder function in SDk.
I have to use paymentMethodName and paymentMethodReferenceId params for use this function.
So I asked you about paymentMethodName.

My goal is to change the receiving state using API or SDK.
Please let me know if you have good solution.
Thank you

Dmytro Bondarev wrote:

You DON’T HAVE TO USE it, you CAN use it if your payment system supports subsequent charges and you need it.
Otherwise just skip these parameters.

Anonymous wrote:

Try to explain more in depth this is what we talked about with simplybook me live chat:

  1. I used to sbpay sdk and checked order

$client = new \SBPay\SBPayClient(
SBPAY_TOKEN, SBPAY_SECRET,
SBPAY_MERCHANT, SBPAY_HOST
);
echo “

”;
print_r($client->payments()->getOrder(1263));
echo “
”;
exit;

order id is 1263

  1. If i have (approveOrder) I can change payment status if I use this function, i think

But (paymentMethod) is required in here.

  1. We used:

I checked order details using this script. So I asking for paymentMethod

sdk

  1. The problem is that it doesnt not work on the booking page.

The booking status is stuck on pending for a whille then says booking is cancled even though the payment has gone through to Vipps.

so I tried change booking status using sbpay sdk. But paymentMethod param is required in sdk. paymentMethod is null for now

The problem is Its just not showing up as paid sbpays side orderstatus. even though the payment has gone through to vipps you get stuck on booking page for a while then shows booking is cancelld even though payment has gone through.

Dmytro Bondarev wrote:

Please provide your call of approveOrder and response from sbpay.

Anonymous wrote:

$client = new \SBPay\SBPayClient(
SBPAY_TOKEN, SBPAY_SECRET,
SBPAY_MERCHANT, SBPAY_HOST
);

$order = $client->payments()->approveOrder(
1263, ‘custom’, ‘’,
‘’, ‘’, ‘custom’
);

error:
Fatal error: Uncaught SBPay\Exceptions\BadRequestException: Validation error in D:\work\xampp-8\htdocs\vendor\sbpay\sdk\lib\SBPayClient.php:167 Stack trace: #0 D:\work\xampp-8\htdocs\vendor\sbpay\sdk\lib\SBPayClient.php(226): SBPay\SBPayClient->request(‘POST’, ‘/order/1263/app…’, ‘{“reason”:"cust…’, ‘19a57c1e1003c84…’) #1 D:\work\xampp-8\htdocs\vendor\sbpay\sdk\lib\SBPayClient.php(243): SBPay\SBPayClient->signedRequest(‘POST’, ‘/order/1263/app…’, Array) #2 D:\work\xampp-8\htdocs\vendor\sbpay\sdk\lib\SBPayPayments.php(51): SBPay\SBPayClient->signedPost(‘/order/1263/app…’, Array) #3 D:\work\xampp-8\htdocs\sbpay.php(43): SBPay\SBPayPayments->approveOrder(1263, ‘custom’, ‘’, ‘’, ‘’, ‘custom’) #4 {main} thrown in D:\work\xampp-8\htdocs\vendor\sbpay\sdk\lib\SBPayClient.php on line 167