sveawebpay / php-integration

SDK for Sveas payment methods (standalone and Svea Checkout)
Other
15 stars 19 forks source link

Error: 308 (BAD_PAYMENTMETHOD) #90

Open timint opened 3 years ago

timint commented 3 years ago

Testing direct bank finland I can access the payment page with usePayPageDirectBankOnly() rather than setting the bank.

image

But clicking the Nordea icon in the payment gateway immediately throws the customer back to the store with a response error:

object(Svea\WebPay\HostedService\HostedResponse\HostedPaymentResponse)#194 (9) {
  ["transactionId"]=> string(0) ""
  ["clientOrderNumber"]=> string(0) ""
  ["paymentMethod"]=> string(0) ""
  ["merchantId"]=> string(0) ""
  ["amount"]=> string(4) "0.00"
  ["currency"]=> string(0) ""
  ["accepted"]=> int(0)
  ["resultcode"]=> string(23) "308 (BAD_PAYMENTMETHOD)"
  ["errormessage"]=> string(33) "Invalid value for payment method."
}

How do I resolve this?

timint commented 3 years ago

@alexanderwiden95 Any news on this one?

alexanderwiden95 commented 3 years ago

Hi,

Since the action is made on Svea's webpage the issue is more related to their service rather than the SDK. I've contacted the product owner at Svea to get some clarification. They will reach out to you with more information

timint commented 3 years ago

Okay. Just to clearify, this one uses usePayPageDirectBankOnly(). While Issue #89 uses Nordea FI as the preselected gateway.

alexanderwiden95 commented 3 years ago

Hi,

We're unable to reproduce the error following the code at #89 (but using usePayPageDirectBankOnly instead of usePaymentMethod). Could you provide us with some sample code that triggers this error?

timint commented 3 years ago
        $response = $swp->usePayPageDirectBankOnly()
                    ->setPayPageLanguage($order->data['language_code'])
                    ->setReturnUrl(document::ilink('order_process'))
                    ->setCancelUrl(document::ilink('checkout'))
                    ->getPaymentUrl();

Let me explain how this works. The API does not have a DirectBankOnly option. So to do this, the library adds all the methods possible and removes some handpicked ones. Because some of the methods no longer available in the api are still available in the library the user receives an error.

Removing the no longer availabe options is the short term solution. Asking the API crew not to throw an error if an excluded option is already removed could ease the pain. But everytime a new method is added to the library, it will need to be excluded in DirectBankOnly.

The long term solution is that Svea implements an option for directbank only in the API. I think you should escalate this back to the API developers.