0

i was having a problem with Wepay API. My codes are correct but it keeps on returning an error saying "payment method does not exist or does not belong to app". I already configured the permission to allow tokenized credit cards. But still. Any feedback is greatly appreciated. Thanks!

Here is my code

require_once('public/payment/wepay/wepay.php');

$user = API::get_client(['fldClientEmail' => $email])->first();

// change to useProduction for live environments   
\Wepay::useStaging(WEPAY_CLIENT_ID, WEPAY_CLIENT_SECRET);

$wepay = new \WePay($user->fldClientWepayTokenAccess);
//        $wepay = new \WePay(WEPAY_ACCESS_TOKEN);

//        dd($email);die;
//        dd($user->fldClientWepayAccountID);die;
// charge the credit card
$response = $wepay->request('checkout/create', [
    'account_id'          => $user->fldClientWepayAccountID,
    'amount'              => number_format(Input::get('amount_tipped'),2),
    'currency'            => 'USD',
    'short_description'   => 'A short description',
    'type'                => 'goods',
    'payment_method'      => array(
    'type'            => 'credit_card',
    'credit_card'     => array(
        'id'          => Input::get('cc_id')
        )
    )
]);

// display the response
return $response;
  • 1
    Debug whats in `Input::get('cc_id')` it should be the customers card id given when you called card/create endpoint. – Lawrence Cherone Jan 05 '18 at 00:01
  • Hi yes, the Input::get('cc_id') is the customer's credit card id created upon card create. – Programmer One Jan 05 '18 at 00:32
  • @ProgrammerOne can you give us an example of what value you are seeing from Input::get('cc_id')? Those tokens only have meaning within your application so no harm in sharing it. You should have used WePay's tokenization library along with your WEPAY_CLIENT_ID to generate a token for the card. – TheF1rstPancake Jan 16 '18 at 23:08

1 Answers1

0

Make sure that when you follow the tutorial from their docs, you replace all of the credentials from the examples. I was using their Javascript library for the tokenization of the credit card with the client_id they provided.

response = WePay.credit_card.create({
        "client_id":        YOUR.CLIENT.ID.HERE,
        "user_name":        valueById('name'),
        "email":            valueById('email'),
        "cc_number":        valueById('cc-number'),
        "cvv":              valueById('cc-cvv'),
        "expiration_month": valueById('cc-month'),
        "expiration_year":  valueById('cc-year'),
        "address": {
            "postal_code": valueById('postal_code')
        }

If you don't provide your own, is like you were creating those credit cards for another application that's not yours.

If this didn't do the trick, check this article, hopefully it does:

https://support.wepay.com/hc/en-us/articles/203609273-WePay-API-Error-Codes

Rafael Mejía
  • 485
  • 4
  • 9