Брейнтри подписка в гравитационной форме

Я использую Gravity Form с надстройкой Braintree. Я хочу добавить подписку с помощью кредитной карты. когда я захожу в формы-> расчеты-> braintree, в Типе транзакции есть только одна опция -> Продукты и услуги, где нет возможности подписки, я искал это здесь -> https://developers.braintreepayments.com/javascript+php/guides/recurring-billing

но это не работает для меня.

Пожалуйста, помогите мне об этом.

Спасибо!

-1

Решение

После долгих поисков я нашел что-то отличное.
Просто вызовите вашу среду, торговый ключ, открытый ключ и закрытый ключ в functions.php

Braintree_Configuration::environment($transaction); //Sandbox OR Products
Braintree_Configuration::merchantId($merchant_key); //Your Braintree Merchant Key
Braintree_Configuration::publicKey($public_key);    //Your Braintree Public Key
Braintree_Configuration::privateKey($private_key);  //Your Braintree Private Key

add_action("gform_after_submission", "after_submission", 10, 2);

function after_submission($entry, $form)
{
//Create Customer
$result = Braintree_Customer::create(array(
'firstName' => 'First Name',
'lastName' => 'Last Name',
'company' => 'Company Name',
'email' => 'email@email.com',
));

//Get Current Customer ID
$customer_id = $result->customer->id;

//Add Customer Credit Card Info to Braintree Subscription
$result = Braintree_CreditCard::create(array(
'customerId' => $customer_id,
'number' => '4111111111111111',
'expirationDate' => '05/20',
'cardholderName' => 'Mani'
));

try {

$customer = Braintree_Customer::find($customer_id);
$payment_method_token = $customer->creditCards[0]->token;

//You can add Subscription Package From Braintree Account
$result = Braintree_Subscription::create(array(
'paymentMethodToken' => $payment_method_token,
'planId' => 'Your_subscription_name_here',
'price' => '1000'
));

if ($result->success) {
echo("Success! Subscription " . $result->subscription->id . " is " . $result->subscription->status);
} else {
echo("Validation errors:");
foreach (($result->errors->deepAll()) as $error) {
echo("- " . $error->message);
}
}
} catch (Braintree_Exception_NotFound $e) {
echo("Failure: no customer found with ID " . $customer_id);
}
1

Другие решения

Других решений пока нет …