SHARE
TWEET

Untitled

a guest Jul 17th, 2019 177 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function recurringCheckout(Request $request)
  2. {
  3.     $url = config('pagseguro.pagseguroRecurringCheckout');
  4.     $headers = [
  5.         'Content-Type' => 'application/x-www-form-urlencoded;charset=ISO-8859-1',
  6.         'Accept' => 'application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1'
  7.     ];
  8.     $data = [
  9.         'email' => 'marceloamp2@gmail.com',
  10.         'token' => 'XXXXXXXXXXXXXXXXXXXXXXXXX',
  11.         'plan' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  12.         'reference' => $request['reference'],
  13.         'sender.name' => 'Marcelo',
  14.         'sender.email' => $request['sender']['email'],
  15.         'sender.ip' => $request['sender']['ip'],
  16.         'sender.hash' => $request['sender']['hash'],
  17.  
  18.         'sender.phone.areaCode' => '16',
  19.         'sender.phone.number' => '999999999',
  20.  
  21.         'sender.address.street' => 'Rua X',
  22.         'sender.address.number' => 1,
  23.         'sender.address.complement' => 'Apto 13',
  24.         'sender.address.district' => 'Campos Elíseos',
  25.         'sender.address.city' => 'Ribeirão Preto',
  26.         'sender.address.state' => 'SP',
  27.         'sender.address.country' => 'BRA',
  28.         'sender.address.postalCode' => 14085010,
  29.         'paymentMethod.type' => $request['paymentMethod']['type'],
  30.         'paymentMethod.creditCard.token' => $request['paymentMethod']['creditCard']['token'],
  31.         'paymentMethod.creditCard.holder.name' => $request['paymentMethod']['creditCard']['holder']['name'],
  32.         'paymentMethod.creditCard.holder.birthDate' => '13/10/1981',
  33.         'paymentMethod.creditCard.holder.billingAddress.street' => 'Rua X',
  34.         'paymentMethod.creditCard.holder.billingAddress.number' => 1,
  35.         'paymentMethod.creditCard.holder.billingAddress.complement' => 'Apto 13',
  36.         'paymentMethod.creditCard.holder.billingAddress.district' => 'Campos Elíseos',
  37.         'paymentMethod.creditCard.holder.billingAddress.city' => 'Ribeirão Preto',
  38.         'paymentMethod.creditCard.holder.billingAddress.state' => 'SP',
  39.         'paymentMethod.creditCard.holder.billingAddress.country' => 'BRA',
  40.         'paymentMethod.creditCard.holder.billingAddress.postalCode' => 14085010,
  41.  
  42.         'paymentMethod.creditCard.holder.documents.type' => 'CPF',
  43.         'paymentMethod.creditCard.holder.documents.value' => '99999999999',
  44.     ];
  45.     try {
  46.         $client = new Client();
  47.         $response = $client->request('POST', $url, [
  48.             'headers' => $headers,
  49.             'form_params' => $data
  50.         ]);
  51.         $body = $response->getBody();
  52.         $contents = $body->getContents();
  53.         return $contents;
  54.     } catch (Exception $exception) {
  55.         throw new Exception($exception->getResponse()->getBody()->getContents());
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top