whatwedo / PostFinanceEPayment

PHP library for handling PostFinance E-Payments
MIT License
15 stars 6 forks source link

Howto add additional parameters to form #2

Closed Ymox closed 8 years ago

Ymox commented 9 years ago

Grüezi mitenand!

I found your library a moment ago while looking for a way to integrate PostFinance E-Payment into a Symfony project. This is real nice work ! For my project, I need to work with aliases. As far as I understand, to receive an alias in a response, there must be the corresponding field(s) in the form. I could not find out how to add it through the library, as i missed a way to access the payment parameter bag. May I ask you for help?

Thanks in advance

xarem commented 9 years ago

Hey @Ymox

That's true, you don't have direct access to the payment parameter bag. That's not not good :)

I've pushed some changes to the develop Branch which allows you to pass additional payment request parameters.

Can you test it if this works? Here is an example:

$payment = $ePayment->createPayment($client, $order, [
    // Adding ALIAS Parameter for recurring payments
    Parameter::ALIAS      => sprintf('RECURRING_%s_CLIENT_%s', $order->getId(), $client->getId()),
    Parameter::ALIASUSAGE => 'Recurring Invoice for Domain example.com'
]);

I didn't work with the Alias Manager yet (documentation is attached), but according to the documentation, it should work. In addition to that, I've added a getAlias() method to the Response class.

Thanks!

Kind regards Ueli

Ymox commented 9 years ago

Woah, thanks for the quick fix ! As far as I am in my work, I can tell that the signature is correct and accepted at PostFinance, and the field is present in the form when added with the PostFinance. Hurray !

I'll come back when I'll manage to make the whole process work, i.-e. get the alias back.

Ymox commented 8 years ago

Sorry for the delay. Those changes works fine, I can specify and retrieve the alias all right, as well as payment ID. Thanks !