github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/examples/merchant/payments/ApprovePaymentExample.go (about)

     1  // This file was auto-generated from the API references found at
     2  // https://epayments-api.developer-ingenico.com/
     3  
     4  package examples
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/Ingenico-ePayments/connect-sdk-go/domain/payment"
    10  )
    11  
    12  func approvePaymentExample() {
    13  	client, clientErr := getClient()
    14  	if clientErr != nil {
    15  		panic(clientErr)
    16  	}
    17  	defer client.Close()
    18  
    19  	// Assigning literals to pointer variables directly is not supported.
    20  	// The below code uses helper functions newInt64 and newString to overcome this issue.
    21  	// http://stackoverflow.com/a/30716481 lists a few more alternatives.
    22  	// The code for these helper functions can be found in file Helper.go
    23  
    24  	var directDebitPaymentMethodSpecificInput payment.ApprovePaymentNonSepaDirectDebitPaymentMethodSpecificInput
    25  	directDebitPaymentMethodSpecificInput.DateCollect = newString("20150201")
    26  	directDebitPaymentMethodSpecificInput.Token = newString("bfa8a7e4-4530-455a-858d-204ba2afb77e")
    27  
    28  	var references payment.OrderReferencesApprovePayment
    29  	references.MerchantReference = newString("AcmeOrder0001")
    30  
    31  	var order payment.OrderApprovePayment
    32  	order.References = &references
    33  
    34  	var body payment.ApproveRequest
    35  	body.Amount = newInt64(2980)
    36  	body.DirectDebitPaymentMethodSpecificInput = &directDebitPaymentMethodSpecificInput
    37  	body.Order = &order
    38  
    39  	response, err := client.Merchant("merchantId").Payments().Approve("paymentId", body, nil)
    40  
    41  	fmt.Println(response, err)
    42  }