Neeraj Prajapati
Neeraj Prajapati

Reputation: 541

mindbody-php-api for stored credit card payment?

I am using mindbody api for payment, when I add my credit card detail then payment is successful but when I am using stored(existing) card for payment then it's given error :

Card Authorization Failed mb.Core.BLL.Transaction failed validation Could not determine the type of credit card.

my code is:

$shoppingCart = array(
                'ClientID' => $client_id,
                'Test' => false,
                'InStore' => true, //add by NIK
                'CartItems' => array(
                    'CartItem' => array(
                        'Quantity' => $product_qty,
                        'Item' => new SoapVar(
                            array('ID' => $product_id), SOAP_ENC_ARRAY, 'Service', 'http://clients.mindbodyonline.com/api/0_5'
                        ),
                        'DiscountAmount' => 0
                    )
                ),

                'Payments' => array(
                    'PaymentInfo' => new SoapVar(
                        array(
                            'LastFour'=>$clientCreditCard->LastFour,
                            'Amount'=>round($OnlinePrice, 2),
                        ),
                        SOAP_ENC_ARRAY,
                        'StoredCardInfo',
                        'http://clients.mindbodyonline.com/api/0_5'
                    ),
                )
            );

please give any solution for it, what should I do or send extra parameter. thanks!

Upvotes: 0

Views: 280

Answers (2)

John Riordan
John Riordan

Reputation: 1

Your shopping cart array with saved card is correctly constructed.

I've been struggling with exactly the same problem for the last few days, and I found that the error in my case was that the front end account page was passing the credit card number with spaces in the string - the front end form was automatically adding the spaces for the usual format/usability reasons in the admin part of the application where the saved card details are entered.

I solved it by stripping out the spaces in PHP : str_replace(" ", "", $_POST['cardnumber']) in the card save function.

Once I did that the saved card payment process worked fine.

Upvotes: 0

delboy1978uk
delboy1978uk

Reputation: 12384

Shouldn't it look more like this?

'Payments' => array(
        'PaymentInfo' => new SoapVar(
            array(
                'CreditCardNumber'=>'4111111111111111', 
                'ExpYear'=>'2015', 
                'ExpMonth'=>'06', 
                'Amount'=>'130', 
                'BillingAddress'=>'123 Happy Ln', 
                'BillingPostalCode'=>'93405'
            ), 
            SOAP_ENC_ARRAY, 
            'CreditCardInfo', 
            'http://clients.mindbodyonline.com/api/0_5'
        )

Taken from this README.md https://github.com/devincrossman/mindbody-php-api

Upvotes: 0

Related Questions