· 6 years ago · Nov 05, 2019, 09:18 PM
1 // variables for dd creation
2 $uid = Str::uuid(); // new uuid for each call for duplicate validation
3 $membershipNo = ''; // generated at start of signup process
4 $membershipStartDate = ''; //membership start date
5 $joiningFee = ''; //joining fee in pence
6 $firstPaymentDate= ''; //one month after join date or 1 month after club opening date
7 $monthlyMembershipFee = ''; // monthly fee in pence
8 $totalRecurringAmount = ''; // same as above
9 $secondPaymentDate = ''; // firstpaymentdate + 1 month
10 $contractLengthMonths = ''; // 12 month and rolling (1month)
11 $nonRenewable = ''; //does the contract auto-renew (rolling contract) / true/false
12 $gender = '';
13 $dob = '';
14 $title = '';
15 $forename = '';
16 $surname = '';
17 $address1 = '';
18 $town = '';
19 $postcode = '';
20 $telephone = '';
21 $email = 'email@domain.com';
22 $urlDDCreation = 'URL to API Endpoint';
23
24 // new instance of guzzlehttp client
25 $client = new Client();
26 // make request
27 $request = $client->post($urlDDCreation. [
28 RequestOptions::JSON => [
29 'clientID' => $clientID,
30 'key' => $key,
31 'UID' => $uid,
32 'MembershipNo' => $membershipNo,
33 'TransactionType' => 'CREATE', // CREATE or UPDATE
34 'OriginatorName' => 'SENSITIVE',
35 'OriginatorNumber' => 'SENSITIVE',
36 'AccountName' => $bankName,
37 'AccountNumber' => $account,
38 'SortCode' => $sortcode,
39 'PaymentMethod' => 'DD', // DD or HybridCardDD
40 'PaymentIntervalMonths' => '1', // number of months between payments
41 'MembershipStartDate' => $membershipStartDate,
42 'JoiningFee' => $joiningFee,
43 'FirstPaymentDate' => $firstPaymentDate,
44 'MonthlyMembershipFee' => $monthlyMembershipFee,
45 'TotalRecurringAmount' => $totalRecurringAmount,
46 'SecondPaymentDate' => $secondPaymentDate,
47 'ContractLengthMonths' => $contractLengthMonths,
48 'NonRenewable' => $nonRenewable,
49 'Gender' => $gender,
50 'DOB' => $dob,
51 'Title' => $title,
52 'Forename' => $forename,
53 'Surname' => $surname,
54 'Address1' => $address1,
55 'Town' => $town,
56 'Postcode' => $postcode,
57 'Telephone' => $telephone,
58 'Email' => $email,
59 ]]);
60
61 // get response body for processing
62 $response = $request->getBody()->getContents();
63
64 // decode response into variable
65 $data = json_decode($response);
66
67 dd($data);