tuyakhov / yii2-braintree

Integrate a credit card payment form with Braintree's API into Yii2
3 stars 11 forks source link

Just a question #5

Closed andrewblake1 closed 9 years ago

andrewblake1 commented 9 years ago

Re: BrainTreeForm->addErrorFromResponse

Could you provide and example of $key and attribute for:

$key . '_' . $error->attribute

I suspect things must be happening a little different with payment_method_nonce or perhaps becuase using (braintreeClient.tokenizeCard) - to the point, errors errors arn't being added for me.

I can get work around with:

foreach ($result->errors->deepAll() as $error) {
    $this->addError(($error->attribute), $error->message);
}

however for example with an invalid expiry I get an attribute name of expirationDate rather than creditCard_expirationDate - which would perhaps indicate that your $key somehow might be creditCard for that attribute but unclear as to why.

I am not sure about paymentMethodToken, but with nonce at least, credit card number etc arn't posted hence loading into the model doesn't happen therefore $values doesn't contain any keys for credit card number, expiry etc.

As per a previous issue - I am hoping to be able to make this extension more versatile as opposed to creating a different one.

tuyakhov commented 9 years ago

Yep. Main idea is to have some kind of alias. So for example creditCard_expirationDate can be easily transformed into $value['creditCard']['expirationDate'] and just be appended to request body without any additional manipulation. I believe that it is not good way to get it done. I think it should be separated to different models like for example CreditCardForm, CustomerForm etc. But this is how i done it. Almost everything was taken by me from the same extension for yii1 http://www.yiiframework.com/extension/braintreeapi/

andrewblake1 commented 9 years ago

Cheers, will look into this again in next few days.